mapstp.utils package¶
Submodules¶
mapstp.utils.io module¶
Input/output utility methods.
- class mapstp.utils._io.MCNPSections[source]¶
Bases:
objectText sections from an MCNP file.
- __init__(cells, surfaces=None, cards=None, remainder=None)¶
- mapstp.utils._io.can_override(path, *, override)[source]¶
Check if it’s allowed to override a path.
- Parameters:
path (
Path) – path, where we are going to writeoverride (
bool) – permission to override flag
- Return type:
Path- Returns:
The input path to facilitate chaining in mapping in code.
- Raises:
FileExistsError – if file exists, but override is not allowed.
- mapstp.utils._io.find_first_cell_number(mcnp)[source]¶
Find the first cell number in MCNP model.
- Parameters:
mcnp (
str|Path) – an input MCNP model file name- Return type:
- Returns:
the first cell number
- Raises:
ValueError – if the cell is not found in the mcnp file.
- mapstp.utils._io.find_first_void_cell_number(mcnp)[source]¶
Find the first void cell number in MCNP model.
- Parameters:
mcnp (
str|Path) – an input MCNP model file name- Return type:
- Returns:
the first void cell number
- Raises:
ValueError – if the cell is not found in the mcnp file.
- mapstp.utils._io.read_mcnp_sections(mcnp_path)[source]¶
Read text sections from MCNP file.
- Parameters:
mcnp_path (
Path) – path to file.- Returns:
the text sections
- Return type:
mapstp.utils.re module¶
The regular expressions to be used in various modules.
- mapstp.utils._re.CARD_PATTERN = re.compile('^\\s{0,4}(?:(?P<comment>[cC]\\s)|(?P<card>\\w+))')¶
Start of MCNP line with comment or any card.
- mapstp.utils._re.CELLS_END_PATTERN = re.compile('^\\s*$')¶
Empty line.
Separates sections in MCNP file.
- mapstp.utils._re.CELL_START_PATTERN = re.compile('^\\s{0,5}(?P<number>\\d+)\\s+(?P<material>\\d+)\\s+')¶
Line starts with two numbers.
- mapstp.utils._re.MATERIAL_PATTERN = re.compile('^\\s{0,4}[mM](?P<material>\\d+)')¶
Start of an MCNP card with material specification.
- mapstp.utils._re.VOID_CELL_START_PATTERN = re.compile('^\\s{0,5}(?P<number>\\d+)\\s+0\\s')¶
Line starts with a number and following zero.
Module contents¶
The mapstp package utility subpackages.
- class mapstp.utils.MCNPSections[source]¶
Bases:
objectText sections from an MCNP file.
- __init__(cells, surfaces=None, cards=None, remainder=None)¶
- mapstp.utils.can_override(path, *, override)[source]¶
Check if it’s allowed to override a path.
- Parameters:
path (
Path) – path, where we are going to writeoverride (
bool) – permission to override flag
- Return type:
Path- Returns:
The input path to facilitate chaining in mapping in code.
- Raises:
FileExistsError – if file exists, but override is not allowed.
- mapstp.utils.find_first_cell_number(mcnp)[source]¶
Find the first cell number in MCNP model.
- Parameters:
mcnp (
str|Path) – an input MCNP model file name- Return type:
- Returns:
the first cell number
- Raises:
ValueError – if the cell is not found in the mcnp file.
- mapstp.utils.read_mcnp_sections(mcnp_path)[source]¶
Read text sections from MCNP file.
- Parameters:
mcnp_path (
Path) – path to file.- Returns:
the text sections
- Return type: