cellpy.parameters.internal_settings

Contents

cellpy.parameters.internal_settings#

Internal settings and definitions and functions for getting them.

Module Contents#

Classes#

BaseHeaders

Subclass of BaseSetting including option to add postfixes.

BaseSettings

Base class for internal cellpy settings.

CellpyLimits

These are the limits used inside cellpy for finding step types.

CellpyMeta

Base class for meta-data in cellpy.

CellpyMetaCommon

Common (not test-dependent) meta-data for cellpy.

CellpyMetaIndividualTest

Test-dependent meta-data for cellpy.

CellpyUnits

These are the units used inside Cellpy.

DictLikeClass

Add some dunder-methods so that it does not break old code that used

HeaderDict

A Sub-class of dict to allow for tab-completion.

HeadersJournal

Headers used for the journal (batch) (used as column headers for the journal pandas DataFrames)

HeadersNormal

Headers used for the normal (raw) data (used as column headers for the main data pandas DataFrames)

HeadersStepTable

Headers used for the steps table (used as column headers for the steps pandas DataFrames)

HeadersSummary

Headers used for the summary data (used as column headers for the main data pandas DataFrames)

InstrumentSettings

Base class for instrument settings.

Functions#

get_cellpy_units(→ CellpyUnits)

Returns an augmented global dictionary with units

get_default_cellpy_file_raw_units(→ CellpyUnits)

Returns a dictionary with units to use as default for old versions of cellpy files

get_default_custom_headers_summary(→ HeadersSummary)

Returns an augmented dictionary that can be used to create custom header-strings for the summary

get_default_output_units(→ CellpyUnits)

Returns an augmented dictionary with units to use as default.

get_default_raw_limits(→ CellpyLimits)

Returns an augmented dictionary with units as default for raw data

get_default_raw_units(→ CellpyUnits)

Returns a dictionary with units as default for raw data

get_headers_journal(→ HeadersJournal)

Returns an augmented global dictionary containing the header-strings for the journal (batch)

get_headers_normal(→ HeadersNormal)

Returns an augmented global dictionary containing the header-strings for the normal data

get_headers_step_table(→ HeadersStepTable)

Returns an augmented global dictionary containing the header-strings for the steps table

get_headers_summary(→ HeadersSummary)

Returns an augmented global dictionary containing the header-strings for the summary

Attributes#

ATTRS_TO_IMPORT_FROM_EXCEL_SQLITE

BATCH_ATTRS_TO_IMPORT_FROM_EXCEL_SQLITE

CELLPY_FILE_VERSION

COLUMNS_EXCEL_PK

COLUMNS_RENAMER

MINIMUM_CELLPY_FILE_VERSION

OTHERPATHS

PICKLE_PROTOCOL

RAW_TABLE_VERSION

STEP_TABLE_VERSION

SUMMARY_TABLE_VERSION

TABLE_NAME_SQLITE

base_columns_float

base_columns_int

cellpy_units

headers_journal

headers_normal

headers_step_table

headers_summary

keys_journal_session

class BaseHeaders[source]#

Bases: BaseSettings

Inheritance diagram of cellpy.parameters.internal_settings.BaseHeaders

Subclass of BaseSetting including option to add postfixes.

Example

>>> header["key_postfix"]  # returns "value_postfix"
postfixes = [][source]#
class BaseSettings[source]#

Bases: DictLikeClass

Inheritance diagram of cellpy.parameters.internal_settings.BaseSettings

Base class for internal cellpy settings.

Usage:

@dataclass
class MyCoolCellpySetting(BaseSetting):
    var1: str = "first var"
    var2: int = 12
get(key)[source]#

Get the value (postfixes not supported).

to_frame()[source]#

Converts to pandas dataframe

class CellpyLimits[source]#

Bases: BaseSettings

Inheritance diagram of cellpy.parameters.internal_settings.CellpyLimits

These are the limits used inside cellpy for finding step types.

Since all instruments have an inherent inaccuracy, it is naive to assume that for example the voltage within a constant voltage step does not change at all. Therefore, we need to define some limits for what we consider to be a constant and what we assume to be zero.

current_hard: float = 1e-13[source]#
current_soft: float = 1e-05[source]#
ir_change: float = 1e-05[source]#
stable_charge_hard: float = 0.9[source]#
stable_charge_soft: float = 5.0[source]#
stable_current_hard: float = 2.0[source]#
stable_current_soft: float = 4.0[source]#
stable_voltage_hard: float = 2.0[source]#
stable_voltage_soft: float = 4.0[source]#
class CellpyMeta[source]#

