Python API

The Python API is a wrapper around the C++ API. Structures and functionality is copied from the C++ API with as similar naming as possible.

Parfis class

Parfis class is the main class of the API. It provides options to load the compiled dynamical library.

class parfis.Parfis
static getConfig(id: int) int

Wrapper for parfis::api::getConfig(id). Returns the configuration by reading the loaded objects properties, not a copy of the configuration string. The returned string is formated in a manner that the same string can be used as input string (or saved to file - as input file).

Parameters

id (int) – Parfis id.

Returns

Configuration string

Return type

str

static info() int

Wrapper for parfis::api::info()

Returns

Info about parfis lib

Return type

str

static load_lib(mode='Release', stateType='double')

Loads speciffic library version in memory. This is needed only once per script life. By loading with different parameters the dynamic library get unloaded and different version is loaded.

Parameters
  • mode (str) –

    Available modes:

    • ’Release’ - load release version

    • ’Debug’ - load debug version

    • ’Copy’ - load debug version if python is in debug mode, otherwise load release version

  • stateType (str) –

    Available state types:

    • ’double’ - load library with state type double

    • ’float’ - load library with state type float

Data structure classes

class parfis.Vec3DBase(x=0, y=0, z=0)

Base parent class for the Vec3D (resembles template Vec3D). Class is inherited from other Vec3D_<type> classes.

class parfis.Type

Defines type names similary to the c++ module.

cellId_t

alias of c_uint

cellPos_t

alias of c_ushort

nodeFlag_t

alias of c_ubyte

stateId_t

alias of c_uint

state_t

alias of c_double

class parfis.PyFuncTable

Wrapper for the parfis::PyFuncTable class. The structure is coppied from parfis::PyFuncTable.

type

Type of tabulation (0: linear, 1:nonlinear).

Type

c_int

colCnt

Number of columns (increase of 1, in memory address increases the column counter). If you want values ordered in memory pack them in successive columns.

Type

c_int

rowCnt

Number of rows.

Type

c_int

ranges

Ranges for tabulation.

Type

c_double

nbins

Number of bins per range.

Type

c_int

idx

Delta x in every range.

Type

c_double

xVec

X axis.

Type

c_double

yVec

Y axis (or multiple axis - a matrix).

Type

c_double

Example

Generating simple cross sections

Python tools

Tools in python are used for generating data (ex: cross-section tabulated functions) and data processing.

parfis.generateCrossSection(func: Callable[[float], float], ranges: List[float], nbins: List[int], file: Optional[str] = None) Tuple[ndarray[Any, dtype[ScalarType]], ndarray[Any, dtype[ScalarType]]]

Function used to generate tabulated functions for the use as cross-section data. Data is tabulated for the x-axis.

Parameters
  • func (Callable) – Mathemathical callable in the form func(x) -> y, where x is in eV and y is returned as A^2.

  • ranges (List[float]) – Ranges, starts from 0.

  • nbins (List[int]) – Number of bins for every range.

Returns

numpy.ndarray (x, y).

Return type

npt.NDArray