cellpy.readers.instruments package
Subpackages
- cellpy.readers.instruments.configurations package
- Submodules
- cellpy.readers.instruments.configurations.maccor_txt_four module
- cellpy.readers.instruments.configurations.maccor_txt_one module
- cellpy.readers.instruments.configurations.maccor_txt_three module
- cellpy.readers.instruments.configurations.maccor_txt_two module
- cellpy.readers.instruments.configurations.maccor_txt_zero module
- cellpy.readers.instruments.configurations.neware_txt_zero module
- Module contents
ModelParameters
ModelParameters.columns_to_keep
ModelParameters.file_info
ModelParameters.formatters
ModelParameters.incremental_unit_labels
ModelParameters.meta_keys
ModelParameters.name
ModelParameters.normal_headers_renaming_dict
ModelParameters.not_implemented_in_cellpy_yet_renaming_dict
ModelParameters.post_processors
ModelParameters.pre_processors
ModelParameters.prefixes
ModelParameters.raw_limits
ModelParameters.raw_units
ModelParameters.states
ModelParameters.unit_labels
register_configuration_from_module()
register_local_configuration_from_yaml_file()
- cellpy.readers.instruments.loader_specific_modules package
- cellpy.readers.instruments.processors package
- Submodules
- cellpy.readers.instruments.processors.post_processors module
convert_date_time_to_datetime()
convert_step_time_to_timedelta()
convert_test_time_to_timedelta()
convert_units()
cumulate_capacity_within_cycle()
date_time_from_test_time()
get_column_names()
remove_last_if_bad()
rename_headers()
replace()
select_columns_to_keep()
set_cycle_number_not_zero()
set_index()
split_capacity()
split_current()
- cellpy.readers.instruments.processors.pre_processors module
- Module contents
Submodules
cellpy.readers.instruments.arbin_res module
cellpy.readers.instruments.arbin_sql module
arbin MS SQL Server data
- class cellpy.readers.instruments.arbin_sql.DataLoader(*args, **kwargs)[source]
Bases:
BaseLoader
Class for loading arbin-data from MS SQL server.
- static get_headers_aux()[source]
Defines the so-called auxiliary table column headings for Arbin SQL Server
- static get_headers_aux_global()[source]
Defines the so-called auxiliary global column headings for Arbin SQL Server
- static get_headers_global()[source]
Defines the so-called global column headings for Arbin SQL Server
- static get_headers_normal()[source]
Defines the so-called normal column headings for Arbin SQL Server
- static get_raw_units()[source]
Include the settings for the units used by the instrument.
This is needed for example when converting the capacity to a specific capacity. So far, it has been difficult to get any kind of consensus on what the most optimal units are for storing cycling data. Therefore, cellpy implements three levels of units: 1) the raw units that the data is loaded in already has and 2) the cellpy units used by cellpy when generating summaries and related information, and 3) output units that can be set to get the data in a specif unit when exporting or creating specific outputs such as ICA.
Comment 2022.09.11:
still not sure if we should use raw units or cellpy units in the cellpy-files (.h5/ .cellpy). Currently, the summary is in cellpy units and the raw and step data is in raw units. If you have any input on this topic, let us know.
The units are defined w.r.t. the SI units (‘unit-fractions’; currently only units that are multiples of Si units can be used). For example, for current defined in mA, the value for the current unit-fraction will be 0.001.
The internal cellpy units are given in the
cellpy_units
attribute.- Returns
dictionary of units (str)
Example
A minimum viable implementation:
@staticmethod def get_raw_units(): raw_units = dict() raw_units["current"] = "A" raw_units["charge"] = "Ah" raw_units["mass"] = "g" raw_units["voltage"] = "V" return raw_units
- instrument_name = 'arbin_sql'
cellpy.readers.instruments.arbin_sql_7 module
cellpy.readers.instruments.arbin_sql_csv module
arbin MS SQL Server csv data
- class cellpy.readers.instruments.arbin_sql_csv.DataLoader(*args, **kwargs)[source]
Bases:
BaseLoader
Class for loading arbin-data from MS SQL server.
- static get_headers_aux(df)[source]
Defines the so-called auxiliary table column headings for Arbin SQL Server csv
- static get_headers_normal()[source]
Defines the so-called normal column headings for Arbin SQL Server csv
- static get_raw_units()[source]
Include the settings for the units used by the instrument.
This is needed for example when converting the capacity to a specific capacity. So far, it has been difficult to get any kind of consensus on what the most optimal units are for storing cycling data. Therefore, cellpy implements three levels of units: 1) the raw units that the data is loaded in already has and 2) the cellpy units used by cellpy when generating summaries and related information, and 3) output units that can be set to get the data in a specif unit when exporting or creating specific outputs such as ICA.
Comment 2022.09.11:
still not sure if we should use raw units or cellpy units in the cellpy-files (.h5/ .cellpy). Currently, the summary is in cellpy units and the raw and step data is in raw units. If you have any input on this topic, let us know.
The units are defined w.r.t. the SI units (‘unit-fractions’; currently only units that are multiples of Si units can be used). For example, for current defined in mA, the value for the current unit-fraction will be 0.001.
The internal cellpy units are given in the
cellpy_units
attribute.- Returns
dictionary of units (str)
Example
A minimum viable implementation:
@staticmethod def get_raw_units(): raw_units = dict() raw_units["current"] = "A" raw_units["charge"] = "Ah" raw_units["mass"] = "g" raw_units["voltage"] = "V" return raw_units
- instrument_name = 'arbin_sql_csv'
- loader(name, **kwargs)[source]
returns a Data object with loaded data.
Loads data from arbin SQL server db.
- Parameters
name (str) – name of the file
- Returns
new_tests (list of data objects)
- raw_ext = 'csv'
cellpy.readers.instruments.arbin_sql_h5 module
arbin MS SQL Server exported h5 data
- class cellpy.readers.instruments.arbin_sql_h5.DataLoader(*args, **kwargs)[source]
Bases:
BaseLoader
Class for loading arbin-data from MS SQL server.
- static get_headers_aux(df)[source]
Defines the so-called auxiliary table column headings for Arbin SQL Server h5 export
- static get_headers_normal()[source]
Defines the so-called normal column headings for Arbin SQL Server h5 export
- static get_raw_units()[source]
Include the settings for the units used by the instrument.
This is needed for example when converting the capacity to a specific capacity. So far, it has been difficult to get any kind of consensus on what the most optimal units are for storing cycling data. Therefore, cellpy implements three levels of units: 1) the raw units that the data is loaded in already has and 2) the cellpy units used by cellpy when generating summaries and related information, and 3) output units that can be set to get the data in a specif unit when exporting or creating specific outputs such as ICA.
Comment 2022.09.11:
still not sure if we should use raw units or cellpy units in the cellpy-files (.h5/ .cellpy). Currently, the summary is in cellpy units and the raw and step data is in raw units. If you have any input on this topic, let us know.
The units are defined w.r.t. the SI units (‘unit-fractions’; currently only units that are multiples of Si units can be used). For example, for current defined in mA, the value for the current unit-fraction will be 0.001.
The internal cellpy units are given in the
cellpy_units
attribute.- Returns
dictionary of units (str)
Example
A minimum viable implementation:
@staticmethod def get_raw_units(): raw_units = dict() raw_units["current"] = "A" raw_units["charge"] = "Ah" raw_units["mass"] = "g" raw_units["voltage"] = "V" return raw_units
- instrument_name = 'arbin_sql_h5'
- loader(name, **kwargs)[source]
returns a Data object with loaded data.
Loads data from arbin SQL server h5 export.
- Parameters
name (str) – name of the file
- Returns
data object
- raw_ext = 'h5'
cellpy.readers.instruments.arbin_sql_xlsx module
arbin MS SQL Server csv data
- class cellpy.readers.instruments.arbin_sql_xlsx.DataLoader(*args, **kwargs)[source]
Bases:
BaseLoader
Class for loading arbin-data from MS SQL server.
- static get_headers_aux(df)[source]
Defines the so-called auxiliary table column headings for Arbin SQL Server csv
- static get_headers_normal()[source]
Defines the so-called normal column headings for Arbin SQL Server csv
- static get_raw_units()[source]
Include the settings for the units used by the instrument.
This is needed for example when converting the capacity to a specific capacity. So far, it has been difficult to get any kind of consensus on what the most optimal units are for storing cycling data. Therefore, cellpy implements three levels of units: 1) the raw units that the data is loaded in already has and 2) the cellpy units used by cellpy when generating summaries and related information, and 3) output units that can be set to get the data in a specif unit when exporting or creating specific outputs such as ICA.
Comment 2022.09.11:
still not sure if we should use raw units or cellpy units in the cellpy-files (.h5/ .cellpy). Currently, the summary is in cellpy units and the raw and step data is in raw units. If you have any input on this topic, let us know.
The units are defined w.r.t. the SI units (‘unit-fractions’; currently only units that are multiples of Si units can be used). For example, for current defined in mA, the value for the current unit-fraction will be 0.001.
The internal cellpy units are given in the
cellpy_units
attribute.- Returns
dictionary of units (str)
Example
A minimum viable implementation:
@staticmethod def get_raw_units(): raw_units = dict() raw_units["current"] = "A" raw_units["charge"] = "Ah" raw_units["mass"] = "g" raw_units["voltage"] = "V" return raw_units
- instrument_name = 'arbin_sql_xlsx'
- loader(name, **kwargs)[source]
returns a Data object with loaded data.
Loads data from arbin SQL server db.
- Parameters
name (str) – name of the file
- Returns
data object
- raw_ext = 'xlsx'
cellpy.readers.instruments.base module
When you make a new loader you have to subclass the Loader class. Remember also to register it in cellpy.cellreader.
(for future development, not used very efficiently yet).
- class cellpy.readers.instruments.base.AtomicLoad[source]
Bases:
object
Atomic loading class
- property fid
The unique file id
- instrument_name = 'atomic_loader'
- property is_db
Is the file stored in the database
- loader(*args, **kwargs)[source]
The method that does the actual loading.
This method should be overwritten by the specific loader class.
- property name
The name of the file to be loaded
- property refuse_copying
Should the file be copied to a temporary file
- property temp_file_path
The name of the file to be loaded if copied to a temporary file
- class cellpy.readers.instruments.base.AutoLoader(*args, **kwargs)[source]
Bases:
BaseLoader
Main autoload class.
This class can be sub-classed if you want to make a data-reader for different type of “easily parsed” files (for example csv-files). The subclass needs to have at least one associated CONFIGURATION_MODULE defined and must have the following attributes as minimum:
default_model: str = NICK_NAME_OF_DEFAULT_CONFIGURATION_MODULE supported_models: dict = SUPPORTED_MODELS
where SUPPORTED_MODELS is a dictionary with {NICK_NAME : CONFIGURATION_MODULE_NAME} key-value pairs. Remark! the NICK_NAME must be in upper-case!
It is also possible to set these in a custom pre_init method:
@classmethod def pre_init(cls): cls.default_model: str = NICK_NAME_OF_DEFAULT_CONFIGURATION_MODULE cls.supported_models: dict = SUPPORTED_MODELS
or turn off automatic registering of configuration:
@classmethod def pre_init(cls): cls.auto_register_config = False # defaults to True
During initialisation of the class, if
auto_register_config == True
, it will dynamically load the definitions provided in the CONFIGURATION_MODULE.py located in thecellpy.readers.instruments.configurations
folder/package.Attributes can be set during initialisation of the class as **kwargs that are then handled by the
parse_formatter_parameters
method.Remark that some also can be provided as arguments to the
loader
method and will then automatically be “transparent” to thecellpy.get
function. So if you would like to give the user access to modify these arguments, you should implement them in theparse_loader_parameters
method.- get_raw_limits()[source]
Include the settings for how to decide what kind of step you are examining here.
The raw limits are ‘epsilons’ used to check if the current and/or voltage is stable (for example for galvanostatic steps, one would expect that the current is stable (constant) and non-zero). It is expected that different instruments (with different resolution etc.) have different ‘epsilons’.
- Returns
the raw limits (dict)
- get_raw_units()[source]
Include the settings for the units used by the instrument.
The units are defined w.r.t. the SI units (‘unit-fractions’; currently only units that are multiples of Si units can be used). For example, for current defined in mA, the value for the current unit-fraction will be 0.001.
- Returns
dictionary containing the unit-fractions for current, charge, and mass
- instrument_name = 'auto_loader'
- loader(name: Union[str, Path], **kwargs: str) Data [source]
returns a Data object with loaded data.
Loads data from a txt file (csv-ish).
- Parameters
name (str, pathlib.Path) – name of the file.
kwargs (dict) – key-word arguments from raw_loader.
- Returns
new_tests (list of data objects)
- parse_meta() dict [source]
method that parses the data for meta-data (e.g. start-time, channel number, …)
- register_configuration() ModelParameters [source]
Register and load model configuration
- class cellpy.readers.instruments.base.BaseLoader[source]
Bases:
AtomicLoad
Main loading class
- classmethod get_params(parameter: Optional[str]) dict [source]
Retrieves parameters needed for facilitating working with the instrument without registering it.
Typically, it should include the name and raw_ext.
Return: parameters or a selected parameter
- abstract get_raw_limits() dict [source]
Include the settings for how to decide what kind of step you are examining here.
The raw limits are ‘epsilons’ used to check if the current and/or voltage is stable (for example for galvanostatic steps, one would expect that the current is stable (constant) and non-zero). If the (accumulated) change is less than ‘epsilon’, then cellpy interpret it to be stable. It is expected that different instruments (with different resolution etc.) have different resolutions and noice levels, thus different ‘epsilons’.
Returns: the raw limits (dict)
- abstract static get_raw_units() dict [source]
Include the settings for the units used by the instrument.
This is needed for example when converting the capacity to a specific capacity. So far, it has been difficult to get any kind of consensus on what the most optimal units are for storing cycling data. Therefore, cellpy implements three levels of units: 1) the raw units that the data is loaded in already has and 2) the cellpy units used by cellpy when generating summaries and related information, and 3) output units that can be set to get the data in a specif unit when exporting or creating specific outputs such as ICA.
Comment 2022.09.11:
still not sure if we should use raw units or cellpy units in the cellpy-files (.h5/ .cellpy). Currently, the summary is in cellpy units and the raw and step data is in raw units. If you have any input on this topic, let us know.
The units are defined w.r.t. the SI units (‘unit-fractions’; currently only units that are multiples of Si units can be used). For example, for current defined in mA, the value for the current unit-fraction will be 0.001.
The internal cellpy units are given in the
cellpy_units
attribute.- Returns
dictionary of units (str)
Example
A minimum viable implementation:
@staticmethod def get_raw_units(): raw_units = dict() raw_units["current"] = "A" raw_units["charge"] = "Ah" raw_units["mass"] = "g" raw_units["voltage"] = "V" return raw_units
- static identify_last_data_point(data: Data) Data [source]
This method is used to find the last record in the data.
- instrument_name = 'base_loader'
- class cellpy.readers.instruments.base.TxtLoader(*args, **kwargs)[source]
Bases:
AutoLoader
,ABC
Main txt loading class (for sub-classing).
The subclass of a
TxtLoader
gets its information by loading model specifications from its respective module (cellpy.readers.instruments.configurations.<module>
) or configuration file (yaml).Remark that if you implement automatic loading of the formatter, the module / yaml-file must include all the required formatter parameters (sep, skiprows, header, encoding, decimal, thousands).
If you need more flexibility, try using the
CustomTxtLoader
or subclass directly fromAutoLoader
orLoader
.- Constructor:
model (str): short name of the (already implemented) sub-model. sep (str): delimiter. skiprows (int): number of lines to skip. header (int): number of the header lines. encoding (str): encoding. decimal (str): character used for decimal in the raw data, defaults to ‘.’. processors (dict): pre-processing steps to take (before loading with pandas). post_processors (dict): post-processing steps to make after loading the data, but before returning them to the caller. include_aux (bool): also parse so-called auxiliary columns / data. Defaults to False. keep_all_columns (bool): load all columns, also columns that are not 100% necessary for
cellpy
to work. Remark that the configuration settings for the sub-model must include a list of column header names that should be kept if keep_all_columns is False (default).- Module:
sep (str): the delimiter (also works as a switch to turn on/off automatic detection of delimiter and start of data (skiprows)).
- instrument_name = 'txt_loader'
- raw_ext = '*'
- cellpy.readers.instruments.base.find_delimiter_and_start(file_name, separators=None, checking_length_header=30, checking_length_whole=200)[source]
function to automatically detect the delimiter and what line the first data appears on.
- Remark! This function is rather simple, it splits the data into to parts
(possible header part (checking_length_header) and the rest of the data). Then it counts the appearances of the different possible delimiters in the rest of the data part, and then selects a delimiter if it has unique counts for all the lines.
The first line is defined as where the delimiter is used same number of times (probably a header line).
cellpy.readers.instruments.biologics_mpr module
cellpy.readers.instruments.custom module
This module is used for loading data using the instrument=”custom” method. If no instrument_file is given (either directly or through the use of the :: separator), the default instrument file (yaml) will be used.
cellpy.readers.instruments.ext_nda_reader module
- class cellpy.readers.instruments.ext_nda_reader.DataLoader(*args, **kwargs)[source]
Bases:
BaseLoader
Class for using the NDA loader by Frederik Huld (Beyonder).
- static get_params(parameter=None)[source]
Retrieves parameters needed for facilitating working with the instrument without registering it.
Typically, it should include the name and raw_ext.
Return: parameters or a selected parameter
- get_raw_limits()[source]
Include the settings for how to decide what kind of step you are examining here.
The raw limits are ‘epsilons’ used to check if the current and/or voltage is stable (for example for galvanostatic steps, one would expect that the current is stable (constant) and non-zero). It is expected that different instruments (with different resolution etc.) have different ‘epsilons’.
Returns: the raw limits (dict)
- get_raw_units()[source]
Include the settings for the units used by the instrument.
The units are defined w.r.t. the SI units (‘unit-fractions’; currently only units that are multiples of Si units can be used). For example, for current defined in mA, the value for the current unit-fraction will be 0.001.
Returns: dictionary containing the unit-fractions for current, charge, and mass
- instrument_name = 'neware_nda'
cellpy.readers.instruments.local_instrument module
This module is used for loading data using the corresponding Local yaml file with definitions on how the data should be loaded. This loader is based on the TxtLoader and can only be used to load csv-type files
cellpy.readers.instruments.maccor_txt module
Maccor txt data
- class cellpy.readers.instruments.maccor_txt.DataLoader(*args, **kwargs)[source]
Bases:
TxtLoader
Class for loading data from Maccor txt files.
- default_model = 'one'
- instrument_name = 'maccor_txt'
- raw_ext = 'txt'
- supported_models = {'FOUR': 'maccor_txt_four', 'KIT_COMMA_SIMBA': 'maccor_txt_two', 'KIT_SIMBA': 'maccor_txt_four', 'ONE': 'maccor_txt_one', 'S4000-KIT': 'maccor_txt_four', 'S4000-UBHAM': 'maccor_txt_three', 'S4000-WMG': 'maccor_txt_four', 'THREE': 'maccor_txt_three', 'TWO': 'maccor_txt_two', 'UBHAM_SIMBA': 'maccor_txt_three', 'WMG_SIMBA': 'maccor_txt_three', 'ZERO': 'maccor_txt_zero'}
cellpy.readers.instruments.neware_txt module
Neware txt data - with explanations how it was implemented.
Update SUPPORTED_MODELS, raw_ext and default_model
- Add instrument to prms.py
create the boxed item:
Neware = {“default_model”: “UIO”} Neware = box.Box(Neware)
…
- add it to Instruments:
Instruments = InstrumentsClass( … Neware=Neware )
Update the dataclass in prms.py:
@dataclass class InstrumentsClass(CellPyConfig):
tester: str custom_instrument_definitions_file: Union[str, None] Arbin: box.Box Maccor: box.Box Neware: box.Box
(optionally) add Neware defaults to .cellpy_prms_default.conf
Create instrument configuration file in readers/instruments/configurations
formatters states normal_headers_renaming_dict file_info raw_units post_processors
Put a file in test_data and create at least one test.
cellpy.readers.instruments.pec_csv module
pec csv-type data files
- class cellpy.readers.instruments.pec_csv.DataLoader(*args, **kwargs)[source]
Bases:
BaseLoader
Main loading class
- get_raw_limits()[source]
Include the settings for how to decide what kind of step you are examining here.
The raw limits are ‘epsilons’ used to check if the current and/or voltage is stable (for example for galvanostatic steps, one would expect that the current is stable (constant) and non-zero). It is expected that different instruments (with different resolution etc.) have different ‘epsilons’.
Returns: the raw limits (dict)
- static get_raw_units()[source]
Include the settings for the units used by the instrument.
The units are defined w.r.t. the SI units (‘unit-fractions’; currently only units that are multiples of Si units can be used). For example, for current defined in mA, the value for the current unit-fraction will be 0.001.
Returns: dictionary containing the unit-fractions for current, charge, and mass
- instrument_name = 'pec_csv'
- raw_ext = 'csv'