Base class for meta-data in cellpy.

digest(as_list: bool = False, **kwargs)[source]#

Pops from dictionary of form {key: [values]}

Parameters:
  • as_list (bool) – pick only first scalar if True.

  • **kwargs (dict) – key word attributes to pick.

Returns:

Dictionary containing the non-digested part.

to_frame()[source]#

Converts to pandas dataframe

update(as_list: bool = False, **kwargs)[source]#

Updates from dictionary of form {key: [values]}

Parameters:
  • as_list (bool) – pick only first scalar if True.

  • **kwargs (dict) – key word attributes to update.

Returns:

None

class CellpyMetaCommon[source]#

Bases: CellpyMeta

Inheritance diagram of cellpy.parameters.internal_settings.CellpyMetaCommon

Common (not test-dependent) meta-data for cellpy.

active_electrode_area: cellpy.prms.CellPyDataConfig | None[source]#
active_electrode_current_collector: cellpy.prms.CellPyDataConfig | None[source]#
active_electrode_thickness: cellpy.prms.CellPyDataConfig | None[source]#
active_electrode_type: cellpy.prms.CellPyDataConfig | None[source]#
cell_name: str | None[source]#
cell_type: cellpy.prms.CellPyDataConfig | None[source]#
cellpy_file_version: int[source]#
comment: cellpy.prms.CellPyDataConfig | None[source]#
counter_electrode_type: cellpy.prms.CellPyDataConfig | None[source]#
electrolyte_type: cellpy.prms.CellPyDataConfig | None[source]#
electrolyte_volume: cellpy.prms.CellPyDataConfig | None[source]#
experiment_type: cellpy.prms.CellPyDataConfig | None[source]#
file_errors: str | None[source]#
mass: cellpy.prms.CellPyDataConfig | None[source]#
material: cellpy.prms.CellPyDataConfig | None[source]#
nom_cap: cellpy.prms.CellPyDataConfig | None[source]#
nom_cap_specifics: cellpy.prms.CellPyDataConfig | None[source]#
raw_id: str | None[source]#
reference_electrode_current_collector: cellpy.prms.CellPyDataConfig | None[source]#
reference_electrode_type: cellpy.prms.CellPyDataConfig | None[source]#
separator_type: cellpy.prms.CellPyDataConfig | None[source]#
start_datetime: str | None[source]#
tester_ID: cellpy.prms.CellPyDataConfig | None[source]#
tester_calibration_date: cellpy.prms.CellPyDataConfig | None[source]#
tester_client_software_version: cellpy.prms.CellPyDataConfig | None[source]#
tester_server_software_version: cellpy.prms.CellPyDataConfig | None[source]#
time_zone: str | None[source]#
tot_mass: cellpy.prms.CellPyDataConfig | None[source]#
class CellpyMetaIndividualTest[source]#

Bases: CellpyMeta

Inheritance diagram of cellpy.parameters.internal_settings.CellpyMetaIndividualTest

Test-dependent meta-data for cellpy.

channel_index: cellpy.prms.CellPyDataConfig | None[source]#
creator: str | None[source]#
cycle_mode: cellpy.prms.CellPyDataConfig | None[source]#
schedule_file_name[source]#
test_ID: cellpy.prms.CellPyDataConfig | None[source]#
test_type: cellpy.prms.CellPyDataConfig | None[source]#
voltage_lim_high: cellpy.prms.CellPyDataConfig | None[source]#
voltage_lim_low: cellpy.prms.CellPyDataConfig | None[source]#
class CellpyUnits[source]#

Bases: BaseSettings

Inheritance diagram of cellpy.parameters.internal_settings.CellpyUnits

These are the units used inside Cellpy.

At least two sets of units needs to be defined; cellpy_units and raw_units. The data.raw dataframe is given in raw_units where the units are defined inside the instrument loader used. Since the data.steps dataframe is a summary of the step statistics from the data.raw dataframe, this also uses the raw_units. The data.summary dataframe contains columns with values directly from the data.raw dataframe given in raw_units as well as calculated columns given in cellpy_units.

