pyprobe.filters module#
A module for the filtering classes.
- get_cycle_column(filter)#
Adds a cycle column to the data.
If cycle details have been provided in the README, the cycle column will be created by checking for the last step of the cycle. For nested cycles, the “outer” cycle will be created first. Subsequent filtering with the cycle method will then allow for filtering on the “inner” cycles.
If no cycle details have been provided, the cycle column will be created by identifying the last step of the cycle by checking for a decrease in the step number.
- Parameters:
filter (FilterToCycleType) – The experiment or cycle object.
- Returns:
The data with a cycle column.
- Return type:
pl.DataFrame | pl.LazyFrame
- pydantic model Procedure(*, base_dataframe, info, column_definitions=None, step_descriptions={}, readme_dict, cycle_info=[])#
Bases:
RawData
A class for a procedure in a battery experiment.
- Validators:
- Parameters:
base_dataframe (LazyFrame | DataFrame)
info (Dict[str, str | int | float | Dict[Any, Any] | None])
column_definitions (Dict[str, str])
step_descriptions (Dict[str, List[str | int | None]])
readme_dict (Dict[str, Dict[str, List[str | int | Tuple[int, int, int]]]])
cycle_info (List[Tuple[int, int, int]])
- Return type:
None
- field readme_dict: Dict[str, Dict[str, List[str | int | Tuple[int, int, int]]]] [Required]#
A dictionary representing the data contained in the README yaml file.
- Validated by:
_load_base_dataframe
- field cycle_info: List[Tuple[int, int, int]] = []#
A list of tuples representing the cycle information from the README yaml file.
The tuple format is
(start step (inclusive), end step (inclusive), cycle count)
.- Validated by:
_load_base_dataframe
- step(*step_numbers, condition=None)#
Return a step object. Filters to a numerical condition on the Event column.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
step_numbers (int | range) – Variable-length argument list of step indices or a range object.
condition (pl.Expr, optional) – A polars expression to filter the step before applying the numerical filter. Defaults to None.
- Returns:
A step object.
- Return type:
- cycle(*cycle_numbers)#
Return a cycle object. Filters on the Cycle column.
- Parameters:
filter (FilterToExperimentType) – A filter object that this method is called on.
cycle_numbers (int | range) – Variable-length argument list of cycle indices or a range object.
- Returns:
A cycle object.
- Return type:
- charge(*charge_numbers)#
Return a charge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
charge_numbers (int | range) – Variable-length argument list of charge indices or a range object.
- Returns:
A charge step object.
- Return type:
- discharge(*discharge_numbers)#
Return a discharge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
discharge_numbers (int | range) – Variable-length argument list of discharge indices or a range object.
- Returns:
A discharge step object.
- Return type:
- chargeordischarge(*chargeordischarge_numbers)#
Return a charge or discharge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
chargeordischarge_numbers (int | range) – Variable-length argument list of charge or discharge indices or a range object.
- Returns:
A charge or discharge step object.
- Return type:
- rest(*rest_numbers)#
Return a rest step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
rest_numbers (int | range) – Variable-length argument list of rest indices or a range object.
- Returns:
A rest step object.
- Return type:
- constant_current(*constant_current_numbers)#
Return a constant current step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
constant_current_numbers (int | range) – Variable-length argument list of constant current indices or a range object.
- Returns:
A constant current step object.
- Return type:
- constant_voltage(*constant_voltage_numbers)#
Return a constant voltage step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
constant_current_numbers (int | range) – Variable-length argument list of constant voltage indices or a range object.
constant_voltage_numbers (int | range)
- Returns:
A constant voltage step object.
- Return type:
- experiment(*experiment_names)#
Return an experiment object from the procedure.
- Parameters:
experiment_names (str) – Variable-length argument list of experiment names.
- Returns:
An experiment object from the procedure.
- Return type:
- remove_experiment(*experiment_names)#
Remove an experiment from the procedure.
- Parameters:
experiment_names (str) – Variable-length argument list of experiment names.
- Return type:
None
- property experiment_names: List[str]#
Return the names of the experiments in the procedure.
- Returns:
The names of the experiments in the procedure.
- Return type:
List[str]
- add_external_data(filepath, importing_columns, date_column_name='Date')#
Add data from another source to the procedure.
The data must be timestamped, with a column that can be interpreted in DateTime format. The data will be interpolated to the procedure’s time.
- Parameters:
filepath (str) – The path to the external file.
importing_columns (List[str] | Dict[str, str]) – The columns to import from the external file. If a list, the columns will be imported as is. If a dict, the keys are the columns in the data you want to import and the values are the columns you want to rename them to.
date_column_name (str, optional) – The name of the date column in the external data. Defaults to “Date”.
- Return type:
None
- load_external_file(filepath)#
Load an external file into a LazyFrame.
Supported file types are CSV, Parquet, and Excel. For maximum performance, consider using Parquet files. If you have an Excel file, consider converting it to CSV before loading.
- Parameters:
filepath (str) – The path to the external file.
- Return type:
LazyFrame
- pydantic model Experiment(*, base_dataframe, info, column_definitions=None, step_descriptions={}, cycle_info=[])#
Bases:
RawData
A class for an experiment in a battery experimental procedure.
- Validators:
- Parameters:
base_dataframe (LazyFrame | DataFrame)
info (Dict[str, str | int | float | Dict[Any, Any] | None])
column_definitions (Dict[str, str])
step_descriptions (Dict[str, List[str | int | None]])
cycle_info (List[Tuple[int, int, int]])
- Return type:
None
- field cycle_info: List[Tuple[int, int, int]] = []#
A list of tuples representing the cycle information from the README yaml file.
The tuple format is
(start step (inclusive), end step (inclusive), cycle count)
.- Validated by:
_load_base_dataframe
- step(*step_numbers, condition=None)#
Return a step object. Filters to a numerical condition on the Event column.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
step_numbers (int | range) – Variable-length argument list of step indices or a range object.
condition (pl.Expr, optional) – A polars expression to filter the step before applying the numerical filter. Defaults to None.
- Returns:
A step object.
- Return type:
- cycle(*cycle_numbers)#
Return a cycle object. Filters on the Cycle column.
- Parameters:
filter (FilterToExperimentType) – A filter object that this method is called on.
cycle_numbers (int | range) – Variable-length argument list of cycle indices or a range object.
- Returns:
A cycle object.
- Return type:
- charge(*charge_numbers)#
Return a charge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
charge_numbers (int | range) – Variable-length argument list of charge indices or a range object.
- Returns:
A charge step object.
- Return type:
- discharge(*discharge_numbers)#
Return a discharge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
discharge_numbers (int | range) – Variable-length argument list of discharge indices or a range object.
- Returns:
A discharge step object.
- Return type:
- chargeordischarge(*chargeordischarge_numbers)#
Return a charge or discharge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
chargeordischarge_numbers (int | range) – Variable-length argument list of charge or discharge indices or a range object.
- Returns:
A charge or discharge step object.
- Return type:
- rest(*rest_numbers)#
Return a rest step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
rest_numbers (int | range) – Variable-length argument list of rest indices or a range object.
- Returns:
A rest step object.
- Return type:
- constant_current(*constant_current_numbers)#
Return a constant current step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
constant_current_numbers (int | range) – Variable-length argument list of constant current indices or a range object.
- Returns:
A constant current step object.
- Return type:
- constant_voltage(*constant_voltage_numbers)#
Return a constant voltage step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
constant_current_numbers (int | range) – Variable-length argument list of constant voltage indices or a range object.
constant_voltage_numbers (int | range)
- Returns:
A constant voltage step object.
- Return type:
- pydantic model Cycle(*, base_dataframe, info, column_definitions=None, step_descriptions={}, cycle_info=[])#
Bases:
RawData
A class for a cycle in a battery experimental procedure.
- Validators:
- Parameters:
base_dataframe (LazyFrame | DataFrame)
info (Dict[str, str | int | float | Dict[Any, Any] | None])
column_definitions (Dict[str, str])
step_descriptions (Dict[str, List[str | int | None]])
cycle_info (List[Tuple[int, int, int]])
- Return type:
None
- field cycle_info: List[Tuple[int, int, int]] = []#
A list of tuples representing the cycle information from the README yaml file.
The tuple format is
(start step (inclusive), end step (inclusive), cycle count)
.- Validated by:
_load_base_dataframe
- step(*step_numbers, condition=None)#
Return a step object. Filters to a numerical condition on the Event column.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
step_numbers (int | range) – Variable-length argument list of step indices or a range object.
condition (pl.Expr, optional) – A polars expression to filter the step before applying the numerical filter. Defaults to None.
- Returns:
A step object.
- Return type:
- charge(*charge_numbers)#
Return a charge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
charge_numbers (int | range) – Variable-length argument list of charge indices or a range object.
- Returns:
A charge step object.
- Return type:
- discharge(*discharge_numbers)#
Return a discharge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
discharge_numbers (int | range) – Variable-length argument list of discharge indices or a range object.
- Returns:
A discharge step object.
- Return type:
- chargeordischarge(*chargeordischarge_numbers)#
Return a charge or discharge step.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
chargeordischarge_numbers (int | range) – Variable-length argument list of charge or discharge indices or a range object.
- Returns:
A charge or discharge step object.
- Return type:
- rest(*rest_numbers)#
Return a rest step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
rest_numbers (int | range) – Variable-length argument list of rest indices or a range object.
- Returns:
A rest step object.
- Return type:
- constant_current(*constant_current_numbers)#
Return a constant current step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
constant_current_numbers (int | range) – Variable-length argument list of constant current indices or a range object.
- Returns:
A constant current step object.
- Return type:
- constant_voltage(*constant_voltage_numbers)#
Return a constant voltage step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
constant_current_numbers (int | range) – Variable-length argument list of constant voltage indices or a range object.
constant_voltage_numbers (int | range)
- Returns:
A constant voltage step object.
- Return type:
- pydantic model Step(*, base_dataframe, info, column_definitions=None, step_descriptions={})#
Bases:
RawData
A class for a step in a battery experimental procedure.
- Validators:
- Parameters:
base_dataframe (LazyFrame | DataFrame)
info (Dict[str, str | int | float | Dict[Any, Any] | None])
column_definitions (Dict[str, str])
step_descriptions (Dict[str, List[str | int | None]])
- Return type:
None
- step(*step_numbers, condition=None)#
Return a step object. Filters to a numerical condition on the Event column.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
step_numbers (int | range) – Variable-length argument list of step indices or a range object.
condition (pl.Expr, optional) – A polars expression to filter the step before applying the numerical filter. Defaults to None.
- Returns:
A step object.
- Return type:
- constant_current(*constant_current_numbers)#
Return a constant current step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
constant_current_numbers (int | range) – Variable-length argument list of constant current indices or a range object.
- Returns:
A constant current step object.
- Return type:
- constant_voltage(*constant_voltage_numbers)#
Return a constant voltage step object.
- Parameters:
filter (FilterToCycleType) – A filter object that this method is called on.
constant_current_numbers (int | range) – Variable-length argument list of constant voltage indices or a range object.
constant_voltage_numbers (int | range)
- Returns:
A constant voltage step object.
- Return type: