Skip to content

Utils

Batch processing, plotting, and the analysis helpers.

Batch

batch

Routines for batch processing of cells (v2).

Batch

Batch(*args, **kwargs)

A convenience class for running batch procedures.

The Batch class contains (among other things):

  • iterator protocol
  • a journal with info about the different cells where the main information is accessible as a pandas.DataFrame through the .pages attribute
  • a data lookup accessor .data that behaves similarly as a dict.

The initialization accepts arbitrary arguments and keyword arguments. It first looks for the file_name and db_reader keyword arguments.

Usage::

b = Batch((name, (project)), **kwargs)

Examples:

>>> b = Batch("experiment001", "main_project")
>>> b = Batch("experiment001", "main_project", batch_col="b02")
>>> b = Batch(name="experiment001", project="main_project", batch_col="b02")
>>> b = Batch(file_name="cellpydata/batchfiles/cellpy_batch_experiment001.json")

Parameters:

  • name (str) –

    (project (str))

Other Parameters:

  • file_name (str or Path) –

    journal file name to load.

  • db_reader (str) –

    data-base reader to use (defaults to "default" as given in the config-file or prm-class).

  • db_reader_path (str or Path) –

    path to send to the db_reader.

  • frame (DataFrame) –

    load from given dataframe.

  • default_log_level (str) –

    custom log-level (defaults to None (i.e. default log-level in cellpy)).

  • custom_log_dir (str or Path) –

    custom folder for putting the log-files.

  • force_raw_file (bool) –

    load from raw regardless (defaults to False).

  • force_cellpy (bool) –

    load cellpy-files regardless (defaults to False).

  • force_recalc (bool) –

    Always recalculate (defaults to False).

  • export_cycles (bool) –

    Extract and export individual cycles to csv (defaults to True).

  • export_raw (bool) –

    Extract and export raw-data to csv (defaults to True).

  • export_ica (bool) –

    Extract and export individual dQ/dV data to csv (defaults to True).

  • accept_errors (bool) –

    Continue automatically to next file if error is raised (defaults to False).

  • nom_cap (float) –

    give a nominal capacity if you want to use another value than the one given in the config-file or prm-class.

info_file property

info_file

The name of the info file.

summaries property

summaries

Concatenated summaries from all cells (multiindex dataframe).

summary_headers property

summary_headers

The column names of the concatenated summaries

view property

view

Show the selected info about each cell.

collect

collect(cells: list[CellpyCell] = None, **kwargs)

Collect data from the cells.

Parameters:

  • cells (list, default: None ) –

    list of cellpy cell objects.

  • **kwargs

    keyword arguments to be sent to the collector.

Returns:

  • None

combine_summaries

combine_summaries(export_to_csv=True, **kwargs) -> None

Combine selected columns from each of the cells into single frames.

Other Parameters:

  • export_to_csv (bool) –

    export the combined summaries to csv (defaults to True).

  • **kwargs

    sent to the summary_collector.

Returns:

  • None

    None

create_journal

create_journal(description=None, from_db=True, auto_use_file_list=None, file_list_kwargs=None, abort_on_empty=True, **kwargs)

Create journal pages.

This method is a wrapper for the different Journal methods for making journal pages (Batch.experiment.journal.xxx). It is under development. If you want to use 'advanced' options (i.e. not loading from a db), please consider using the methods available in Journal for now.

Parameters:

  • description

    the information and meta-data needed to generate the journal pages:

    • 'empty': create an empty journal
    • dict: create journal pages from a dictionary
    • pd.DataFrame: create journal pages from a pandas.DataFrame
    • 'filename.json': load cellpy batch file
    • 'filename.xlsx': create journal pages from an Excel file.
  • from_db (bool, default: True ) –

    Deprecation Warning: this parameter will be removed as it is the default anyway. Generate the pages from a db (the default option). This will be over-ridden if description is given.

  • auto_use_file_list (bool, default: None ) –

    Experimental feature. If True, a file list will be generated and used instead of searching for files in the folders.

  • file_list_kwargs (dict, default: None ) –

    Experimental feature. Keyword arguments to be sent to the file list generator.

  • abort_on_empty (bool, default: True ) –

    If True, the function will raise a cellpy.exceptions.NullData if no journal pages are found.

  • **kwargs

    sent to sub-function(s) (e.g. from_db -> simple_db_reader -> find_files -> filefinder.search_for_files).

When using a custom JSON reader (e.g. batbase_json_reader or custom_json_reader), file search is performed after reading the JSON, using the filename/file_name_indicator column as run name. Use file_list and pre_path to control search, or skip_file_search=True to leave existing raw/cellpy paths unchanged.

The following keyword arguments are picked up by from_db:

Transferred Parameters

project: None name: None batch_col: None

The following keyword arguments are picked up by simple_db_reader:

Transferred Parameters

reader: a reader object (defaults to dbreader.Reader) cell_ids: keys (cell IDs) file_list: file list to send to filefinder (instead of searching in folders for files). pre_path: prepended path to send to filefinder. include_key: include the key col in the pages (the cell IDs). include_individual_arguments: include the argument column in the pages. additional_column_names: list of additional column names to include in the pages.

The following keyword arguments are picked up by filefinder.search_for_files:

Transferred Parameters

run_name(str): run-file identification. raw_extension(str): optional, extension of run-files (without the '.'). cellpy_file_extension(str): optional, extension for cellpy files (without the '.'). raw_file_dir(path): optional, directory where to look for run-files (default: read prm-file) project_dir(path): subdirectory in raw_file_dir to look for run-files cellpy_file_dir(path): optional, directory where to look for cellpy-files (default: read prm-file) prm_filename(path): optional parameter file can be given. file_name_format(str): format of raw-file names or a glob pattern (default: YYYYMMDD_[name]EEE_CC_TT_RR). reg_exp(str): use regular expression instead (defaults to None). sub_folders (bool): perform search also in sub-folders. file_list (list of str): perform the search within a given list of filenames instead of searching the folder(s). The list should not contain the full filepath (only the actual file names). If you want to provide the full path, you will have to modify the file_name_format or reg_exp accordingly. pre_path (path or str): path to prepend the list of files selected from the file_list.

The following keyword arguments are picked up by journal.to_file:

Transferred Parameters

duplicate_to_local_folder (bool): default True.

Returns:

  • None

drop

drop(cell_label=None)

Drop cells from the journal.

If cell_label is not given, cellpy will look into the journal for session info about bad cells, and if it finds it, it will remove those from the journal.

Note

Remember to save your journal again after modifying it.

Warning

This method has not been properly tested yet.

Parameters:

  • cell_label (str, default: None ) –

    the cell label of the cell you would like to remove.

Returns:

  • cellpy.utils.batch object (returns a copy if keep_old is True).

drop_cell

drop_cell(cell_label)

Drop a cell from the journal.

Parameters:

  • cell_label

    the cell label of the cell you would like to remove.

drop_cells

drop_cells(cell_labels)

Drop cells from the journal.

Parameters:

  • cell_labels

    the cell labels of the cells you would like to remove.

drop_cells_marked_bad

drop_cells_marked_bad()

Drop cells that has been marked as bad from the journal (experimental feature).

duplicate_cellpy_files

duplicate_cellpy_files(location: str = 'standard', selector: dict = None, **kwargs) -> None

Copy the cellpy files and make a journal with the new names available in the current folder.

Parameters:

  • location (str, default: 'standard' ) –

    where to copy the files. Either choose among the following options:

    • 'standard': data/interim folder
    • 'here': current directory
    • 'cellpydatadir': the stated cellpy data dir in your settings (prms)

    or if the location is not one of the above, use the actual value of the location argument.

  • selector (dict, default: None ) –

    if given, the cellpy files are reloaded after duplicating and modified based on the given selector(s).

  • **kwargs

    sent to Batch.experiment.update if selector is provided

Returns:

  • None

    The updated journal pages.

duplicate_journal

duplicate_journal(folder=None) -> None

Copy the journal to folder.

