libpyvinyl.BaseCalculator
- class libpyvinyl.BaseCalculator(name, input, output_keys, output_data_types, output_filenames=None, instrument_base_dir='./', calculator_base_dir=None, parameters=None)[source]
- Class:
Base class of all calculators.
This class is provides the libpyvinyl API. It defines all methods through which a user interacts with the simulation backengines.
This class is to be used as a base class for all calculators that implement a special simulation module, such as a photon diffraction calculator. Such a specialized Calculator has the same interface to the simulation backengine as all other ViNYL Calculators.
A complete example including a instrument and calculators can be found in
test/integration/plusminus
- Parameters:
name (
str
) – The name of this calculator.input (
Union
[DataCollection
,List
[BaseData
],BaseData
]) – The input of this calculator. It can be a DataCollection, a list of `BaseData`s or a single Data Object.output_keys (
Union
[list
,str
]) – The key(s) of this calculator’s output data.output_data_types (
Union
[list
,BaseData
]) – The data type(s), i.e., classes, of each output. It’s a list of the data classes or a single data class. The available data classes are based on BaseData.output_filenames (
Union
[list
,str
,None
]) – The name(s) of the output file(s). It can be a str of a filename or a list of filenames. If the mapping is dict mapping, the name is None. Defaults to None.instrument_base_dir (
str
) – The base directory for the instrument to which this calculator belongs. The final exact output file path depends on instrument_base_dir and calculator_base_dir: instrument_base_dir/calculator_base_dir/filenamecalculator_base_dir (
Optional
[str
]) – The base directory for this calculator. The final exact output file path depends on instrument_base_dir and calculator_base_dir: instrument_base_dir/calculator_base_dir/filenameparameters (
Optional
[CalculatorParameters
]) – The parameters for this calculator.
- __init__(name, input, output_keys, output_data_types, output_filenames=None, instrument_base_dir='./', calculator_base_dir=None, parameters=None)[source]
- Parameters:
name (
str
) – The name of this calculator.input (
Union
[DataCollection
,List
[BaseData
],BaseData
]) – The input of this calculator. It can be a DataCollection, a list of `BaseData`s or a single Data Object.output_keys (
Union
[list
,str
]) – The key(s) of this calculator’s output data.output_data_types (
Union
[list
,BaseData
]) – The data type(s), i.e., classes, of each output. It’s a list of the data classes or a single data class. The available data classes are based on BaseData.output_filenames (
Union
[list
,str
,None
]) – The name(s) of the output file(s). It can be a str of a filename or a list of filenames. If the mapping is dict mapping, the name is None. Defaults to None.instrument_base_dir (
str
) – The base directory for the instrument to which this calculator belongs. The final exact output file path depends on instrument_base_dir and calculator_base_dir: instrument_base_dir/calculator_base_dir/filenamecalculator_base_dir (
Optional
[str
]) – The base directory for this calculator. The final exact output file path depends on instrument_base_dir and calculator_base_dir: instrument_base_dir/calculator_base_dir/filenameparameters (
Optional
[CalculatorParameters
]) – The parameters for this calculator.
Methods
__init__
(name, input, output_keys, ...[, ...])- type name:
dump
([fname])Dump class instance to file.
from_dump
(dumpfile)Load a dill dump from a dumpfile.
Virtual method to initialize all parameters.
reset_parameters
(value)Resets the calculator parameters
set_calculator_base_dir
(value)Set the calculator base directory
set_input
(value)Set the calculator input data.
set_instrument_base_dir
(value)Set the instrument base directory
set_output_data_types
(value)Set the calculator output data type.
set_output_filenames
(value)Set the calculator output filenames.
set_output_keys
(value)Set the calculator output keys.
set_parameters
([args_as_dict])Sets parameters contained in this calculator using dict or kwargs
Attributes
The base path for the output files of this calculator in consideration of instrument_base_dir and calculator_base_dir
The alias of output.
The output of this calculator
The final output file paths considering base_dir