pymchelper.readers package#

Subpackages#

Submodules#

pymchelper.readers.common module#

class pymchelper.readers.common.Reader(filename)[source]#

Bases: object

abstract property corename#
read(estimator)[source]#
abstract read_data(estimator)[source]#
class pymchelper.readers.common.ReaderFactory(filename)[source]#

Bases: object

abstract get_reader()[source]#

pymchelper.readers.fluka module#

class pymchelper.readers.fluka.AxesDescription(x: AxisDescription, y: AxisDescription, z: AxisDescription)[source]#

Bases: object

Axes descriptions

x: AxisDescription#
y: AxisDescription#
z: AxisDescription#
class pymchelper.readers.fluka.FlukaReader(filename)[source]#

Bases: Reader

property corename#

corename_fort.XX. :return: corename part of output file or None in case filename doesn’t follow Fluka naming pattern

Type:

Fluka output filenames follow this pattern

parse_data(estimator)[source]#

TODO :param estimator: an Estimator object, will be modified here and filled with data

parse_resnuclei(estimator)[source]#

TODO add support for resnuclei RESNUCLEi Scores residual nuclei produced in inelastic interactions on a region basis :param estimator: an Estimator object, will be modified here and filled with data

parse_usrbdx(estimator)[source]#

USRBDX defines a detector for a boundary crossing fluence or current estimator.

Parameters:

estimator – an Estimator object, will be modified here and filled with data

parse_usrbin(estimator)[source]#

USRBIN scores distribution of one of several quantities in a regular spatial structure (binning detector) independent from the geometry. :param estimator: an Estimator object, will be modified here and filled with data

parse_usrtrack(estimator)[source]#
Parameters:

estimator – an Estimator object, will be modified here and filled with data

USRTRACK defines a detector for a track-length fluence estimator

read_data(estimator, nscale=1)[source]#

TODO :param estimator: an Estimator object, will be modified here and filled with data

class pymchelper.readers.fluka.FlukaReaderFactory(filename)[source]#

Bases: ReaderFactory

Class responsible for discovery of filetype.

get_reader()[source]#

Try reading header of Fluka binary file and return a corresponding FlukaReader object

Returns:

FlukaReader class if file is digested by Usrxxx Flair reader. None is returned otherwise

class pymchelper.readers.fluka.UsrbinScoring[source]#

Bases: object

Helper class for USRBIN scoring

static get_axes_description(binning_type: int) AxesDescription[source]#

Get axes descriptions for binning type

classmethod get_unit_and_factor_for_scoring(scoring: str) -> (<class 'str'>, <class 'float'>)[source]#

Get unit and rescaling factor for scoring

Based on: - (1) https://flukafiles.web.cern.ch/manual/chapters/particle_and_material_codes/particles_codes.html - (2) https://flukafiles.web.cern.ch/manual/chapters/description_input/description_options/usrbin.html

Parameters:

scoring – scoring name

Returns:

tuple of scoring and unit

pymchelper.readers.fluka.get_particle_from_db(particle_id: int) Particle | None[source]#

Get particle from Flair database by its id

pymchelper.readers.topas module#

class pymchelper.readers.topas.TopasReader(filename)[source]#

Bases: Reader

Reader for Topas output files

property corename: str#
read_data(estimator: Estimator) bool[source]#

Read the data from the file and store them in the provided estimator object. TOPAS reader assumes that the input file is in the same directory as the output file to extract the number of histories from it. If the name of the input file is not found in the output file or the input file is not in the same directory, the number of histories is set to 0.

class pymchelper.readers.topas.TopasReaderFactory(filename)[source]#

Bases: ReaderFactory

Factory for TopasReader

get_reader()[source]#

Return TopasReader if the file extension is .csv

pymchelper.readers.topas.extract_bins_data(dimensions: List[str], header_lines: List[str]) dict | None[source]#

Takes as arguments a list of dimensions (e.g. [‘X’, ‘Y’, ‘Z’]) and three consecutive lines from the output file header. Returns dict containing number of bins, bin size and unit for each dimension or None if output file does not contain this information for provided dimensions

pymchelper.readers.topas.extract_differential_axis(header_line: str) MeshAxis | None[source]#

Check if the output file contains differential axis and get it from file if it does

pymchelper.readers.topas.extract_parameter_filename(header_line: str) str | None[source]#

Get parameter filename from the output file

pymchelper.readers.topas.extract_scorer_name(header_line: str) str | None[source]#

Get scorer name from the output file

pymchelper.readers.topas.extract_scorer_unit_results(header_line: str) Tuple[str, str, List] | None[source]#

Get scoring quantity, unit and the scoring values (sum/mean/etc.) from the output file

pymchelper.readers.topas.get_topas_estimators(output_files_path: str) List[Estimator][source]#

Get Topas estimators from provided directory

Module contents#