Remark that all input to cellpy through user interaction (or utils) should be in cellpy_units. This is also true for meta-data collected from the raw files. The instrument loader needs to take care of the translation from its raw units to cellpy_units during loading the raw data file for the meta-data (remark that this is not necessary and not recommended for the actual “raw” data that is going to be stored in the data.raw dataframe).

As of 2022.09.29, cellpy does not automatically ensure unit conversion for input of meta-data, but has an internal method (CellPyData.to_cellpy_units) that can be used.

These are the different attributes currently supported for data in the dataframes:

current: str = "A"
charge: str = "mAh"
voltage: str = "V"
time: str = "sec"
resistance: str = "Ohms"
power: str = "W"
energy: str = "Wh"
frequency: str = "hz"

And here are the different attributes currently supported for meta-data:

# output-units for specific capacity etc.
specific_gravimetric: str = "g"
specific_areal: str = "cm**2"  # used for calculating specific capacity etc.
specific_volumetric: str = "cm**3"  # used for calculating specific capacity etc.

# other meta-data
nominal_capacity: str = "mAh/g"  # used for calculating rates etc.
mass: str = "mg"
length: str = "cm"
area: str = "cm**2"
volume: str = "cm**3"
temperature: str = "C"
area: str = 'cm**2'[source]#
charge: str = 'mAh'[source]#
current: str = 'A'[source]#
energy: str = 'Wh'[source]#
frequency: str = 'hz'[source]#
length: str = 'cm'[source]#
mass: str = 'mg'[source]#
nominal_capacity: str = 'mAh/g'[source]#
power: str = 'W'[source]#
pressure: str = 'bar'[source]#
resistance: str = 'ohm'[source]#
specific_areal: str = 'cm**2'[source]#
specific_gravimetric: str = 'g'[source]#
specific_volumetric: str = 'cm**3'[source]#
temperature: str = 'C'[source]#
time: str = 'sec'[source]#
voltage: str = 'V'[source]#
volume: str = 'cm**3'[source]#
update(new_units: dict)[source]#

Update the units.

class DictLikeClass[source]#

Add some dunder-methods so that it does not break old code that used dictionaries for storing settings

Remarks: it is not a complete dictionary experience - for example, setting new attributes (new keys) is not supported (raises KeyError if using the typical dict setting method) since it uses the dataclasses.fields method to find its members.

items()[source]#
keys()[source]#
values()[source]#
class HeaderDict(dict=None, /, **kwargs)[source]#

Bases: collections.UserDict

Inheritance diagram of cellpy.parameters.internal_settings.HeaderDict

A Sub-class of dict to allow for tab-completion.

class HeadersJournal[source]#

Bases: BaseHeaders

Inheritance diagram of cellpy.parameters.internal_settings.HeadersJournal

Headers used for the journal (batch) (used as column headers for the journal pandas DataFrames)

area: str = 'area'[source]#
argument: str = 'argument'[source]#
cell_type: str = 'cell_type'[source]#
cellpy_file_name: str = 'cellpy_file_name'[source]#
comment: str = 'comment'[source]#
experiment: str = 'experiment'[source]#
filename: str = 'filename'[source]#
fixed: str = 'fixed'[source]#
group: str = 'group'[source]#
instrument: str = 'instrument'[source]#
label: str = 'label'[source]#
loading: str = 'loading'[source]#
mass: str = 'mass'[source]#
nom_cap: str = 'nom_cap'[source]#
raw_file_names: str = 'raw_file_names'[source]#
sub_group: str = 'sub_group'[source]#
total_mass: str = 'total_mass'[source]#
class HeadersNormal[source]#

Bases: BaseHeaders

Inheritance diagram of cellpy.parameters.internal_settings.HeadersNormal

Headers used for the normal (raw) data (used as column headers for the main data pandas DataFrames)