Parameters:

  • folder (str or Path, default: None ) –

    folder to copy to (defaults to the

export_journal

export_journal(filename=None) -> None

Export the journal to xlsx.

Parameters:

  • filename (str or Path, default: None ) –

    the name of the file to save the journal to. If not given, the journal will be saved to the default name.

link(max_cycle: Optional[int] = None, mark_bad=False, force_combine_summaries=False) -> None

Link journal content to the cellpy-files and load the step information.

Parameters:

  • max_cycle (int, default: None ) –

    set maximum cycle number to link to.

  • mark_bad (bool, default: False ) –

    mark cells as bad if they are not linked.

  • force_combine_summaries (bool, default: False ) –

    automatically run combine_summaries (set this to True if you are re-linking without max_cycle for a batch that previously were linked with max_cycle)

load

load() -> None

Load the selected datasets.

make_summaries

make_summaries() -> None

Combine selected columns from each of the cells into single frames and export.

mark_as_bad

mark_as_bad(cell_label)

Mark a cell as bad (experimental feature).

Parameters:

  • cell_label

    the cell label of the cell you would like to mark as bad.

paginate

paginate() -> None

Create the folders where cellpy will put its output.

plot

plot(backend=None, reload_data=False, **kwargs)

Plot the summaries (e.g. capacity vs. cycle number).

Delegates to cellpy.plotting.batch_summary_plot (#658). Supported backends: plotly (primary) and matplotlib. seaborn warns once and maps to matplotlib; bokeh raises.

Parameters:

  • backend (str, default: None ) –

    plotting backend (plotly or matplotlib)

  • reload_data (bool, default: False ) –

    reload the data before plotting

  • **kwargs

    sent to the plotter

Other Parameters:

  • color_map ((str, any)) –

    color map to use (defaults to px.colors.qualitative.Set1 for plotly)

  • ce_range (list) –

    optional range for the coulombic efficiency plot

  • min_cycle (int) –

    minimum cycle number to plot

  • max_cycle (int) –

    maximum cycle number to plot

  • title (str) –

    title of the figure (defaults to "Cycle Summary")

  • x_label (str) –

    title of the x-label (defaults to "Cycle Number")

  • direction (str) –

    plot charge or discharge (defaults to "charge")

  • rate (bool) –

    (defaults to False)

  • ir (bool) –

    (defaults to True)

  • group_legends (bool) –

    group the legends so that they can be turned visible/invisible as a group (defaults to True) (only for plotly)

  • base_template (str) –

    template to use for the plot (only for plotly)

  • filter_by_group (int or list of ints) –

    show only the selected group(s)

  • filter_by_name (str) –

    show only cells containing this string

  • inverted_mode (bool) –

    invert the colors vs symbols (only for plotly)

  • only_selected (bool) –

    only show the selected cells

  • capacity_specifics (str) –

    select how to present the capacity ("gravimetric", "areal" or "absolute") (defaults to "gravimetric")

Usage

b.plot(backend="plotly", reload_data=False, color_map="Set2", ce_range=[95, 105], min_cycle=1, max_cycle=100, title="Cycle Summary", x_label="Cycle Number", direction="charge", rate=False, ir=True, group_legends=True, base_template="plotly_dark", filter_by_group=1, filter_by_name="2019", capacity_specifics="areal")

to get the plotly canvas:

my_canvas = b.plotter.figure

plot_summaries

plot_summaries(output_filename=None, backend=None, reload_data=False, **kwargs) -> None

Plot the summaries.

recalc

recalc(**kwargs) -> None

Run make_step_table and make_summary on all cells.

Other Parameters:

  • save (bool) –

    Save updated cellpy-files if True (defaults to True).

  • step_opts (dict) –

    parameters to inject to make_steps (defaults to None).

  • summary_opts (dict) –

    parameters to inject to make_summary (defaults to None).

  • indexes (list) –

    Only recalculate for given indexes (i.e. list of cell-names) (defaults to None).

  • calc_steps (bool) –

    Run make_steps before making the summary (defaults to True).

  • testing (bool) –

    Only for testing purposes (defaults to False).

Examples:

>>> # re-make summaries for all cells assuming cell-type is "anode" (anode half-cells):
>>> b.recalc(save=False, calc_steps=False, summary_opts=dict(cell_type="anode"))

Returns:

  • None

    None

remove_mark_as_bad

remove_mark_as_bad(cell_label)

Remove the bad cell mark from a cell (experimental feature).

Parameters:

  • cell_label

    the cell label of the cell you would like to remove the bad mark from.

report

report(stylize=True, grouped=False, check=False)

Create a report on all the cells in the batch object.

Important

To perform a reporting, cellpy needs to access all the data (and it might take some time).

Parameters:

  • stylize (bool, default: True ) –

    apply some styling to the report (default True).

  • grouped (bool, default: False ) –

    add information based on the group cell belongs to (default False).

  • check (bool, default: False ) –

    check if the data seems to be without errors (0 = no errors, 1 = partial duplicates) (default False).

Returns:

  • pandas.DataFrame

save

save() -> None

Save journal and cellpy files.

The journal file will be saved in the project directory and in the batch-file-directory (config.paths.batchfiledir). The latter is useful for processing several batches using the iterate_batches functionality.

The name and location of the cellpy files is determined by the journal pages.

save_journal

save_journal(paginate=False, duplicate_to_project_folder=False) -> None

Save the journal (json-format).

The journal file will be saved to the current directory by default. Optionally, it can be copied to the project directory in config.paths.outdatadir and/or the batch-file-directory (config.paths.batchfiledir).

Parameters:

  • paginate (bool, default: False ) –

    paginate the journal pages, i.e. create a project folder structure inside your 'out' folder (default False).

  • duplicate_to_project_folder (bool, default: False ) –

    if True, copy the journal to config.paths.outdatadir/project/ (default False).

show_pages

show_pages(number_of_rows=5)

Show the journal pages.

update

update(pool=False, **kwargs) -> None

Updates the selected datasets.

Other Parameters:

  • all_in_memory (bool) –

    store the cellpydata in memory (default False)

  • cell_specs (dict of dicts) –

    individual arguments pr. cell. The cellspecs key-word argument dictionary will override the **kwargs and the parameters from the journal pages for the indicated cell.

  • logging_mode (str) –

    sets the logging mode for the loader(s).

  • accept_errors (bool) –

    if True, the loader will continue even if it encounters errors.

Additional keyword arguments are sent to the loader(s) if not picked up earlier. Remark that you can obtain the same pr. cell by providing a cellspecs dictionary. The kwargs have precedence over the parameters given in the journal pages, but will be overridden by parameters given by cellspecs.

Merging picks up the following keyword arguments:

Transferred Parameters

recalc (Bool): set to False if you don't want automatic recalculation of cycle numbers etc. when merging several data-sets.

Loading picks up the following keyword arguments:

Transferred Parameters

selector (dict): selector-based parameters sent to the cellpy-file loader (hdf5) if loading from raw is not necessary (or turned off).

from_journal

from_journal(journal_file, autolink=True, testing=False, **kwargs) -> Batch

Create a Batch from a journal file

from_journal2

from_journal2(journal_file, autolink=True, testing=False, **kwargs) -> Batch

Create a Batch from a journal file

This function will be renamed to from_journal in the future. It uses the "new" mode of the Batch class.

Parameters:

  • journal_file

    the path to the journal file

  • autolink

    if True, the batch will be linked automatically

  • testing

    should be set to True in test mode

  • **kwargs

    additional keyword arguments - db_reader: the reader to use (defaults to "default") - testing: if True, the batch will be tested - default_log_level: the default log level (defaults to "CRITICAL") - custom_log_dir: the directory to save the log file (defaults to None) - reset_big_log: if True, the big log will be reset (defaults to True)

Returns:

  • Batch

    Batch object (cellpy.utils.batch.Batch)

Examples:

>>> b = batch.from_journal2("cellpy_journal_one.json", testing=True, db_reader="batbase_json_reader")
>>> b.create_journal()
>>> b.update()
>>> b.plot()

init

init(*args, empty=False, **kwargs) -> Batch

Returns an initialized instance of the Batch class.

Parameters:

  • empty (bool, default: False ) –

    if True, the batch will not be linked to any database and an empty batch is returned

  • *args

    passed directly to Batch()

    • name: name of batch.
    • project: name of project.
    • batch_col: batch column identifier.

Other Parameters:

  • file_name

    json file if loading from pages (journal).

  • default_log_level

    "INFO" or "DEBUG". Defaults to "CRITICAL".

Other keyword arguments are sent to the Batch object.

Examples:

>>> empty_batch = Batch.init(db_reader=None)
>>> batch_from_file = Batch.init(file_name="cellpy_batch_my_experiment.json")
>>> normal_init_of_batch = Batch.init()

init2

init2(*args, empty=False, **kwargs) -> Batch

Returns an initialized instance of the Batch class.

Parameters:

  • empty (bool, default: False ) –

    if True, the batch will not be linked to any database and an empty batch is returned

  • *args

    passed directly to Batch()

    • name: name of batch.
    • project: name of project.
    • batch_col: batch column identifier.

Other Parameters:

  • file_name

    json file if loading from pages (journal).

  • default_log_level

    "INFO" or "DEBUG". Defaults to "CRITICAL".

Other keyword arguments are sent to the Batch object.

Examples:

>>> empty_batch = Batch.init(db_reader=None)
>>> batch_from_file = Batch.init(file_name="cellpy_batch_my_experiment.json")
>>> normal_init_of_batch = Batch.init()

iterate_batches

iterate_batches(folder, extension='.json', glob_pattern=None, **kwargs)

Iterate through all journals in given folder.

Parameters:

  • folder (str or Path) –

    folder containing the journal files.

  • extension (str, default: '.json' ) –

    extension for the journal files (used when creating a default glob-pattern).

  • glob_pattern (str, default: None ) –

    optional glob pattern.

  • **kwargs

    keyword arguments passed to batch.process_batch.

load

load(name, project, batch_col=None, allow_from_journal=True, allow_using_backup_journal=False, drop_bad_cells=True, force_reload=False, reader='default', reader_path=None, journal_file=None, **kwargs)

Load a batch from a journal file or create a new batch and load it if the journal file does not exist.

Parameters:

  • name (str) –

    name of batch

  • project (str) –

    name of project

  • batch_col (str, default: None ) –

    batch column identifier (only used for loading from db with simple_db_reader)

  • allow_from_journal (bool, default: True ) –

    if True, the journal file will be loaded if it exists

  • allow_using_backup_journal (bool, default: False ) –

    if True, the backup journal file will be used if the journal file does not exist

  • force_reload (bool, default: False ) –

    if True, the batch will be reloaded even if the journal file exists

  • drop_bad_cells (bool, default: True ) –

    if True, bad cells will be dropped (only apply if journal file is loaded)

  • auto_use_file_list (bool) –

    Experimental feature. If True, a file list will be generated and used instead of searching for files in the folders.

  • reader (str, default: 'default' ) –

    reader to use (defaults to "default" as given in the config-file or prm-class).

  • reader_path (str, default: None ) –

    path to the reader file (if not using "simple_excel_reader"). When journal_file is provided with a JSON reader, journal_file is used as the DB source and overrides reader_path.

  • journal_file (str or Path, default: None ) –

    explicit path to a journal/JSON file. When provided, load from this file instead of the derived path or DB-only path. If reader is "batbase_json_reader" or "custom_json_reader", this file is used as the DB source (no need to set reader_path).

  • **kwargs

    sent to Batch during initialization

Other Parameters:

  • db_reader (str) –

    data-base reader to use (defaults to "default" as given in the config-file or prm-class).

  • frame (DataFrame) –

    load from given dataframe.

  • default_log_level (str) –

    custom log-level (defaults to None (i.e. default log-level in cellpy)).

  • custom_log_dir (str or Path) –

    custom folder for putting the log-files.

  • force_raw_file (bool) –

    load from raw regardless (defaults to False).

  • force_cellpy (bool) –

    load cellpy-files regardless (defaults to False).

  • force_recalc (bool) –

    Always recalculate (defaults to False).

  • export_cycles (bool) –

    Extract and export individual cycles to csv (defaults to True).

  • export_raw (bool) –

    Extract and export raw-data to csv (defaults to True).

  • export_ica (bool) –

    Extract and export individual dQ/dV data to csv (defaults to True).

  • accept_errors (bool) –

    Continue automatically to next file if error is raised (defaults to False).

  • nom_cap (float) –

    give a nominal capacity if you want to use another value than the one given in the config-file or prm-class.

  • max_cycle (int or None) –

    maximum number of cycles to link up to (defaults to None).

  • force_combine_summaries (bool) –

    automatically run combine_summaries when linking.

  • column_map (dict) –

    for reader="custom_json_reader", map from JSON column names to cellpy journal keys (e.g. {"cell_id": "filename", "mass_mg": "mass"}).

Returns:

  • populated Batch object (cellpy.utils.batch.Batch)

Examples:

Load from derived journal (default): look for cellpy_batch_{name}.json in cwd or project::

b = load("my_batch", "my_project")

Load from an explicit cellpy journal file::

b = load("my_batch", "my_project", journal_file="path/to/cellpy_batch_my_batch.json")

Load from a custom JSON file using a column map::

b = load(
    "my_batch", "my_project",
    journal_file="path/to/cells.json",
    reader="custom_json_reader",
    column_map={"cell_id": "filename", "mass_mg": "mass"},
)

Load from a BatBase-format JSON file::

b = load("my_batch", "my_project", journal_file="path/to/batbase.json", reader="batbase_json_reader")

load_journal

load_journal(journal_file, **kwargs)

Load a journal file.

Parameters:

  • journal_file (str) –

    path to journal file.

  • **kwargs

    sent to Journal.from_file

Returns:

  • journal

load_pages

load_pages(file_name) -> pd.DataFrame

Retrieve pages from a Journal file.

This function is here to let you easily inspect a Journal file without starting up the full batch-functionality.

Examples:

>>> from cellpy.utils import batch
>>> journal_file_name = 'cellpy_journal_one.json'
>>> pages = batch.load_pages(journal_file_name)

Returns:

  • DataFrame

    pandas.DataFrame

naked

naked(name=None, project=None) -> Batch

Returns an empty instance of the Batch class.

Examples:

>>> empty_batch = naked()

process_batch

process_batch(*args, **kwargs) -> Batch

Execute a batch run, either from a given file_name or by giving the name and project as input.

Examples:

>>> process_batch(file_name | (name, project), **kwargs)

Parameters:

  • *args

    file_name or name and project (both string)

Other Parameters:

  • backend (str) –

    what backend to use when plotting ('bokeh' or 'matplotlib'). Defaults to 'matplotlib'.

  • dpi (int) –

    resolution used when saving matplotlib plot(s). Defaults to 300 dpi.

  • default_log_level (str) –

    What log-level to use for console output. Chose between 'CRITICAL', 'DEBUG', or 'INFO'. The default is 'CRITICAL' (i.e. usually no log output to console).

Returns:

  • Batch

    cellpy.batch.Batch object

Plotting

plotutils

Utilities for helping to plot cellpy-data.

SummaryPlotConfig dataclass

SummaryPlotConfig(x: Optional[str] = None, y: str = 'capacities_gravimetric_coulombic_efficiency', height: Optional[int] = None, width: int = 900, markers: bool = True, title: Optional[str] = None, x_range: Optional[list] = None, y_range: Optional[list] = None, ce_range: Optional[list] = None, norm_range: Optional[list] = None, cv_share_range: Optional[list] = None, split: bool = True, hover_columns: Optional[list] = None, auto_convert_legend_labels: bool = True, backend: Optional[str] = None, interactive: Optional[bool] = None, share_y: bool = False, rangeslider: bool = False, return_data: bool = False, verbose: bool = False, plotly_template: Optional[str] = None, seaborn_palette: str = 'deep', seaborn_style: str = 'dark', formation_cycles: int = 3, show_formation: bool = True, show_legend: bool = True, x_axis_domain_formation_fraction: float = 0.2, column_separator: float = 0.01, reset_losses: bool = True, link_capacity_scales: bool = False, fullcell_standard_normalization_type: str = 'max', fullcell_standard_normalization_factor: Optional[float] = None, fullcell_standard_normalization_scaler: float = 1.0, fullcell_standard_normalization_cycle_numbers: Optional[list[int]] = None, seaborn_line_hooks: Optional[list[tuple[str, list, dict]]] = None, filters: Optional[dict] = None, nominal_capacity: Optional[float] = None, rate_filter_columns: Optional[Union[str, tuple, list]] = None, additional_kwargs: dict = dict())

Configuration dataclass for summary_plot parameters.

Encapsulates all parameters for summary_plot to improve maintainability and enable easier refactoring.

from_kwargs classmethod

from_kwargs(**kwargs) -> SummaryPlotConfig

Create SummaryPlotConfig from keyword arguments.

Extracts known parameters and stores remaining kwargs in additional_kwargs.

to_kwargs

to_kwargs() -> dict

Convert config back to kwargs dict for passing to legacy function.

SummaryPlotInfo

SummaryPlotInfo(c: Any)

Initialize SummaryPlotInfo.

This class contains information about the summary plot. It is used to store the information about the columns and labels.

Parameters:

  • c (Any) –

    cellpy object

normalize_col staticmethod

normalize_col(x: ndarray, normalization_factor: Optional[float] = None, normalization_type: str = 'max', normalization_scaler: float = 1.0, normalization_indexes: list[int] = [1]) -> np.ndarray

Normalize a column.

Parameters:

  • x (ndarray) –

    column to normalize

  • normalization_factor (Optional[float], default: None ) –

    normalization factor

  • normalization_type (str, default: 'max' ) –

    normalization type

  • normalization_scaler (float, default: 1.0 ) –

    normalization scaler

  • normalization_indexes (list[int], default: [1] ) –

    indexes to use for normalization

Normalization types
  • divide: divide by normalization factor and then multiply by normalization scaler
  • shift-divide: shift by normalization factor and then divide by normalization factor and then multiply by normalization scaler
  • multiply: multiply by normalization factor and normalization scaler
  • area: divide by area (integrated using trapezoid rule) and then multiply by normalization scaler
  • max: divide by maximum value and then multiply by normalization scaler
  • on-max: divide by maximum value over normalization factor and then multiply by normalization scaler
  • on-cycles: divide by mean value of the cycles in normalization_indexes and then multiply by normalization scaler
  • false: no normalization is done

Returns:

  • ndarray

    normalized column

create_colormarkerlist

create_colormarkerlist(groups, sub_groups, symbol_label='all', color_style_label='seaborn-colorblind')

Fetch lists with color names and marker types of correct length.

Parameters:

  • groups

    list of group numbers (used to generate the list of colors)

  • sub_groups

    list of sub-group numbers (used to generate the list of markers).

  • symbol_label

    sub-set of markers to use

  • color_style_label

    cmap to use for colors

Returns:

  • colors (list), markers (list)

create_colormarkerlist_for_journal

create_colormarkerlist_for_journal(journal, symbol_label='all', color_style_label='seaborn-colorblind')

Fetch lists with color names and marker types of correct length for a journal.

Parameters:

  • journal

    cellpy journal

  • symbol_label

    sub-set of markers to use

  • color_style_label

    cmap to use for colors

Returns:

  • colors (list), markers (list)

cycle_info_plot

cycle_info_plot(cell, cycle=None, get_axes=False, backend: Optional[str] = None, interactive: Optional[bool] = None, t_unit='hours', v_unit='V', i_unit='mA', **kwargs)

Show raw data together with step and cycle information.

Draws through prepare → spec → render (#647).

Parameters:

  • cell

    cellpy object

  • cycle (int or list or tuple, default: None ) –

    cycle(s) to select (must be int for matplotlib)

  • get_axes (bool, default: False ) –

    return axes (for matplotlib) or figure (for plotly)

  • backend (str, default: None ) –

    "plotly" (default) or "matplotlib".

  • interactive (bool, default: None ) –

    Deprecated alias for backend selection (True→plotly, False→matplotlib; removal 2.1).

  • t_unit (str, default: 'hours' ) –

    unit for x-axis (default: "hours")

  • v_unit (str, default: 'V' ) –

    unit for y-axis (default: "V")

  • i_unit (str, default: 'mA' ) –

    unit for current (default: "mA")

  • **kwargs

    parameters specific to plotting backend.

Returns:

  • matplotlib.axes or None (or a figure when get_axes / backend semantics require it)

cycles_plot

cycles_plot(c, cycles=None, inter_cycle_shift=True, cycle_mode=None, formation_cycles=3, show_formation=True, mode='gravimetric', method='forth-and-forth', interpolated=True, number_of_points=200, colormap='Blues_r', formation_colormap='autumn', cut_colorbar=True, title=None, figsize=(6, 4), x_range=None, y_range=None, xlim=None, ylim=None, backend: Optional[str] = None, interactive: Optional[bool] = None, return_figure=None, width=800, height=600, marker_size=5, formation_line_color='rgba(152, 0, 0, .8)', force_colorbar=False, force_nonbar=False, plotly_template=None, seaborn_palette: str = 'deep', seaborn_style: str = 'dark', return_data=False, **kwargs)

Plot the voltage vs. capacity for different cycles of a cell.

This function is meant as an easy way of visualizing the voltage vs. capacity for different cycles of a cell. The cycles are plotted with different colors, and the formation cycles are highlighted with a different colormap. It is not intended to provide you with high quality plots, but rather to give you a quick overview of the data.

Draws through prepare → spec → render (#646).

Parameters:

  • c

    cellpy object containing the data to plot.

  • cycles (list, default: None ) –

    List of cycle numbers to plot. If None, all cycles are plotted.

  • inter_cycle_shift (bool, default: True ) –

    Whether to shift the cycles by one. Default is True.

  • cycle_mode (str, default: None ) –

    Mode for the test (anode or other). Default is None (i.e. use the cellpy cell object's cycle_mode).

  • formation_cycles (int, default: 3 ) –

    Number of formation cycles to highlight. Default is 3.

  • show_formation (bool, default: True ) –

    Whether to show formation cycles. Default is True.

  • mode (str, default: 'gravimetric' ) –

    Mode for capacity ('gravimetric', 'areal', etc.). Default is 'gravimetric'.

  • method (str, default: 'forth-and-forth' ) –

    Method for interpolation. Default is 'forth-and-forth'.

  • interpolated (bool, default: True ) –

    Whether to interpolate the data. Default is True.

  • number_of_points (int, default: 200 ) –

    Number of points for interpolation. Default is 200.

  • colormap (str, default: 'Blues_r' ) –

    Colormap for the cycles. Default is 'Blues_r'.

  • formation_colormap (str, default: 'autumn' ) –

    Colormap for the formation cycles. Default is 'autumn'.

  • cut_colorbar (bool, default: True ) –

    Whether to cut the colorbar. Default is True.

  • title (str, default: None ) –

    Title of the plot. If None, the cell name is used.

  • figsize (tuple, default: (6, 4) ) –

    Size of the figure for matplotlib. Default is (6, 4).

  • x_range (list, default: None ) –

    Limits for the x-axis.

  • y_range (list, default: None ) –

    Limits for the y-axis.

  • xlim (list, default: None ) –

    Deprecated alias for x_range (removal 2.1).

  • ylim (list, default: None ) –

    Deprecated alias for y_range (removal 2.1).

  • backend (str, default: None ) –

    "plotly" (default) or "matplotlib".

  • interactive (bool, default: None ) –

    Deprecated alias for backend selection (True→plotly, False→matplotlib; removal 2.1).

  • return_figure (bool, default: None ) –

    Whether to return the figure object. Default is True for matplotlib and False for plotly (fig.show()).

  • width (int, default: 800 ) –

    Width of the figure for Plotly. Default is 800.

  • height (int, default: 600 ) –

    Height of the figure for Plotly. Default is 600.

  • marker_size (int, default: 5 ) –

    Size of the markers for Plotly. Default is 5.

  • formation_line_color (str, default: 'rgba(152, 0, 0, .8)' ) –

    Color for the formation cycle lines in Plotly. Default is 'rgba(152, 0, 0, .8)'.

  • force_colorbar (bool, default: False ) –

    Whether to force the colorbar to be shown. Default is False.

  • force_nonbar (bool, default: False ) –

    Whether to force the colorbar to be hidden. Default is False.

  • plotly_template (str, default: None ) –

    Plotly template to use (uses default template if None).

  • seaborn_palette (str, default: 'deep' ) –

    name of the seaborn palette to use (only if seaborn is available).

  • seaborn_style (str, default: 'dark' ) –

    name of the seaborn style to use (only if seaborn is available).

  • return_data (bool, default: False ) –

    Whether to return the data used for the plot. Default is False.

  • **kwargs

    Additional keyword arguments for the plotting backend.

Additional keyword arguments for Plotly

plotly_max_individual_traces_for_lines (int, optional): Maximum number of individual traces (not including formation cycles) for lines in Plotly. Default is 8. plotly_xaxes_kwargs (dict, optional): propagated to plotly.update_xaxes. plotly_yaxes_kwargs (dict, optional): propagated to plotly.update_yaxes. plotly_layout_kwargs (dict, optional): propagated to plotly.update_layout.

Returns:

  • The figure is a matplotlib.figure.Figure or a plotly.graph_objects.Figure, depending on the backend used.

  • If return_data is True: tuple: (figure, data)

  • If return_figure is True: figure: The generated plot figure (same as the return value).

  • Else

    None: The plot is shown in the default browser.

dva_plot

dva_plot(cell, cycles=None, direction='both', options=None, *, backend: Optional[str] = None, interactive: Optional[bool] = None, title=None, colormap='viridis', width=800, height=600, figsize=(6, 4), x_range=None, y_range=None, plotly_template=None, return_data=False, **kwargs)

Plot differential voltage analysis (dV/dQ vs capacity).

Draws through prepare → spec → render (#648). Data come from cellpy.ica.dvdq; both half-cycles are overlaid when direction="both" (plotly hover shows charge/discharge).

Parameters:

  • cell

    cellpy object.

  • cycles

    Cycle number or list (None = all).

  • direction

    "charge", "discharge", or "both".

  • options

    Optional IcaOptions (defaults to DVA-oriented options inside dvdq).

  • backend (Optional[str], default: None ) –

    "plotly" (default) or "matplotlib".

  • interactive (Optional[bool], default: None ) –

    Deprecated alias for backend selection (removal 2.1).

  • title

    Figure title.

  • colormap

    Cycle colour map.

  • width, height

    Plotly figure size.

  • figsize

    Matplotlib figure size.

  • x_range, y_range

    Optional axis ranges.

  • plotly_template

    Optional plotly template name.

  • return_data

    If True, return (figure, frame).

  • **kwargs

    Extra knobs (strict, cycle_mode, number_of_points, and individual IcaOptions field overrides).

Returns:

  • Plotly or matplotlib figure (or (figure, frame) when return_data).

ica_plot

ica_plot(cell, cycles=None, direction='both', options=None, *, backend: Optional[str] = None, interactive: Optional[bool] = None, title=None, colormap='viridis', width=800, height=600, figsize=(6, 4), x_range=None, y_range=None, plotly_template=None, return_data=False, **kwargs)

Plot incremental capacity (dQ/dV vs voltage).

Draws through prepare → spec → render (#648). Data come from cellpy.ica.dqdv; both half-cycles are overlaid when direction="both" (plotly hover shows charge/discharge).

Parameters:

  • cell

    cellpy object.

  • cycles

    Cycle number or list (None = all).

  • direction

    "charge", "discharge", or "both".

  • options

    Optional IcaOptions.

  • backend (Optional[str], default: None ) –

    "plotly" (default) or "matplotlib".

  • interactive (Optional[bool], default: None ) –

    Deprecated alias for backend selection (removal 2.1).

  • title

    Figure title.

  • colormap

    Cycle colour map.

  • width, height

    Plotly figure size.

  • figsize

    Matplotlib figure size.

  • x_range, y_range

    Optional axis ranges.

  • plotly_template

    Optional plotly template name.

  • return_data

    If True, return (figure, frame).

  • **kwargs

    Extra knobs (strict, cycle_mode, number_of_points, and individual IcaOptions field overrides).

Returns:

  • Plotly or matplotlib figure (or (figure, frame) when return_data).

notebook_docstring_printer

notebook_docstring_printer(func, default_show_docstring=False)

Decorator that prints the function's docstring when called from a notebook environment.

This decorator checks if the function is being called from a Jupyter notebook or IPython environment and prints the function's docstring if it is.

Parameters:

  • func

    The function to decorate

Returns:

  • The decorated function

partition_summary_cv_steps

partition_summary_cv_steps(c, x: str, column_set: list, split: bool = False, var_name: str = 'variable', value_name: str = 'value')

Partition the summary data into CV and non-CV steps.

Parameters:

  • c

    cellpy object

  • x (str) –

    x-axis column name

  • column_set (list) –

    names of columns to include

  • split (bool, default: False ) –

    add additional column that can be used to split the data when plotting.

  • var_name (str, default: 'variable' ) –

    name of the variable column after melting

  • value_name (str, default: 'value' ) –

    name of the value column after melting

Returns:

  • pandas.DataFrame (melted with columns x, var_name, value_name, and optionally "row" if split is True)

raw_plot

raw_plot(cell, y=None, y_label=None, x=None, x_label=None, title=None, backend: Optional[str] = None, interactive: Optional[bool] = None, plot_type='voltage-current', double_y=True, **kwargs)

Plot raw data.

Draws through prepare → spec → render (#647).

Parameters:

  • cell

    cellpy object

  • y (str or list, default: None ) –

    y-axis column

  • y_label (str or list, default: None ) –

    label for y-axis

  • x (str, default: None ) –

    x-axis column

  • x_label (str, default: None ) –

    label for x-axis

  • title (str, default: None ) –

    title of the plot

  • backend (str, default: None ) –

    "plotly" (default) or "matplotlib".

  • interactive (bool, default: None ) –

    Deprecated alias for backend selection (True→plotly, False→matplotlib; removal 2.1).

  • plot_type (str, default: 'voltage-current' ) –

    type of plot (defaults to "voltage-current") (overrides given y if y is not None), currently only "voltage-current", "raw", "capacity", "capacity-current", and "full" is supported.

  • double_y (bool, default: True ) –

    use double y-axis (only for matplotlib and when plot_type with 2 rows is used)

  • **kwargs

    additional parameters for the plotting backend

Returns:

  • matplotlib figure or plotly figure

save_image_files

save_image_files(figure: Any, name: str = 'my_figure', scale: float = 3.0, dpi: int = 300, backend: str = 'plotly', formats: Optional[list] = None)

Save to image files (png, svg, json/pickle).

Notes

This method requires kaleido for the plotly backend.

Notes

Exporting to json is only applicable for the plotly backend.

Parameters:

  • figure (fig - object) –

    The figure to save.

  • name (Path or str, default: 'my_figure' ) –

    The path of the file (without extension).

  • scale (float, default: 3.0 ) –

    The scale of the image.

  • dpi (int, default: 300 ) –

    The dpi of the image.

  • backend (str, default: 'plotly' ) –

    The backend to use (plotly or seaborn/matplotlib).

  • formats (list, default: None ) –

    The formats to save (default: ["png", "svg", "json", "pickle"]).

set_plotly_template

set_plotly_template(template_name=None, **kwargs)

Set the default plotly template.

summary_plot

summary_plot(c, x: Optional[str] = None, y: str = 'capacities_gravimetric_coulombic_efficiency', height: Optional[int] = None, width: int = 900, markers: bool = True, title: Optional[str] = None, x_range: Optional[list] = None, y_range: Optional[list] = None, ce_range: Optional[list] = None, norm_range: Optional[list] = None, cv_share_range: Optional[list] = None, split: bool = True, hover_columns: Optional[list] = None, auto_convert_legend_labels: bool = True, backend: Optional[str] = None, interactive: Optional[bool] = None, share_y: bool = False, rangeslider: bool = False, return_data: bool = False, verbose: bool = False, plotly_template: Optional[str] = None, seaborn_palette: str = 'deep', seaborn_style: str = 'dark', formation_cycles: int = 3, show_formation: bool = True, show_legend: bool = True, x_axis_domain_formation_fraction: float = 0.2, column_separator: float = 0.01, reset_losses: bool = True, link_capacity_scales: bool = False, fullcell_standard_normalization_type: str = 'max', fullcell_standard_normalization_factor: Optional[float] = None, fullcell_standard_normalization_scaler: float = 1.0, fullcell_standard_normalization_cycle_numbers: Optional[list[int]] = None, seaborn_line_hooks: Optional[list[tuple[str, list, dict]]] = None, filters: Optional[dict] = None, nominal_capacity: Optional[float] = None, rate_filter_columns: Optional[Union[str, tuple, list]] = None, **kwargs) -> Any

Create a summary plot.

Parameters:

  • c

    cellpy object

  • x (Optional[str], default: None ) –

    x-axis column (default: 'cycle_index')

  • y (str, default: 'capacities_gravimetric_coulombic_efficiency' ) –

    y-axis column or column set. Currently, the following predefined sets exists: "voltages", "capacities_gravimetric", "capacities_areal", "capacities_absolute", "capacities_gravimetric_split_constant_voltage", "capacities_areal_split_constant_voltage", "capacities_gravimetric_coulombic_efficiency", "capacities_areal_coulombic_efficiency", "capacities_absolute_coulombic_efficiency", "capacities_gravimetric_with_rate", "capacities_areal_with_rate", "capacities_absolute_with_rate", "fullcell_standard_gravimetric", "fullcell_standard_areal", "fullcell_standard_absolute",

  • height (Optional[int], default: None ) –

    height of the plot (for plotly)

  • width (int, default: 900 ) –

    width of the plot (for plotly)

  • markers (bool, default: True ) –

    use markers

  • title (Optional[str], default: None ) –

    title of the plot

  • x_range (Optional[list], default: None ) –

    limits for x-axis

  • y_range (Optional[list], default: None ) –

    limits for y-axis

  • ce_range (Optional[list], default: None ) –

    limits for coulombic efficiency (if present)

  • norm_range (Optional[list], default: None ) –

    limits for normalized capacity (if present)

  • cv_share_range (Optional[list], default: None ) –

    limits for cv share (if present)

  • split (bool, default: True ) –

    split the plot

  • hover_columns (Optional[list], default: None ) –

    columns to show in the hover tooltip (only for plotly)

  • auto_convert_legend_labels (bool, default: True ) –

    convert the legend labels to a nicer format.

  • backend (Optional[str], default: None ) –

    plotting backend ("plotly" or "matplotlib"; default "plotly")

  • interactive (Optional[bool], default: None ) –

    deprecated alias for backend selection (True"plotly", False"matplotlib"); removal 2.1

  • rangeslider (bool, default: False ) –

    add a range slider to the x-axis (only for plotly)

  • share_y (bool, default: False ) –

    share y-axis (only for plotly)

  • return_data (bool, default: False ) –

    return the data used for plotting

  • verbose (bool, default: False ) –

    print out some extra information to make it easier to find out what to plot next time

  • plotly_template (Optional[str], default: None ) –

    name of the plotly template to use

  • seaborn_palette (str, default: 'deep' ) –

    name of the seaborn palette to use (matplotlib backend)

  • seaborn_style (str, default: 'dark' ) –

    name of the seaborn style to use (matplotlib backend)

  • formation_cycles (int, default: 3 ) –

    number of formation cycles to show

  • show_formation (bool, default: True ) –

    show formation cycles

  • show_legend (bool, default: True ) –

    show the legend

  • x_axis_domain_formation_fraction (float, default: 0.2 ) –

    fraction of the x-axis domain for the formation cycles (default: 0.2)

  • column_separator (float, default: 0.01 ) –

    separation between columns when splitting the plot (only for plotly)

  • reset_losses (bool, default: True ) –

    reset the losses to the first cycle (only for fullcell_standard plots)

  • link_capacity_scales (bool, default: False ) –

    link the capacity scales (only for fullcell_standard plots)

  • fullcell_standard_normalization_type (str, default: 'max' ) –

    normalization type for the fullcell standard plots (capacity retention) (divide, multiply, area, max, on-max, False)

  • fullcell_standard_normalization_factor (Optional[float], default: None ) –

    normalization factor for the fullcell standard plots

  • fullcell_standard_normalization_scaler (float, default: 1.0 ) –

    scaler for the fullcell standard plots

  • fullcell_standard_normalization_cycle_numbers (Optional[list[int]], default: None ) –

    cycle numbers to use for normalization (only for fullcell_standard plots)

  • seaborn_line_hooks (Optional[list[tuple[str, list, dict]]], default: None ) –

    list of functions to hook into the seaborn lines (e.g. to update the marker_size)

  • filters (Optional[dict], default: None ) –

    optional dict forwarded to :func:cellpy.filters.filter_summary to drop rows from the summary before plotting (e.g. filters={"rate": (0, 0.5)} drops slow-rate characterisation cycles). See :func:cellpy.filters.filter_summary for range semantics.

  • nominal_capacity (Optional[float], default: None ) –

    optional plain float in c.cellpy_units.nominal_capacity units. When given, the charge_c_rate / discharge_c_rate columns are rescaled to use this nominal capacity instead of c.data.nom_cap (multiplies rates by c.data.nom_cap / nominal_capacity).

  • rate_filter_columns (Optional[Union[str, tuple, list]], default: None ) –

    optional override for which rate column(s) the rate filter targets. Defaults to both (charge_c_rate, discharge_c_rate); pass a single string (e.g. "discharge_c_rate") to filter only one side.

  • **kwargs

    includes additional parameters for the plotting backend (not properly documented yet).

Returns:

  • Any

    if return_data is True, returns a tuple with the figure and the data used for plotting.

  • Any

    Otherwise, it returns only the figure. With backend="plotly" the figure is a

  • Any

    plotly figure; with backend="matplotlib" it is a matplotlib figure.

Examples:

Default plot (capacity and Coulombic efficiency vs cycle number)::

>>> from cellpy.utils.plotutils import summary_plot
>>> fig = summary_plot(c)
>>> fig.show()

Plot gravimetric capacity alone, with formation cycles disabled::

>>> fig = summary_plot(c, y="capacities_gravimetric", show_formation=False)

Use the matplotlib backend (seaborn styling), e.g. for an SVG export from a script::

>>> fig = summary_plot(c, y="capacities_gravimetric", backend="matplotlib")
>>> fig.savefig("summary.svg")

Get the prepared DataFrame back together with the figure (useful for custom annotations or follow-up analysis)::

>>> fig, data = summary_plot(c, y="capacities_gravimetric", return_data=True)
>>> data.head()

New *_with_rate y-set adds a C-rate subplot on row 0::

>>> fig = summary_plot(c, y="capacities_gravimetric_with_rate")

Drop slow-rate characterisation cycles (e.g. keep only rows where both charge_c_rate and discharge_c_rate are above 0.1)::

>>> fig = summary_plot(
...     c,
...     y="capacities_gravimetric",
...     filters={"rate": (0.1, 10.0)},
... )

Same idea using the symmetric {value, delta} form to keep rows close to a target C/2 rate::

>>> fig = summary_plot(
...     c,
...     y="capacities_gravimetric_with_rate",
...     filters={"rate": {"value": 0.5, "delta": 0.05}},
... )

Filter on the discharge rate only (charge rate is ignored)::

>>> fig = summary_plot(
...     c,
...     y="capacities_gravimetric",
...     filters={"rate": (0.1, 1.0)},
...     rate_filter_columns="discharge_c_rate",
... )

Override the nominal capacity used for the C-rate axis without re-running make_summary. The rate columns are rescaled by c.data.nom_cap / nominal_capacity; here we both rescale and filter in the new units::

>>> fig = summary_plot(
...     c,
...     y="capacities_gravimetric_with_rate",
...     nominal_capacity=200.0,
...     filters={"rate": (0.1, 5.0)},
... )

The same filter is available without plotting via :meth:CellpyCell.filtered_summary (returns a DataFrame copy)::

>>> trimmed = c.filtered_summary(rate=(0.1, 10.0))

Or as a free function on any summary-shaped DataFrame::

>>> from cellpy.filters import filter_summary
>>> trimmed = filter_summary(c.data.summary.reset_index(),
...                          rate=(0.1, 10.0))

summary_plot_legacy

summary_plot_legacy(c, x: Optional[str] = None, y: str = 'capacities_gravimetric_coulombic_efficiency', height: Optional[int] = None, width: int = 900, markers: bool = True, title: Optional[str] = None, x_range: Optional[list] = None, y_range: Optional[list] = None, ce_range: Optional[list] = None, norm_range: Optional[list] = None, cv_share_range: Optional[list] = None, split: bool = True, auto_convert_legend_labels: bool = True, interactive: bool = True, share_y: bool = False, rangeslider: bool = False, return_data: bool = False, verbose: bool = False, plotly_template: Optional[str] = None, seaborn_palette: str = 'deep', seaborn_style: str = 'dark', formation_cycles: int = 3, show_formation: bool = True, show_legend: bool = True, x_axis_domain_formation_fraction: float = 0.2, column_separator: float = 0.01, reset_losses: bool = True, link_capacity_scales: bool = False, fullcell_standard_normalization_type: str = 'on-max', fullcell_standard_normalization_factor: Optional[float] = None, fullcell_standard_normalization_scaler: float = 1.0, seaborn_line_hooks: Optional[list[tuple[str, list, dict]]] = None, **kwargs) -> Any

Deprecated. Use summary_plot.

The 1 400-line implementation that used to live here was broken, not merely redundant: its first statement unpacked the return value of SummaryPlotInfo._create_col_info, which stores its results as attributes and returns None — so every call raised TypeError regardless of the cell or the runtime (#567). Nothing in the repo called it, and nothing outside it could have called it successfully either.

Delegates to summary_plot, which draws the same figures through the builder pipeline. Removal in 2.1.

Analysis

Incremental capacity analysis lives at cellpy.ica since 2.0; cellpy.utils.ica re-exports it.

ocv_rlx

MultiCycleOcvFit

MultiCycleOcvFit(cellpydata, cycles, circuits=3)

Object for performing fitting of multiple cycles.

Remarks

This is only tested for OCV relaxation data for half-cells in anode mode where the OCV relaxation is performed according to the standard protocol implemented at IFE in the battery development group.

If you want to use this for other data or protocols, please report an issue on the GitHub page.

Object for performing fitting of multiple cycles.

Parameters:

  • cellpydata

    CellpyCell-object

  • cycles (list) –

    cycles to fit.

  • circuits (int, default: 3 ) –

    number of circuits to use in fitting.

get_best_fit_data

get_best_fit_data()

Returns the best fit data.

get_best_fit_parameters

get_best_fit_parameters() -> list

Returns parameters for the best fit.

get_best_fit_parameters_grouped

get_best_fit_parameters_grouped() -> dict

Returns a dictionary of the best fit.

get_best_fit_parameters_translated

get_best_fit_parameters_translated() -> list

Returns the parameters in 'real units' for the best fit.

get_best_fit_parameters_translated_grouped

get_best_fit_parameters_translated_grouped() -> dict

Returns the parameters as a dictionary of the 'real units' for the best fit.

get_fit_cycles

get_fit_cycles()

Returns a list of the fit cycles

plot_summary

plot_summary(cycles=None)

Convenience function for plotting the summary of the fit

plot_summary_translated

plot_summary_translated()

Convenience function for plotting the summary of the fit (translated)

run_fitting

run_fitting(direction='up', weighted=True)

Parameters:

  • direction (up | down, default: 'up' ) –

    what type of ocv relaxation to fit

  • weighted (bool, default: True ) –

    use weighted fitting.

Returns:

  • None

set_cycles

set_cycles(cycles)

Sets the cycles.

set_data

set_data(cellpydata)

Sets the CellpyCell.

summary_translated

summary_translated() -> pd.DataFrame

Convenience function for creating a dataframe of the summary of the fit (translated)

OcvFit

OcvFit(circuits=None, direction=None, zero_current=0.1, zero_voltage=0.05)

Bases: object

Class for fitting open circuit relaxation data.

The model is a sum of exponentials and a constant offset (Ohmic resistance). The number of exponentials is set by the number of circuits. The model is: v(t) = v0 + R0 + sum(wi * exp(-t/tau_i)) where v0 is the OCV, wi is the weight of the exponential tau_i is the time constant of the exponential and R0 is the Ohmic resistance.

r is found by calculating v0 / i_start --> err(r)= err(v0) + err(i_start).
c is found from using tau / r --> err(c) = err(r) + err(tau).

The fit is performed by using lmfit.

Attributes:

  • data (cellpydata - object) –

    The data to be fitted.

  • time (list) –

    Time measured during relaxation (extracted from data if provided).

  • voltage (list) –

    Time measured during relaxation (extracted from data if provided).

  • steps (str) –

    Step information (if data is provided).

  • circuits (int) –

    The number of circuits to be fitted.

  • weights (list) –

    The weights of the different circuits.

  • zero_current (float) –

    Last current observed before turning the current off.

  • zero_voltage (float) –

    Last voltage observed before turning the current off.

  • model (lmfit - object) –

    The model used for fitting.

  • params (lmfit - object) –

    The parameters used for fitting.

  • result (lmfit - object) –

    The result of the fitting.

  • best_fit_data (list) –

    The best fit data [x, y_measured, y_fitted].

  • best_fit_parameters (dict) –

    The best fit parameters.

Remarks

This class does not take advantage of the cellpydata-object. It is primarily used for fitting data that does not originate from cellpy, but it can also be used for fitting cellpy-data.

If you have cellpy-data, you should use the MultiCycleOcvFit class instead.

Initializes the class.

Parameters:

  • circuits (int, default: None ) –

    The number of circuits to be fitted (including R0).

  • direction (str, default: None ) –

    The direction of the relaxation (up or down).

  • zero_current (float, default: 0.1 ) –

    Last current observed before turning the current off.

  • zero_voltage (float, default: 0.05 ) –

    Last voltage observed before turning the current off.

create_model

create_model()

Create the model to be used in the fit.

run_fit

run_fit()

Performing fit of the OCV steps in the cycles set by set_cycles() from the data set by set_data()

r is found by calculating v0 / i_start → err®= err(v0) + err(i_start).

c is found from using tau / r → err© = err® + err(tau).

The resulting best fit parameters are stored in self.result for the given cycles.

Returns:

  • None

set_cellpydata

set_cellpydata(cellpydata, cycle)

Convenience method for setting the data from a cellpydata-object. Args: cellpydata (CellpyCell): data object from cellreader cycle (int): cycle number to get from CellpyCell object

Remarks

You need to set the direction before calling this method if you don't want to use the default direction (up).

Returns:

  • None

set_circuits

set_circuits(circuits)

Set the number of circuits to be used in the fit.

Parameters:

  • circuits (int) –

    number of circuits to be used in the fit. Can be 1 to 4.

set_data

set_data(t, v)

Set the data to be fitted.

fit

fit(c, direction='up', circuits=3, cycles=None, return_fit_object=False)

Fits the OCV steps in CellpyCell object c.

Parameters:

  • c

    CellpyCell object

  • direction

    direction of the OCV steps ('up' or 'down')

  • circuits

    number of circuits to use (first is IR, rest is RC) in the fitting (min=1, max=4)

  • cycles

    list of cycles to fit (if None, all cycles will be used)

  • return_fit_object

    if True, returns the MultiCycleOcvFit instance.

Returns:

  • pd.DataFrame with the fitted parameters for each cycle if return_fit_object=False,

  • else MultiCycleOcvFit instance

select_ocv_points

select_ocv_points(cellpydata, cycles=None, cell_label=None, include_times=True, selection_method='martin', number_of_points=5, interval=10, relative_voltage=False, report_times=False, direction='both')

Select points from the ocvrlx steps.

Parameters:

  • cellpydata

    CellpyData-object

  • cycles

    list of cycle numbers to process (optional)

  • cell_label (str, default: None ) –

    optional, will be added to the frame if given

  • include_times (bool, default: True ) –

    include additional information including times.

  • selection_method (martin | fixed_times, default: 'martin' ) –

    criteria for selecting points ('martin': select first and last, and then last/2, last/2/2 etc. until you have reached the wanted number of points; 'fixed_times': select first, and then same interval between each subsequent point).

  • number_of_points

    number of points you want.

  • interval

    interval between each point (in use only for methods where interval makes sense). If it is a list, then number_of_points will be calculated as len(interval) + 1 (and override the set number_of_points).

  • relative_voltage

    set to True if you would like the voltage to be relative to the voltage before starting the ocv rlx step. Defaults to False. Remark that for the initial rxl step (when you just have put your cell on the tester) does not have any prior voltage. The relative voltage will then be versus the first measurement point.

  • report_times

    also report the ocv rlx total time if True (defaults to False)

  • direction ((up, down or both), default: 'both' ) –

    select "up" if you would like to process only the ocv rlx steps where the voltage is relaxing upwards and vice versa. Defaults to "both".

Returns:

  • pandas.DataFrame (and another pandas.DataFrame if return_times is True)

helpers

add_areal_capacity

add_areal_capacity(cell, cell_id, journal)

Adds areal capacity to the summary.

add_c_rate

add_c_rate(cell, nom_cap=None, column_name=None)

Adds C-rates to the step table data frame.

This functionality is now also implemented as default when creating the step_table (make_step_table). However, it is kept here if you would like to recalculate the C-rates, for example if you want to use another nominal capacity or if you would like to have more than one column with C-rates.

Parameters:

  • cell (CellpyCell) –

    cell object

  • nom_cap (float, default: None ) –

    nominal capacity to use for estimating C-rates. Defaults to the nominal capacity defined in the cell object (this is typically set during creation of the CellpyData object based on the value given in the parameter file).

  • column_name (str, default: None ) –

    name of the new column. Uses the name defined in cellpy.parameters.internal_settings as default.

Returns:

  • data object.

add_cv_step_columns

add_cv_step_columns(columns: list) -> list

Add columns for CV steps.

add_normalized_capacity

add_normalized_capacity(cell, norm_cycles=None, individual_normalization=False, scale=1.0)

Add normalized capacity to the summary.

Parameters:

  • cell (CellpyCell) –

    cell to add normalized capacity to.

  • norm_cycles (list of ints, default: None ) –

    the cycles that will be used to find the normalization factor from (averaging their capacity)

  • individual_normalization (bool, default: False ) –

    find normalization factor for both the charge and the discharge if true, else use normalization factor from charge on both charge and discharge.

  • scale (float, default: 1.0 ) –

    scale of normalization (default is 1.0).

Returns:

  • cell (CellpyData) with added normalization capacity columns in

  • the summary.

add_normalized_cycle_index

add_normalized_cycle_index(summary, nom_cap, column_name=None)

Adds normalized cycles to the summary data frame.

This functionality is now also implemented as default when creating the summary (make_summary). However, it is kept here if you would like to redo the normalization, for example if you want to use another nominal capacity or if you would like to have more than one normalized cycle index.

Parameters:

  • summary (DataFrame) –

    data summary

  • nom_cap (float) –

    nominal capacity to use when normalizing.

  • column_name (str, default: None ) –

    name of the new column. Uses the name defined in cellpy.parameters.internal_settings as default.

Returns:

  • data object now with normalized cycle index in its summary.

collect_frames

collect_frames(frames, group_it: bool, hdr_norm_cycle: str, keys: list, normalize_cycles: bool, hooks: list = None)

Helper function for concat_summaries.

concat_summaries

concat_summaries(b: Batch, max_cycle=None, rate=None, on='charge', columns=None, column_names=None, normalize_capacity_on=None, scale_by=None, nom_cap=None, normalize_cycles=False, group_it=False, custom_group_labels=None, rate_std=None, rate_column=None, inverse=False, inverted=False, key_index_bounds=None, pages=None, recalc_summary_kwargs=None, recalc_step_table_kwargs=None, only_selected=False, experimental_feature_cell_selector=None, partition_by_cv=False, replace_inf_with_nan=True, individual_summary_hooks=None, concatenated_summary_hooks=None, drop_columns=None, average_method='mean', replace_extremes_with_nan=True, low_limit=-1000000.0, high_limit=1000000.0, *args, **kwargs) -> pd.DataFrame

Merge all summaries in a batch into a gigantic summary data frame.

Parameters:

  • b (cellpy.batch object) –

    the batch with the cells.

  • max_cycle (int, default: None ) –

    drop all cycles above this value.

  • rate (float, default: None ) –

    filter on rate (C-rate)

  • on (str or list of str, default: 'charge' ) –

    only select cycles if based on the rate of this step-type (e.g. on="charge").

  • columns (list, default: None ) –

    selected column(s) (using cellpy attribute name) [defaults to "charge_capacity_gravimetric"]

  • column_names (list, default: None ) –

    selected column(s) (using exact column name)

  • normalize_capacity_on (list, default: None ) –

    list of cycle numbers that will be used for setting the basis of the normalization (typically the first few cycles after formation)

  • scale_by (float or str, default: None ) –

    scale the normalized data with nominal capacity if "nom_cap", or given value (defaults to one).

  • nom_cap (float, default: None ) –

    nominal capacity of the cell

  • normalize_cycles (bool, default: False ) –

    perform a normalization of the cycle numbers (also called equivalent cycle index)

  • group_it (bool, default: False ) –

    if True, average pr group.

  • partition_by_cv (bool, default: False ) –

    if True, partition the data by cv_step.

  • custom_group_labels (dict, default: None ) –

    dictionary of custom labels (key must be the group number/name).

  • rate_std (float, default: None ) –

    allow for this inaccuracy when selecting cycles based on rate

  • rate_column (str, default: None ) –

    name of the column containing the C-rates.

  • inverse (bool, default: False ) –

    select steps that do not have the given C-rate.

  • inverted (bool, default: False ) –

    select cycles that do not have the steps filtered by given C-rate.

  • key_index_bounds (list, default: None ) –

    used when creating a common label for the cells by splitting the label on '_' and combining again using the key_index_bounds as start and end index.

  • pages (DataFrame, default: None ) –

    alternative pages (journal) of the batch object (if not given, it will use the pages from the batch object).

  • recalc_summary_kwargs (dict, default: None ) –

    keyword arguments to be used when recalculating the summary. If not given, it will not recalculate the summary.

  • recalc_step_table_kwargs (dict, default: None ) –

    keyword arguments to be used when recalculating the step table. If not given, it will not recalculate the step table.

  • only_selected (bool, default: False ) –

    only use the selected cells.

  • experimental_feature_cell_selector (list, default: None ) –

    list of cell names to select.

  • partition_by_cv (bool, default: False ) –

    if True, partition the data by cv_step.

  • replace_inf_with_nan (bool, default: True ) –

    if True, replace inf with nan in the summary data.

  • individual_summary_hooks (list, default: None ) –

    list of functions to be applied to the individual summary data.

  • concatenated_summary_hooks (list, default: None ) –

    list of functions to be applied to the concatenated summary data (passed to the collect_frames function).

  • drop_columns (list, default: None ) –

    list of columns to drop before concatenation.

  • average_method (str, default: 'mean' ) –

    method to be used when averaging the summary data. Remark that for backward compatibility, the column name will be "mean" regardless of the actual method used.

  • replace_extremes_with_nan (bool, default: True ) –

    if True, replace values outside the range [low_limit, high_limit] with nan in the summary data.

  • low_limit (float, default: -1000000.0 ) –

    lower limit for replacing extremes with nan if replace_extremes_with_nan is True.

  • high_limit (float, default: 1000000.0 ) –

    upper limit for replacing extremes with nan if replace_extremes_with_nan is True.

  • remove_last (bool) –

    if True, remove the last cycle from the summary data.

  • *args,**kwargs

    additional arguments to be passed to the hooks.

Returns:

  • DataFrame

    pandas.DataFrame

concatenate_summaries

concatenate_summaries(b: Batch, max_cycle=None, rate=None, on='charge', columns=None, column_names=None, normalize_capacity_on=None, scale_by=None, nom_cap=None, normalize_cycles=False, group_it=False, custom_group_labels=None, rate_std=None, rate_column=None, inverse=False, inverted=False, key_index_bounds=None) -> pd.DataFrame

Merge all summaries in a batch into a gigantic summary data frame.

Parameters:

  • b (cellpy.batch object) –

    the batch with the cells.

  • max_cycle (int, default: None ) –

    drop all cycles above this value.

  • rate (float, default: None ) –

    filter on rate (C-rate)

  • on (str or list of str, default: 'charge' ) –

    only select cycles if based on the rate of this step-type (e.g. on="charge").

  • columns (list, default: None ) –

    selected column(s) (using cellpy attribute name) [defaults to "charge_capacity_gravimetric"]

  • column_names (list, default: None ) –

    selected column(s) (using exact column name)

  • normalize_capacity_on (list, default: None ) –

    list of cycle numbers that will be used for setting the basis of the normalization (typically the first few cycles after formation)

  • scale_by (float or str, default: None ) –

    scale the normalized data with nominal capacity if "nom_cap", or given value (defaults to one).

  • nom_cap (float, default: None ) –

    nominal capacity of the cell

  • normalize_cycles (bool, default: False ) –

    perform a normalization of the cycle numbers (also called equivalent cycle index)

  • group_it (bool, default: False ) –

    if True, average pr group.

  • custom_group_labels (dict, default: None ) –

    dictionary of custom labels (key must be the group number/name).

  • rate_std (float, default: None ) –

    allow for this inaccuracy when selecting cycles based on rate

  • rate_column (str, default: None ) –

    name of the column containing the C-rates.

  • inverse (bool, default: False ) –

    select steps that do not have the given C-rate.

  • inverted (bool, default: False ) –

    select cycles that do not have the steps filtered by given C-rate.

  • key_index_bounds (list, default: None ) –

    used when creating a common label for the cells by splitting and combining from key_index_bound[0] to key_index_bound[1].

Returns:

  • DataFrame

    pandas.DataFrame

create_group_names

create_group_names(custom_group_labels, gno, key_index_bounds, keys_sub, pages)

Helper function for concat_summaries.

The prioritisation of methods for creating the group name is as follows: 1. custom_group_labels (if given) 2. group_label in pages (if given) 3. key_index_bounds and keys_sub (if no other option is available)

Parameters:

  • custom_group_labels (dict) –

    dictionary of custom labels (key must be the group number).

  • gno (int) –

    group number.

  • key_index_bounds (list) –

    used when creating a common label for the cells by splitting the label on '_' and combining again using the key_index_bounds as start and end index.

  • keys_sub (list) –

    list of keys.

  • pages (DataFrame) –

    pages (journal) of the batch object. If the column "group_label" is present, it will be used to create the group name.

create_rate_column

create_rate_column(df, nom_cap, spec_conv_factor, column='current_avr')

Adds a rate column to the dataframe (steps).

filter_cells

filter_cells()

Filter cells based on some criteria.

This is a helper function that can be used to filter cells based on some criteria. It is not very flexible, but it is easy to use.

Returns:

  • a list of cell names that passed the criteria.

fix_group_names

fix_group_names(keys)

Helper function for concat_summaries.

load_and_save_resfile

load_and_save_resfile(filename, outfile=None, outdir=None, mass=1.0)

Load a raw data file and save it as cellpy-file.

Parameters:

  • mass (float, default: 1.0 ) –

    active material mass [mg].

  • outdir (path, default: None ) –

    optional, path to directory for saving the hdf5-file.

  • outfile (str, default: None ) –

    optional, name of hdf5-file.

  • filename (str) –

    name of the resfile.

Returns:

  • out_file_name ( str ) –

    name of saved file.

make_new_cell

make_new_cell()

create an empty CellpyCell object.

remove_first_cycles_from_summary

remove_first_cycles_from_summary(s, first=None)

Remove last rows after given cycle number

remove_last_cycles_from_summary

remove_last_cycles_from_summary(s, last=None)

Remove last rows after given cycle number

remove_outliers_from_summary_on_index

remove_outliers_from_summary_on_index(s, indexes=None, remove_last=False)

Remove rows with supplied indexes (where the indexes typically are cycle-indexes).

Parameters:

  • s (DataFrame) –

    cellpy summary to process

  • indexes (list, default: None ) –

    list of indexes

  • remove_last (bool, default: False ) –

    remove the last point

Returns:

  • pandas.DataFrame

remove_outliers_from_summary_on_nn_distance

remove_outliers_from_summary_on_nn_distance(s, distance=0.7, filter_cols=None, freeze_indexes=None)

Remove outliers with missing neighbours.

Parameters:

  • s (DataFrame) –

    summary frame

  • distance (float, default: 0.7 ) –

    cut-off (all cycles that have a closest neighbour further apart this number will be removed)

  • filter_cols (list, default: None ) –

    list of column headers to perform the filtering on (defaults to charge and discharge capacity)

  • freeze_indexes (list, default: None ) –

    list of cycle indexes that should never be removed (defaults to cycle 1)

Returns:

  • filtered summary (pandas.DataFrame)

Returns:

remove_outliers_from_summary_on_value

remove_outliers_from_summary_on_value(s, low=0.0, high=7000, filter_cols=None, freeze_indexes=None)

Remove outliers based highest and lowest allowed value

Parameters:

  • s (DataFrame) –

    summary frame

  • low (float, default: 0.0 ) –

    low cut-off (all cycles with values below this number will be removed)

  • high (float, default: 7000 ) –

    high cut-off (all cycles with values above this number will be removed)

  • filter_cols (list, default: None ) –

    list of column headers to perform the filtering on (defaults to charge and discharge capacity)

  • freeze_indexes (list, default: None ) –

    list of cycle indexes that should never be removed (defaults to cycle 1)

Returns:

  • filtered summary (pandas.DataFrame)

Returns:

remove_outliers_from_summary_on_window

remove_outliers_from_summary_on_window(s, window_size=3, cut=0.1, iterations=1, col_name=None, freeze_indexes=None)

Removes outliers based on neighbours

remove_outliers_from_summary_on_zscore

remove_outliers_from_summary_on_zscore(s, zscore_limit=4, filter_cols=None, freeze_indexes=None)

Remove outliers based on z-score.

Parameters:

  • s (DataFrame) –

    summary frame

  • zscore_limit (int, default: 4 ) –

    remove outliers outside this z-score limit

  • filter_cols (list, default: None ) –

    list of column headers to perform the filtering on (defaults to charge and discharge capacity)

  • freeze_indexes (list, default: None ) –

    list of cycle indexes that should never be removed (defaults to cycle 1)

Returns:

  • filtered summary (pandas.DataFrame)

select_summary_based_on_rate

select_summary_based_on_rate(cell, rate=None, on=None, rate_std=None, rate_column=None, inverse=False, inverted=False, fix_index=True, partition_by_cv=False)

Select only cycles charged or discharged with a given rate.

Parameters:

  • rate (float, default: None ) –

    the rate to filter on. Remark that it should be given as a float, i.e. you will have to convert from C-rate to the actual numeric value. For example, use rate=0.05 if you want to filter on cycles that has a C/20 rate.

  • on (str, default: None ) –

    only select cycles if based on the rate of this step-type (e.g. on="charge").

  • rate_std (float, default: None ) –

    allow for this inaccuracy in C-rate when selecting cycles

  • rate_column (str, default: None ) –

    column header name of the rate column,

  • inverse (bool, default: False ) –

    select steps that do not have the given C-rate.

  • inverted (bool, default: False ) –

    select cycles that do not have the steps filtered by given C-rate.

  • fix_index (bool, default: True ) –

    automatically set cycle indexes as the index for the summary dataframe if not already set.

Returns:

  • filtered summary (Pandas.DataFrame).

update_journal_cellpy_data_dir

update_journal_cellpy_data_dir(pages, new_path=None, from_path='PureWindowsPath', to_path='Path')

Update the path in the pages (batch) from one type of OS to another.

I use this function when I switch from my work PC (windows) to my home computer (mac).

Parameters:

  • pages

    the (batch.experiment.)journal.pages object (pandas.DataFrame)

  • new_path

    the base path (uses config.paths.cellpydatadir if not given)

  • from_path

    type of path to convert from.

  • to_path

    type of path to convert to.

Returns:

  • journal.pages (pandas.DataFrame)

yank_after

yank_after(b, last=None, keep_old=False)

Cut all cycles after a given cycle index number.

Parameters:

  • b (batch object) –

    the batch object to perform the cut on.

  • last (int or dict {cell_name

    last index}): the last cycle index to keep (if dict: use individual last indexes for each cell).

  • keep_old (bool, default: False ) –

    keep the original batch object and return a copy instead.

Returns:

  • batch object if keep_old is True, else None

yank_before

yank_before(b, first=None, keep_old=False)

Cut all cycles before a given cycle index number.

Parameters:

  • b (batch object) –

    the batch object to perform the cut on.

  • first (int or dict {cell_name

    first index}): the first cycle index to keep (if dict: use individual first indexes for each cell).

  • keep_old (bool, default: False ) –

    keep the original batch object and return a copy instead.

Returns:

  • batch object if keep_old is True, else None

yank_outliers

yank_outliers(b: Batch, zscore_limit=None, low=0.0, high=7000.0, filter_cols=None, freeze_indexes=None, remove_indexes=None, remove_last=False, iterations=1, zscore_multiplyer=1.3, distance=None, window_size=None, window_cut=0.1, keep_old=False)

Remove outliers from a batch object.

Parameters:

  • b (cellpy.utils.batch object) –

    the batch object to perform filtering one (required).

  • zscore_limit (int, default: None ) –

    will filter based on z-score if given.

  • low (float, default: 0.0 ) –

    low cut-off (all cycles with values below this number will be removed)

  • high (float, default: 7000.0 ) –

    high cut-off (all cycles with values above this number will be removed)

  • filter_cols (str, default: None ) –

    what columns to filter on.

  • freeze_indexes (list, default: None ) –

    indexes (cycles) that should never be removed.

  • remove_indexes (dict or list, default: None ) –

    if dict, look-up on cell label, else a list that will be the same for all

  • remove_last (dict or bool, default: False ) –

    if dict, look-up on cell label.

  • iterations (int, default: 1 ) –

    repeat z-score filtering if zscore_limit is given.

  • zscore_multiplyer (int, default: 1.3 ) –

    multiply zscore_limit with this number between each z-score filtering (should usually be less than 1).

  • distance (float, default: None ) –

    nearest neighbour normalised distance required (typically 0.5).

  • window_size (int, default: None ) –

    number of cycles to include in the window.

  • window_cut (float, default: 0.1 ) –

    cut-off.

  • keep_old (bool, default: False ) –

    perform filtering of a copy of the batch object (not recommended at the moment since it then loads the full cellpyfile).

Returns:

  • if keep_old: new cellpy.utils.batch object.

  • else

    dictionary of removed cycles

collectors

Collectors are used for simplifying plotting and exporting batch objects.

BatchCollector

BatchCollector(b, data_collector, plotter=None, collector_name=None, name=None, nick=None, autorun=True, backend='plotly', elevated_data_collector_arguments=None, elevated_plotter_arguments=None, data_collector_arguments: dict = None, plotter_arguments: dict = None, experimental: bool = False, family_kind: str = None, **kwargs)

Update both the collected data and the plot(s).

Parameters:

  • b (Batch) –

    the batch object.

  • data_collector (callable) –

    method that collects the data.

  • plotter (callable, default: None ) –

    optional custom plotter; default None uses :func:cellpy.plotting.collected_plot (#657).

  • collector_name (str, default: None ) –

    name of collector.

  • name (str or bool, default: None ) –

    name used for auto-generating filenames etc.

  • autorun (bool, default: True ) –

    run collector and plotter immediately if True.

  • use_templates (bool) –

    also apply template(s) in autorun mode if True.

  • backend (str, default: 'plotly' ) –

    name of plotting backend to use ("plotly" or "matplotlib").

  • elevated_data_collector_arguments (dict, default: None ) –

    arguments picked up by the child class' initializer.

  • elevated_plotter_arguments (dict, default: None ) –

    arguments picked up by the child class' initializer.

  • data_collector_arguments (dict, default: None ) –

    keyword arguments sent to the data collector.

  • plotter_arguments (dict, default: None ) –

    keyword arguments sent to the plotter.

  • family_kind (str, default: None ) –

    summary | cycles | ica for collected_plot.

  • update_name (bool) –

    update the name (using automatic name generation) based on new settings.

  • **kwargs

    set Collector attributes.

collect

collect(*args, **kwargs)

Collect data.

generate_name

generate_name()

Generate a name for the collection.

parse_units

parse_units(**kwargs)

Look through your cellpy objects and search for units.

plot

plot(**kwargs)

Alias for :meth:render (plotting redesign §3.3 / #657).

post_collect

post_collect(*args, **kwargs)

Perform post-operation after collecting the data

render

render(**kwargs)

Render the figure via cellpy.plotting.collected_plot (#657).

reset_arguments

reset_arguments(data_collector_arguments: dict = None, plotter_arguments: dict = None)

Reset the arguments to the defaults.

Parameters:

  • data_collector_arguments (dict, default: None ) –

    optional additional keyword arguments for the data collector.

  • plotter_arguments (dict, default: None ) –

    optional additional keyword arguments for the plotter.

save

save(serial_number=None, save_hdf5=True, save_image_files=True, to_csv_kwargs: Union[dict, None] = None, to_image_files_kwargs: Union[dict, None] = None)

Save to csv, hdf5 and image files.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

  • save_hdf5 (bool, default: True ) –

    save to hdf5 file.

  • save_image_files (bool, default: True ) –

    save to image files.

  • to_csv_kwargs (dict, default: None ) –

    keyword arguments sent to the csv writer.

show

show(**kwargs)

Show the figure.

Note

If you are working in a Jupyter notebook and using a "matplotlib"-type backend, the figure will most likely be shown automatically when the figure is rendered. You should not need to use this method in that case, unless you want to show the figure one extra time.

Note

The show method returns the figure object and if the backend used does not provide automatic rendering in the editor / running environment you are using, you might have to issue the rendering yourself. For example, if you are using plotly and running it as a script in a typical command shell, you will have to issue .show() on the returned figure object.

Parameters:

  • **kwargs

    sent to the plotter.

Returns:

  • Figure object

to_csv

to_csv(serial_number=None)

Save to csv file.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

to_hdf5

to_hdf5(serial_number=None)

Save to hdf5 file.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

to_image_files

to_image_files(serial_number=None, **kwargs)

Save to image files (png, svg, json).

Notes

This method requires kaleido for the plotly backend.

Notes

Exporting to json is only applicable for the plotly backend.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

update

update(data_collector_arguments: dict = None, plotter_arguments: dict = None, reset: bool = False, update_data: bool = False, update_name: bool = False, update_plot: bool = True)

Update both the collected data and the plot(s).

Parameters:

  • data_collector_arguments (dict, default: None ) –

    keyword arguments sent to the data collector.

  • plotter_arguments (dict, default: None ) –

    keyword arguments sent to the plotter.

  • reset (bool, default: False ) –

    reset the arguments first.

  • update_data (bool, default: False ) –

    update the data before updating the plot even if data has been collected before.

  • update_name (bool, default: False ) –

    update the name (using automatic name generation) based on new settings.

  • update_plot (bool, default: True ) –

    update the plot.

BatchCyclesCollector

BatchCyclesCollector(b, plot_type='fig_pr_cell', collector_type='back-and-forth', cycles=None, max_cycle=None, number_of_points=100, rate=None, rate_on=None, rate_std=None, rate_agg=None, inverse=False, label_mapper=None, backend='plotly', cycles_to_plot=None, width=None, palette=None, show_legend=None, legend_position=None, fig_title=None, cols=None, group_legend_muting=True, only_selected: bool = False, *args, **kwargs)

Bases: BatchCollector

Create a collection of capacity plots.

Parameters:

  • b

    cellpy batch object

  • plot_type (str, default: 'fig_pr_cell' ) –

    either 'fig_pr_cell' or 'fig_pr_cycle'

  • backend (str, default: 'plotly' ) –

    what plotting backend to use (currently only 'plotly' is supported)

  • collector_type (str, default: 'back-and-forth' ) –

    how the curves are given

    • "back-and-forth" - standard back and forth; discharge (or charge) reversed from where charge (or discharge) ends.
    • "forth" - discharge (or charge) continues along x-axis.
    • "forth-and-forth" - discharge (or charge) also starts at 0.
  • cycles (list, default: None ) –

    select these cycles (elevated data collector argument).

  • max_cycle (int, default: None ) –

    drop all cycles above this value (elevated data collector argument).

  • rate (float, default: None ) –

    filter on rate (C-rate) (elevated data collector argument).

  • rate_on (str or list of str, default: None ) –

    only select cycles if based on the rate of this step-type (e.g. on="charge") (elevated data collector argument).

  • rate_std (float, default: None ) –

    allow for this inaccuracy when selecting cycles based on rate (elevated data collector argument).

  • rate_agg (str, default: None ) –

    how to aggregate the rate (e.g. "mean", "max", "min", "first", "last") (elevated data collector argument).

  • inverse (bool, default: False ) –

    select steps that do not have the given C-rate (elevated data collector argument).

  • label_mapper (callable or dict, default: None ) –

    function (or dict) that changes the cell names (elevated data collector argument). The dictionary must have the cell labels as given in the journal.pages index and new label as values. Similarly, if it is a function it takes the cell label as input and returns the new label. Remark! No check are performed to ensure that the new cell labels are unique.

  • cycles_to_plot (int, default: None ) –

    plot only these cycles (elevated plotter argument).

  • width (float, default: None ) –

    width of plot (elevated plotter argument).

  • legend_position (str, default: None ) –

    position of the legend (elevated plotter argument).

  • show_legend (bool, default: None ) –

    set to False if you don't want to show legend (elevated plotter argument).

  • fig_title (str, default: None ) –

    title (will be put above the figure) (elevated plotter argument).

  • palette (str, default: None ) –

    color-map to use (elevated plotter argument).

  • cols (int, default: None ) –

    number of columns (elevated plotter argument).

  • only_selected (bool, default: False ) –

    only process selected cells (elevated data collector argument).

collect

collect(*args, **kwargs)

Collect data.

parse_units

parse_units(**kwargs)

Look through your cellpy objects and search for units.

plot

plot(**kwargs)

Alias for :meth:render (plotting redesign §3.3 / #657).

post_collect

post_collect(*args, **kwargs)

Update the x-unit after collecting the data in case the mode has been set.

render

render(**kwargs)

Render the figure via cellpy.plotting.collected_plot (#657).

reset_arguments

reset_arguments(data_collector_arguments: dict = None, plotter_arguments: dict = None)

Reset the arguments to the defaults.

Parameters:

  • data_collector_arguments (dict, default: None ) –

    optional additional keyword arguments for the data collector.

  • plotter_arguments (dict, default: None ) –

    optional additional keyword arguments for the plotter.

save

save(serial_number=None, save_hdf5=True, save_image_files=True, to_csv_kwargs: Union[dict, None] = None, to_image_files_kwargs: Union[dict, None] = None)

Save to csv, hdf5 and image files.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

  • save_hdf5 (bool, default: True ) –

    save to hdf5 file.

  • save_image_files (bool, default: True ) –

    save to image files.

  • to_csv_kwargs (dict, default: None ) –

    keyword arguments sent to the csv writer.

show

show(**kwargs)

Show the figure.

Note

If you are working in a Jupyter notebook and using a "matplotlib"-type backend, the figure will most likely be shown automatically when the figure is rendered. You should not need to use this method in that case, unless you want to show the figure one extra time.

Note

The show method returns the figure object and if the backend used does not provide automatic rendering in the editor / running environment you are using, you might have to issue the rendering yourself. For example, if you are using plotly and running it as a script in a typical command shell, you will have to issue .show() on the returned figure object.

Parameters:

  • **kwargs

    sent to the plotter.

Returns:

  • Figure object

to_csv

to_csv(serial_number=None)

Save to csv file.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

to_hdf5

to_hdf5(serial_number=None)

Save to hdf5 file.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

to_image_files

to_image_files(serial_number=None, **kwargs)

Save to image files (png, svg, json).

Notes

This method requires kaleido for the plotly backend.

Notes

Exporting to json is only applicable for the plotly backend.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

update

update(data_collector_arguments: dict = None, plotter_arguments: dict = None, reset: bool = False, update_data: bool = False, update_name: bool = False, update_plot: bool = True)

Update both the collected data and the plot(s).

Parameters:

  • data_collector_arguments (dict, default: None ) –

    keyword arguments sent to the data collector.

  • plotter_arguments (dict, default: None ) –

    keyword arguments sent to the plotter.

  • reset (bool, default: False ) –

    reset the arguments first.

  • update_data (bool, default: False ) –

    update the data before updating the plot even if data has been collected before.

  • update_name (bool, default: False ) –

    update the name (using automatic name generation) based on new settings.

  • update_plot (bool, default: True ) –

    update the plot.

BatchICACollector

BatchICACollector(b, plot_type='fig_pr_cell', cycles=None, max_cycle=None, rate=None, rate_on=None, rate_std=None, rate_agg=None, inverse=False, label_mapper=None, backend='plotly', cycles_to_plot=None, width=None, palette=None, show_legend=None, legend_position=None, fig_title=None, cols=None, group_legend_muting=True, only_selected: bool = False, *args, **kwargs)

Bases: BatchCollector

Create a collection of ica (dQ/dV) plots.

Parameters:

  • b

    cellpy batch object

  • plot_type (str, default: 'fig_pr_cell' ) –

    either 'fig_pr_cell' or 'fig_pr_cycle'

  • backend (str, default: 'plotly' ) –

    what plotting backend to use (currently only 'plotly' is supported)

  • cycles (list, default: None ) –

    select these cycles (elevated data collector argument).

  • max_cycle (int, default: None ) –

    drop all cycles above this value (elevated data collector argument).

  • rate (float, default: None ) –

    filter on rate (C-rate) (elevated data collector argument).

  • rate_on (str or list of str, default: None ) –

    only select cycles if based on the rate of this step-type (e.g. on="charge") (elevated data collector argument).

  • rate_std (float, default: None ) –

    allow for this inaccuracy when selecting cycles based on rate (elevated data collector argument).

  • rate_agg (str, default: None ) –

    how to aggregate the rate (e.g. "mean", "max", "min", "first", "last") (elevated data collector argument).

  • inverse (bool, default: False ) –

    select steps that do not have the given C-rate (elevated data collector argument).

  • label_mapper (callable or dict, default: None ) –

    function (or dict) that changes the cell names (elevated data collector argument). The dictionary must have the cell labels as given in the journal.pages index and new label as values. Similarly, if it is a function it takes the cell label as input and returns the new label. Remark! No check are performed to ensure that the new cell labels are unique.

  • cycles_to_plot (int, default: None ) –

    plot points if True (elevated plotter argument).

  • width (float, default: None ) –

    width of plot (elevated plotter argument).

  • palette (str, default: None ) –

    color-map to use (elevated plotter argument).

  • legend_position (str, default: None ) –

    position of the legend (elevated plotter argument).

  • show_legend (bool, default: None ) –

    set to False if you don't want to show legend (elevated plotter argument).

  • fig_title (str, default: None ) –

    title (will be put above the figure) (elevated plotter argument).

  • cols (int, default: None ) –

    number of columns (elevated plotter argument).

  • group_legend_muting (bool, default: True ) –

    if True, the legend will be interactive (elevated plotter argument).

  • only_selected (bool, default: False ) –

    only process selected cells (elevated data collector argument).

collect

collect(*args, **kwargs)

Collect data.

parse_units

parse_units(**kwargs)

Look through your cellpy objects and search for units.

plot

plot(**kwargs)

Alias for :meth:render (plotting redesign §3.3 / #657).

post_collect

post_collect(*args, **kwargs)

Perform post-operation after collecting the data

render

render(**kwargs)

Render the figure via cellpy.plotting.collected_plot (#657).

reset_arguments

reset_arguments(data_collector_arguments: dict = None, plotter_arguments: dict = None)

Reset the arguments to the defaults.

Parameters:

  • data_collector_arguments (dict, default: None ) –

    optional additional keyword arguments for the data collector.

  • plotter_arguments (dict, default: None ) –

    optional additional keyword arguments for the plotter.

save

save(serial_number=None, save_hdf5=True, save_image_files=True, to_csv_kwargs: Union[dict, None] = None, to_image_files_kwargs: Union[dict, None] = None)

Save to csv, hdf5 and image files.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

  • save_hdf5 (bool, default: True ) –

    save to hdf5 file.

  • save_image_files (bool, default: True ) –

    save to image files.

  • to_csv_kwargs (dict, default: None ) –

    keyword arguments sent to the csv writer.

show

show(**kwargs)

Show the figure.

Note

If you are working in a Jupyter notebook and using a "matplotlib"-type backend, the figure will most likely be shown automatically when the figure is rendered. You should not need to use this method in that case, unless you want to show the figure one extra time.

Note

The show method returns the figure object and if the backend used does not provide automatic rendering in the editor / running environment you are using, you might have to issue the rendering yourself. For example, if you are using plotly and running it as a script in a typical command shell, you will have to issue .show() on the returned figure object.

Parameters:

  • **kwargs

    sent to the plotter.

Returns:

  • Figure object

to_csv

to_csv(serial_number=None)

Save to csv file.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

to_hdf5

to_hdf5(serial_number=None)

Save to hdf5 file.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

to_image_files

to_image_files(serial_number=None, **kwargs)

Save to image files (png, svg, json).

Notes

This method requires kaleido for the plotly backend.

Notes

Exporting to json is only applicable for the plotly backend.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

update

update(data_collector_arguments: dict = None, plotter_arguments: dict = None, reset: bool = False, update_data: bool = False, update_name: bool = False, update_plot: bool = True)

Update both the collected data and the plot(s).

Parameters:

  • data_collector_arguments (dict, default: None ) –

    keyword arguments sent to the data collector.

  • plotter_arguments (dict, default: None ) –

    keyword arguments sent to the plotter.

  • reset (bool, default: False ) –

    reset the arguments first.

  • update_data (bool, default: False ) –

    update the data before updating the plot even if data has been collected before.

  • update_name (bool, default: False ) –

    update the name (using automatic name generation) based on new settings.

  • update_plot (bool, default: True ) –

    update the plot.

BatchSummaryCollector

BatchSummaryCollector(b, max_cycle: int = None, rate=None, on=None, columns=None, column_names=None, normalize_capacity_on=None, scale_by=None, nom_cap=None, normalize_cycles=None, group_it=None, rate_std=None, rate_column=None, inverse=None, inverted: bool = None, key_index_bounds=None, backend: str = 'plotly', title: str = None, markers: bool = None, line: bool = None, width: int = None, height: int = None, legend_title: str = None, marker_size: int = None, cmap=None, spread: bool = None, fig_title: str = None, only_selected: bool = None, *args, **kwargs)

Bases: BatchCollector

Collects and shows summaries.

Parameters:

  • b (Batch) –

    the batch object.

  • name (str or bool) –

    name used for auto-generating filenames etc.

  • autorun (bool) –

    run collector and plotter immediately if True.

  • use_templates (bool) –

    also apply template(s) in autorun mode if True.

  • backend (str, default: 'plotly' ) –

    name of plotting backend to use ("plotly" or "matplotlib").

  • data_collector_arguments (dict) –

    keyword arguments sent to the data collector.

  • plotter_arguments (dict) –

    keyword arguments sent to the plotter.

  • update_name (bool) –

    update the name (using automatic name generation) based on new settings.

  • backend (str, default: 'plotly' ) –

    what plotting backend to use (currently only 'plotly' is supported)

  • max_cycle (int, default: None ) –

    drop all cycles above this value (elevated data collector argument).

  • rate (float, default: None ) –

    filter on rate (C-rate) (elevated data collector argument).

  • on (str or list of str, default: None ) –

    only select cycles if based on the rate of this step-type (e.g. on="charge"). (elevated data collector argument).

  • columns (list, default: None ) –

    selected column(s) (using cellpy attribute name). Defaults to "charge_capacity_gravimetric". (elevated data collector argument).

  • column_names (list, default: None ) –

    selected column(s) (using exact column name) (elevated data collector argument)

  • normalize_capacity_on (list, default: None ) –

    list of cycle numbers that will be used for setting the basis of the normalization (typically the first few cycles after formation) (elevated data collector argument)

  • scale_by (float or str, default: None ) –

    scale the normalized data with nominal capacity if "nom_cap", or given value (defaults to one) (elevated data collector argument).

  • nom_cap (float, default: None ) –

    nominal capacity of the cell (elevated data collector argument)

  • normalize_cycles (bool, default: None ) –

    perform a normalization of the cycle numbers (also called equivalent cycle index) (elevated data collector argument).

  • group_it (bool, default: None ) –

    if True, average pr group (elevated data collector argument).

  • rate_std (float, default: None ) –

    allow for this inaccuracy when selecting cycles based on rate (elevated data collector argument)

  • rate_column (str, default: None ) –

    name of the column containing the C-rates (elevated data collector argument).

  • inverse (bool, default: None ) –

    select steps that do not have the given C-rate (elevated data collector argument).

  • inverted (bool, default: None ) –

    select cycles that do not have the steps filtered by given C-rate (elevated data collector argument).

  • key_index_bounds (list, default: None ) –

    used when creating a common label for the cells in a group (when group_it is set to True) by splitting and combining from key_index_bound[0] to key_index_bound[1]. For example, if your cells are called "cell_01_01" and "cell_01_02" and you set key_index_bounds=[0, 2], the common label will be "cell_01". Or if they are called "20230101_cell_01_01_01" and "20230101_cell_01_01_02" and you set key_index_bounds=[1, 3], the common label will be "cell_01_01" (elevated data collector argument).

  • only_selected (bool, default: None ) –

    only process selected cells (elevated data collector argument).

  • markers (bool, default: None ) –

    plot points if True (elevated plotter argument).

  • line (bool, default: None ) –

    plot line if True (elevated plotter argument).

  • width (int, default: None ) –

    width of plot (elevated plotter argument).

  • height (int, default: None ) –

    height of plot (elevated plotter argument).

  • legend_title (str, default: None ) –

    title to put over the legend (elevated plotter argument).

  • marker_size (int, default: None ) –

    size of the markers used (elevated plotter argument).

  • cmap

    color-map to use (elevated plotter argument).

  • spread (bool, default: None ) –

    plot error-bands instead of error-bars if True (elevated plotter argument).

  • fig_title (str, default: None ) –

    title of the figure (elevated plotter argument).

collect

collect(*args, **kwargs)

Collect data.

parse_units

parse_units(**kwargs)

Look through your cellpy objects and search for units.

plot

plot(**kwargs)

Alias for :meth:render (plotting redesign §3.3 / #657).

post_collect

post_collect(*args, **kwargs)

Perform post-operation after collecting the data

render

render(**kwargs)

Render the figure via cellpy.plotting.collected_plot (#657).

reset_arguments

reset_arguments(data_collector_arguments: dict = None, plotter_arguments: dict = None)

Reset the arguments to the defaults.

Parameters:

  • data_collector_arguments (dict, default: None ) –

    optional additional keyword arguments for the data collector.

  • plotter_arguments (dict, default: None ) –

    optional additional keyword arguments for the plotter.

save

save(serial_number=None, save_hdf5=True, save_image_files=True, to_csv_kwargs: Union[dict, None] = None, to_image_files_kwargs: Union[dict, None] = None)

Save to csv, hdf5 and image files.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

  • save_hdf5 (bool, default: True ) –

    save to hdf5 file.

  • save_image_files (bool, default: True ) –

    save to image files.

  • to_csv_kwargs (dict, default: None ) –

    keyword arguments sent to the csv writer.

show

show(**kwargs)

Show the figure.

Note

If you are working in a Jupyter notebook and using a "matplotlib"-type backend, the figure will most likely be shown automatically when the figure is rendered. You should not need to use this method in that case, unless you want to show the figure one extra time.

Note

The show method returns the figure object and if the backend used does not provide automatic rendering in the editor / running environment you are using, you might have to issue the rendering yourself. For example, if you are using plotly and running it as a script in a typical command shell, you will have to issue .show() on the returned figure object.

Parameters:

  • **kwargs

    sent to the plotter.

Returns:

  • Figure object

to_csv

to_csv(serial_number=None)

Save to csv file.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

to_hdf5

to_hdf5(serial_number=None)

Save to hdf5 file.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

to_image_files

to_image_files(serial_number=None, **kwargs)

Save to image files (png, svg, json).

Notes

This method requires kaleido for the plotly backend.

Notes

Exporting to json is only applicable for the plotly backend.

Parameters:

  • serial_number (int, default: None ) –

    serial number to append to the filename.

update

update(data_collector_arguments: dict = None, plotter_arguments: dict = None, reset: bool = False, update_data: bool = False, update_name: bool = False, update_plot: bool = True)

Update both the collected data and the plot(s).

Parameters:

  • data_collector_arguments (dict, default: None ) –

    keyword arguments sent to the data collector.

  • plotter_arguments (dict, default: None ) –

    keyword arguments sent to the plotter.

  • reset (bool, default: False ) –

    reset the arguments first.

  • update_data (bool, default: False ) –

    update the data before updating the plot even if data has been collected before.

  • update_name (bool, default: False ) –

    update the name (using automatic name generation) based on new settings.

  • update_plot (bool, default: True ) –

    update the plot.

cycles_collector

cycles_collector(b, cycles=None, rate=None, rate_on=None, rate_std=None, rate_agg='first', inverse=False, interpolated=True, number_of_points=100, max_cycle=50, abort_on_missing=False, method='back-and-forth', label_mapper=None, mode='gravimetric', only_selected=False)

Collects cycles from all the cells in the batch object.

Parameters:

  • b

    cellpy batch object

  • cycles

    list of cycle numbers to collect

  • rate

    filter on rate (C-rate)

  • rate_on

    only select cycles if based on the rate of this step-type (e.g. on="charge").

  • rate_std

    allow for this inaccuracy when selecting cycles based on rate

  • rate_agg

    how to aggregate the rate (e.g. "mean", "max", "min", "first", "last")

  • inverse

    select steps that do not have the given C-rate.

  • interpolated

    if True, interpolate the data

  • number_of_points

    number of points to interpolate to

  • max_cycle

    drop all cycles above this value

  • abort_on_missing

    if True, abort if a cell is empty

  • method

    how the voltage curves are given (back-and-forth, forth, forth-and-forth)

  • label_mapper

    function (or dict) that changes the cell names.

  • mode (string, default: 'gravimetric' ) –

    'gravimetric', 'areal', 'volumetric' or 'absolute'.

  • only_selected (bool, default: False ) –

    only process selected cells.

Returns:

  • pd.DataFrame: collected data

ica_collector

ica_collector(b, cycles=None, rate=None, rate_on=None, rate_std=None, rate_agg='first', inverse=False, voltage_resolution=0.005, max_cycle=50, abort_on_missing=False, label_direction=True, number_of_points=None, label_mapper=None, only_selected=False, **kwargs)

Collects ica (dQ/dV) curves from all the cells in the batch object.

Parameters:

  • b

    cellpy batch object

  • cycles

    list of cycle numbers to collect

  • rate

    filter on rate (C-rate)

  • rate_on

    only select cycles if based on the rate of this step-type (e.g. on="charge").

  • rate_std

    allow for this inaccuracy when selecting cycles based on rate

  • rate_agg

    how to aggregate the rate (e.g. "mean", "max", "min", "first", "last")

  • inverse

    select steps that do not have the given C-rate.

  • voltage_resolution

    smoothing of the voltage curve

  • number_of_points

    number of points to interpolate to

  • max_cycle

    drop all cycles above this value

  • abort_on_missing

    if True, abort if a cell is empty

  • label_direction

    no-op since 2.0 (kept for signature compatibility; the specced ICA frame always carries a direction column)

  • label_mapper

    function (or dict) that changes the cell names.

  • only_selected (bool, default: False ) –

    only process selected cells.

  • **kwargs

    passed on to ica.dqdv

Returns:

  • pd.DataFrame: collected data

load_data

load_data(filename)

Load data from hdf5 file.

pick_named_cell

pick_named_cell(b, label_mapper=None)

Generator that picks a cell from the batch object, yields its label and the cell itself.

Parameters:

  • b (cellpy.batch object) –

    your batch object

  • label_mapper (callable or dict, default: None ) –

    function (or dict) that changes the cell names. The dictionary must have the cell labels as given in the journal.pages index and new label as values. Similarly, if it is a function it takes the cell label as input and returns the new label. Remark! No check are performed to ensure that the new cell labels are unique.

Yields:

  • label, group, subgroup, cell

Example

def my_mapper(n): return "".join(n.split("")[1:-1])

outputs "nnn_x" etc., if cell-names are of the form "date_nnn_x_y":

for label, group, subgroup, cell in pick_named_cell(b, label_mapper=my_mapper): print(label)

save_plotly_figure

save_plotly_figure(figure, name=None, directory='.', serial_number=None)

Save to image files (png, svg, json).

Notes

This method requires kaleido for the plotly backend.

Notes

Exporting to json is only applicable for the plotly backend.

Parameters:

  • figure

    the plotly figure object.

  • name (str, default: None ) –

    name of the file (without extension).

  • directory (str, default: '.' ) –

    directory to save the file in.

  • serial_number (int, default: None ) –

    serial number to append to the filename.

standard_gravimetric_collector

standard_gravimetric_collector(b, norm_factor=120.0, **kwargs)

Create a standard gravimetric collector.

This is a temporary hack to allow for making standard plot no. 1.

Coulombic Efficiency Discharge Capacity (gravimetric) Discharge Capacity Retention (Normalized) CV share Charge Capacity (Normalized)

Parameters:

  • norm_factor (float, default: 120.0 ) –

    the factor to normalize the discharge capacity retention by.

  • group_it (bool) –

    if True, group the cells by the key_index_bounds.

  • data_collector_arguments (dict) –

    the data collector arguments.

  • plotter_arguments (dict) –

    the plotter arguments.

  • **kwargs

    additional arguments sent to the collector.

summary_collector

summary_collector(*args, **kwargs)

Collects summaries using cellpy.utils.helpers.concat_summaries.