mapstp package¶
Subpackages¶
Submodules¶
mapstp.exceptions module¶
Utility module to specify exception hierarchy for all tee package.
- exception mapstp.exceptions.MyError[source]¶
Bases:
ValueErrorBase class for exceptions in the mapstp package.
- exception mapstp.exceptions.PathInfoError[source]¶
Bases:
MyErrorError on extracting information for labels specified in STP paths.
- __init__(message, row, path_info)[source]¶
Create exception object with information on location in path_info caused the error.
- Parameters:
message (
str) – explanation, what happenedrow (
int) – row in path_info tablepath_info (
DataFrame) – the path_info tableself (PathInfoError)
- Return type:
None
mapstp.extract_info module¶
Extract meta information from paths given in an STP file.
- class mapstp.extract_info.MetaInfoCollector[source]¶
Bases:
objectHelper to store meta information from a path.
- __init__(mnemonic=None, factor=None, rwcl=None)¶
- mapstp.extract_info.define_material_number_and_density(material_index, meta_info, path)[source]¶
Define material number and density from a material index for given meta info.
- mapstp.extract_info.extract_meta_info_from_path(path)[source]¶
Extract meta information from an STP path.
- Parameters:
path (
str) – … to body with [m-…] tags- Return type:
- Returns:
Collected meta info map.
mapstp.materials module¶
Code to load materials map.
The map associates material number to its MCNP specification text.
- mapstp.materials.MaterialsDict¶
Mapping material number -> material MCNP text.
- mapstp.materials.drop_material_cards(lines)[source]¶
Drop lines belonging to material cards.
Used on replacing materials in the model with ones actually used.
- mapstp.materials.get_used_materials(materials_map, path_info)[source]¶
Collect text of used materials specifications.
- mapstp.materials.get_used_materials_sql(con, materials_map)[source]¶
Collect text of used materials specifications.
- Parameters:
con (
Connection) – database connectionmaterials_map (
dict[int,str]) – map material number -> spec.
- Return type:
- mapstp.materials.load_materials_map(materials)[source]¶
Read materials from MCNP file.
- Parameters:
materials (
str|Path) – name of MCNP file, containing materials to read- Returns:
mapping material number -> material text
- Return type:
MaterialsDict
mapstp.materials_index module¶
Code to load materials index.
- mapstp.materials_index.load_materials_index(materials_index=None)[source]¶
Load material index from file.
- Parameters:
materials_index (
str|None) – file name of index to load, if not provided, uses data/default-material-index.xlsx- Return type:
DataFrame
Note
Validation of material index input values is postponed to usage of defined mnemonics. The input file may contain ‘missed’ data for mnemonics in design phase, until the mnemonics are actually used.
- Return type:
DataFrame- Returns:
DataFrame with columns mnemonic, number of material, density with omitted rows, where mnemonic is not specified.
- Raises:
FileNotFoundError – if the file materials_index doesn’t exist.
- Parameters:
materials_index (str | None)
mapstp.merge module¶
The module implements algorithms to transform MCNP model.
Inserts end comments with information about path in STP corresponding to a cell and sets materials and densities, if specified in STP paths.
- mapstp.merge.extract_number_and_density(cell, path_info)[source]¶
Extract material number and density from a path_info for a given cell.
Validate the values: number, if provided, is to be positive, density - not negative.
- mapstp.merge.is_defined(number)[source]¶
Check if number coming from a DataFrame object cell is not None or NaN.
mapstp.stp_parser module¶
The module defines methods and classes to parse STP file and represent parsing results.
- class mapstp.stp_parser.Body[source]¶
Bases:
NumberedBody (MCNP cell) definition.
- classmethod from_string(text)[source]¶
Parse MANIFOLD_SOLID_BREP line.
- Parameters:
text (
str) – input text- Return type:
- Returns:
The new Body object.
- Raises:
STPParserError – on invalid input
- class mapstp.stp_parser.LeafProduct[source]¶
Bases:
ProductThe class to append bodies to “Product definitions”.
- __init__(number, name, bodies=<factory>)¶
- append(body)[source]¶
Append body to this product.
Only applicable to LeafProduct.
- Parameters:
body (
Body) – what to appendself (LeafProduct)
- Return type:
- class mapstp.stp_parser.Link[source]¶
Bases:
NumberedLinkage between products.
- __init__(number, name, src, dst)¶
- classmethod from_string(text)[source]¶
Parse STP line with NEXT_OCCURRENCE_USAGE.
The line specifies a source->destination link between products.
- Parameters:
text (
str) – line from STP file being parsed.- Return type:
- Returns:
new Link object.
- Raises:
STPParserError – on invalid input
- class mapstp.stp_parser.Numbered[source]¶
Bases:
objectThe class shares common property of STP objects: number.
- class mapstp.stp_parser.Product[source]¶
Bases:
NumberedThe class to store “Product definitions”.
- classmethod from_string(text)[source]¶
Create Product from a text string.
- Parameters:
text (
str) – Line with ‘PRODUCT_DEFINITION’ statement from an STP file.- Return type:
- Returns:
New product with given number and name.
- Raises:
STPParserError – if text doesn’t match ‘PRODUCT_DEFINITION’ statement format.
mapstp.tree module¶
Data structures and algorithms to store and process STP nodes and their links.
- class mapstp.tree.Node[source]¶
Bases:
objectNode for the following Tree class.
Stores the references to a Product corresponding to a number presented in a Link as source or destination. Also stores reference to its parent node. Only upward search is necessary in this application, so, there’s no references to childes.
- __init__(product, parent=None)¶
- class mapstp.tree.Tree[source]¶
Bases:
objectUpward directed tree: it is used to find only the parents from a given node.
Indexes and stores results of STP file parsing.
mapstp.workflow module¶
The module contains typical workflow methods and base methods for them.
Use imported methods to organize other workflows in notebooks or dependant packages. Check the methods defined here as templates for other workflows.
Module contents¶
The mapstp package.
Provides functionality to transfer meta information inserted to STP file component names as special tags to MCNP files generated from the STP with SuperMC.