ac_impedance_txt: str = 'ac_impedance'[source]#
aci_phase_angle_txt: str = 'aci_phase_angle'[source]#
amplitude_txt: str = 'amplitude'[source]#
channel_id_txt: str = 'channel_id'[source]#
charge_capacity_txt: str = 'charge_capacity'[source]#
charge_energy_txt: str = 'charge_energy'[source]#
current_txt: str = 'current'[source]#
cycle_index_txt: str = 'cycle_index'[source]#
data_flag_txt: str = 'data_flag'[source]#
data_point_txt: str = 'data_point'[source]#
datetime_txt: str = 'date_time'[source]#
discharge_capacity_txt: str = 'discharge_capacity'[source]#
discharge_energy_txt: str = 'discharge_energy'[source]#
dv_dt_txt: str = 'dv_dt'[source]#
frequency_txt: str = 'frequency'[source]#
internal_resistance_txt: str = 'internal_resistance'[source]#
is_fc_data_txt: str = 'is_fc_data'[source]#
power_txt: str = 'power'[source]#
ref_ac_impedance_txt: str = 'ref_ac_impedance'[source]#
ref_aci_phase_angle_txt: str = 'ref_aci_phase_angle'[source]#
ref_voltage_txt: str = 'reference_voltage'[source]#
step_index_txt: str = 'step_index'[source]#
step_time_txt: str = 'step_time'[source]#
sub_step_index_txt: str = 'sub_step_index'[source]#
sub_step_time_txt: str = 'sub_step_time'[source]#
test_id_txt: str = 'test_id'[source]#
test_name_txt: str = 'test_name'[source]#
test_time_txt: str = 'test_time'[source]#
voltage_txt: str = 'voltage'[source]#
class HeadersStepTable[source]#

Bases: BaseHeaders

Inheritance diagram of cellpy.parameters.internal_settings.HeadersStepTable

Headers used for the steps table (used as column headers for the steps pandas DataFrames)

charge: str = 'charge'[source]#
current: str = 'current'[source]#
cycle: str = 'cycle'[source]#
discharge: str = 'discharge'[source]#
info: str = 'info'[source]#
internal_resistance: str = 'ir'[source]#
internal_resistance_change: str = 'ir_pct_change'[source]#
point: str = 'point'[source]#
rate_avr: str = 'rate_avr'[source]#
step: str = 'step'[source]#
step_time: str = 'step_time'[source]#
sub_step: str = 'sub_step'[source]#
sub_type: str = 'sub_type'[source]#
test: str = 'test'[source]#
test_time: str = 'test_time'[source]#
type: str = 'type'[source]#
ustep: str = 'ustep'[source]#
voltage: str = 'voltage'[source]#
class HeadersSummary[source]#

Bases: BaseHeaders

Inheritance diagram of cellpy.parameters.internal_settings.HeadersSummary

Headers used for the summary data (used as column headers for the main data pandas DataFrames)

In addition to the headers defined here, the summary might also contain specific headers (ending in _gravimetric or _areal).

property areal_charge_capacity: str[source]#
property areal_discharge_capacity: str[source]#
property specific_columns: List[str][source]#

Returns a list of the columns that can be “specific” (e.g. pr. mass or pr. area) for the summary table.

channel_id: str = 'channel_id'[source]#
charge_c_rate: str = 'charge_c_rate'[source]#
charge_capacity: str = 'charge_capacity'[source]#
charge_capacity_loss: str = 'charge_capacity_loss'[source]#
charge_capacity_raw: str = 'charge_capacity'[source]#
coulombic_difference: str = 'coulombic_difference'[source]#
coulombic_efficiency: str = 'coulombic_efficiency'[source]#
cumulated_charge_capacity: str = 'cumulated_charge_capacity'[source]#
cumulated_charge_capacity_loss: str = 'cumulated_charge_capacity_loss'[source]#
cumulated_coulombic_difference: str = 'cumulated_coulombic_difference'[source]#
cumulated_coulombic_efficiency: str = 'cumulated_coulombic_efficiency'[source]#
cumulated_discharge_capacity: str = 'cumulated_discharge_capacity'[source]#
cumulated_discharge_capacity_loss: str = 'cumulated_discharge_capacity_loss'[source]#
cumulated_ric: str = 'cumulated_ric'[source]#
cumulated_ric_disconnect: str = 'cumulated_ric_disconnect'[source]#
cumulated_ric_sei: str = 'cumulated_ric_sei'[source]#
cycle_index: str = 'cycle_index'[source]#
data_flag: str = 'data_flag'[source]#
data_point: str = 'data_point'[source]#
datetime: str = 'date_time'[source]#
discharge_c_rate: str = 'discharge_c_rate'[source]#
discharge_capacity: str = 'discharge_capacity'[source]#
discharge_capacity_loss: str = 'discharge_capacity_loss'[source]#
discharge_capacity_raw: str = 'discharge_capacity'[source]#
end_voltage_charge: str = 'end_voltage_charge'[source]#
end_voltage_discharge: str = 'end_voltage_discharge'[source]#
high_level: str = 'high_level'[source]#
ir_charge: str = 'ir_charge'[source]#
ir_discharge: str = 'ir_discharge'[source]#
low_level: str = 'low_level'[source]#
normalized_charge_capacity: str = 'normalized_charge_capacity'[source]#
normalized_cycle_index: str = 'normalized_cycle_index'[source]#
normalized_discharge_capacity: str = 'normalized_discharge_capacity'[source]#
ocv_first_max: str = 'ocv_first_max'[source]#
ocv_first_min: str = 'ocv_first_min'[source]#
ocv_second_max: str = 'ocv_second_max'[source]#
ocv_second_min: str = 'ocv_second_min'[source]#
postfixes = ['gravimetric', 'areal'][source]#
pre_aux: str = 'aux_'[source]#
shifted_charge_capacity: str = 'shifted_charge_capacity'[source]#
shifted_discharge_capacity: str = 'shifted_discharge_capacity'[source]#
temperature_last: str = 'temperature_last'[source]#
temperature_mean: str = 'temperature_mean'[source]#
test_name: str = 'test_name'[source]#
test_time: str = 'test_time'[source]#
class InstrumentSettings[source]#

Bases: DictLikeClass

Inheritance diagram of cellpy.parameters.internal_settings.InstrumentSettings

Base class for instrument settings.

Usage:

@dataclass
class MyCoolInstrumentSetting(InstrumentSettings):
    var1: str = "first var"
    var2: int = 12

Remark! Try to use it as you would use a normal dataclass.

get_cellpy_units(*args, **kwargs) CellpyUnits[source]#

Returns an augmented global dictionary with units

get_default_cellpy_file_raw_units(*args, **kwargs) CellpyUnits[source]#

Returns a dictionary with units to use as default for old versions of cellpy files

get_default_custom_headers_summary() HeadersSummary[source]#

Returns an augmented dictionary that can be used to create custom header-strings for the summary (used as column headers for the summary pandas DataFrames)

This function is mainly implemented to provide an example.

get_default_output_units(*args, **kwargs) CellpyUnits[source]#

Returns an augmented dictionary with units to use as default.

get_default_raw_limits() CellpyLimits[source]#

Returns an augmented dictionary with units as default for raw data

get_default_raw_units(*args, **kwargs) CellpyUnits[source]#

Returns a dictionary with units as default for raw data

get_headers_journal() HeadersJournal[source]#

Returns an augmented global dictionary containing the header-strings for the journal (batch) (used as column headers for the journal pandas DataFrames)

get_headers_normal() HeadersNormal[source]#

Returns an augmented global dictionary containing the header-strings for the normal data (used as column headers for the main data pandas DataFrames)

get_headers_step_table() HeadersStepTable[source]#

Returns an augmented global dictionary containing the header-strings for the steps table (used as column headers for the steps pandas DataFrames)

get_headers_summary() HeadersSummary[source]#

Returns an augmented global dictionary containing the header-strings for the summary (used as column headers for the summary pandas DataFrames)

ATTRS_TO_IMPORT_FROM_EXCEL_SQLITE = ['name', 'label', 'project', 'cell_group', 'cellpy_file_name', 'instrument', 'cell_type',...[source]#
BATCH_ATTRS_TO_IMPORT_FROM_EXCEL_SQLITE = ['comment_history', 'sub_batch_01', 'sub_batch_02', 'sub_batch_03', 'sub_batch_04',...[source]#
CELLPY_FILE_VERSION = 8[source]#
COLUMNS_EXCEL_PK = 'id'[source]#
COLUMNS_RENAMER[source]#
MINIMUM_CELLPY_FILE_VERSION = 4[source]#
OTHERPATHS = ['rawdatadir', 'cellpydatadir'][source]#
PICKLE_PROTOCOL = 4[source]#
RAW_TABLE_VERSION = 5[source]#
STEP_TABLE_VERSION = 5[source]#
SUMMARY_TABLE_VERSION = 7[source]#
TABLE_NAME_SQLITE = 'cells'[source]#
base_columns_float[source]#
base_columns_int[source]#
cellpy_units[source]#
headers_journal[source]#
headers_normal[source]#
headers_step_table[source]#
headers_summary[source]#
keys_journal_session = ['starred', 'bad_cells', 'bad_cycles', 'notes'][source]#