cellpy.utils.batch_tools package

Contents

cellpy.utils.batch_tools package#

Submodules#

cellpy.utils.batch_tools.batch_analyzers module#

class BaseSummaryAnalyzer[source]#

Bases: BaseAnalyzer

class EISAnalyzer[source]#

Bases: BaseAnalyzer

class ICAAnalyzer[source]#

Bases: BaseAnalyzer

class OCVRelaxationAnalyzer[source]#

Bases: BaseAnalyzer

Analyze open curcuit relaxation curves.

This analyzer is still under development. (Partly) implented so far: select_ocv_points -> farms. To get the DataFrames from the farms, you can use >>> ocv_point_frames = OCVRelaxationAnalyzer.last

selection_method#

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_time: select first, and same interval; defaults to “martin”)

number_of_points#

number of points you want. defaults to 5

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). defaults to 10

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. defaults to False

report_times#

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

direction#

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

Type:

“up”, “down” or “both”

Notes

This analyzer is not working as intended yet. Todos:

  • include better engine-dumper methodology and dump stuff to both memory and file(s) (should add this to BaseAnalyser)

  • recieve settings and parameters

  • option (dumper) for plotting?

  • automatic fitting of OCV rlx data?

property dframe: DataFrame#
do()[source]#

Do what is needed and dump it for each engine.

do2()[source]#
property last: list#
ocv_points_engine(**kwargs)[source]#
run_dumper(dumper)[source]#

Place the animals in the barn

run_engine(engine)[source]#

Run the engine, build the barn and put the animals on the farm

screen_dumper(**kwargs)[source]#

cellpy.utils.batch_tools.batch_core module#

class BaseAnalyzer(*args)[source]#

Bases: Doer

run_dumper(dumper)[source]#

Place the animals in the barn

run_engine(engine, **kwargs)[source]#

Run the engine, build the barn and put the animals on the farm

class BaseExperiment(*args)[source]#

Bases: object

An experiment contains experimental data and meta-data.

property data: Data#

Property for accessing the underlying data in an experiment.

Example

>>> cell_data_one = experiment.data["2018_cell_001"]
>>> capacity, voltage = cell_data_one.get_cap(cycle=1)
get_data()[source]#
info()[source]#

Print information about the experiment.

property max_cycle#
status()[source]#

Describe the status and health of your experiment.

abstractmethod update()[source]#

Get or link data.

class BaseExporter(*args)[source]#

Bases: Doer

An exporter exports your data to a given format.

run_dumper(dumper)[source]#
run_engine(engine, **kwargs)[source]#

Set the current_engine and run it.

The method sets and engages the engine (callable) and provide appropriate binding to at least the class attributes self.farms and self.barn.

Example

self.current_engine = engine self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms, **kwargs)

Parameters:
  • engine (callable) – the function that should be called.

  • **kwargs – additional keyword arguments sent to the callable.

class BaseJournal[source]#

Bases: object

A journal keeps track of the details of the experiment.

The journal should at a mimnimum contain information about the name and project the experiment has.

pages#

table with information about each cell/file.

Type:

pandas.DataFrame

name#

the name of the experiment (used in db-lookup).

Type:

str

project#

the name of the project the experiment belongs to (used for making folder names).

Type:

str

file_name#

the file name used in the to_file method.

Type:

str or path

project_dir#

folder where to put the batch (or experiment) files and information (will be deprecated in future versions).

batch_dir#

folder in project_dir where summary-files and information and results related to the current experiment are stored (will be deprecated in future versions).

raw_dir#

folder in batch_dir where cell-specific information and results are stored (e.g. raw-data, dq/dv data, voltage-capacity cycles) (will be deprecated in future versions).

create()[source]#

Create a journal manually

from_db()[source]#

Make journal pages by looking up a database.

Default to using the simple excel “database” provided by cellpy.

If you don’t have a database, or you don’t know how to make and use one, look in the cellpy documentation for other solutions (e.g. manually create a file that can be loaded by the from_file method).

from_file(file_name)[source]#
generate_file_name()[source]#

Create a file name for saving the journal.

packable = ['name', 'project', 'time_stamp', 'project_dir', 'batch_dir', 'raw_dir']#
paginate()[source]#

Create folders used for saving the different output files.

to_file(file_name=None)[source]#

Save journal pages to a file.

The file can then be used in later sessions using the from_file method.

class BasePlotter(*args)[source]#

Bases: Doer

abstractmethod run_dumper(dumper)[source]#
abstractmethod run_engine(engine, **kwargs)[source]#

Set the current_engine and run it.

The method sets and engages the engine (callable) and provide appropriate binding to at least the class attributes self.farms and self.barn.

Example

self.current_engine = engine self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms, **kwargs)

Parameters:
  • engine (callable) – the function that should be called.

  • **kwargs – additional keyword arguments sent to the callable.

class BaseReporter(*args)[source]#

Bases: Doer

abstractmethod run_dumper(dumper)[source]#
abstractmethod run_engine(engine)[source]#

Set the current_engine and run it.

The method sets and engages the engine (callable) and provide appropriate binding to at least the class attributes self.farms and self.barn.

Example

self.current_engine = engine self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms, **kwargs)

Parameters:
  • engine (callable) – the function that should be called.

  • **kwargs – additional keyword arguments sent to the callable.

class Data(experiment, *args)[source]#

Bases: UserDict

Class that is used to access the experiment.journal.pages DataFrame.

The Data class loads the complete cellpy-file if raw-data is not already loaded in memory. In future version, it could be that the Data object will return a link allowing querying instead to save memory usage…

Remark that some cellpy (cellreader.CellpyCell) function might not work if you have the raw-data in memory, but not summary data (if the cellpy function requires summary data or other settings not set as default).

first()[source]#

Pick out first cell from the batch

last()[source]#

Pick out last cell from the batch

sample()[source]#

Pick out one random cell from the batch

class Doer(*args)[source]#

Bases: object

Base class for all the classes that do something to the experiment(s).

experiments#

list of experiments.

farms#

list of farms (one pr experiment) (containing pandas DataFrames).

barn#

identifier for where to place the output-files (i.e. the animals) (typically a directory path).

Type:

str

The do-er iterates through all the connected engines and dumpers (the dumpers are run for each engine).

It is the responsibility of the engines and dumpers to iterate through the experiments. The most natural way is to work with just one experiment.

assign(experiment)[source]#

Assign an experiment.

do(**kwargs)[source]#

Do what is needed and dump it for each engine.

empty_the_farms()[source]#

Free all the farms for content (empty all lists).

info()[source]#

Delivers some info to you about the class.

abstractmethod run_dumper(dumper)[source]#
abstractmethod run_engine(engine, **kwargs)[source]#

Set the current_engine and run it.

The method sets and engages the engine (callable) and provide appropriate binding to at least the class attributes self.farms and self.barn.

Example

self.current_engine = engine self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms, **kwargs)

Parameters:
  • engine (callable) – the function that should be called.

  • **kwargs – additional keyword arguments sent to the callable.

cellpy.utils.batch_tools.batch_experiments module#

class CyclingExperiment(*args, **kwargs)[source]#

Bases: BaseExperiment

Load experimental data into memory.

This is a re-implementation of the old batch behaviour where all the data-files are processed sequentially (and optionally exported) while the summary tables are kept and processed. This implementation also saves the step tables (for later use when using look-up functionality).

journal (

obj: LabJournal): information about the experiment.

force_cellpy#

tries only to load the cellpy-file if True.

Type:

bool

force_raw#

loads raw-file(s) even though appropriate cellpy-file exists if True.

Type:

bool

save_cellpy#

saves a cellpy-file for each cell if True.

Type:

bool

accept_errors#

in case of error, dont raise an exception, but continue to the next file if True.

Type:

bool

all_in_memory#

store the cellpydata-objects in memory if True.

Type:

bool

export_cycles#

export voltage-capacity curves if True.

Type:

bool

shifted_cycles#

set this to True if you want to export the voltage-capacity curves using the shifted-cycles option (only valid if you set export_cycles to True).

Type:

bool

export_raw#

export the raw-data if True.

Type:

bool

export_ica#

export dq-dv curves if True.

Type:

bool

last_cycle#

sets the last cycle (i.e. the highest cycle number) that you would like to process dq-dv on). Use all if None (the default value).

Type:

int

selected_summaries#

a list of summary labels defining what summary columns to make joint summaries from (optional).

Type:

list

errors#

contains a dictionary listing all the errors encountered.

Type:

dict

Parameters:

db_reader (str or object) – custom db_reader (see doc on db_reader).

Example:

property cell_names#

Returns a list of cell-names (strings)

export_cellpy_files(path=None, **kwargs)[source]#

Export all cellpy-files to a given path.

Remarks:

This method can only export to local folders (OtherPath objects are not formally supported, but might still work if the path is local).

Parameters:

path (str, pathlib.Path) – path to export to (default: current working directory)

Ensure that an appropriate link to the cellpy-files exists for each cell.

The experiment will then contain a CellpyCell object for each cell (in the cell_data_frames attribute) with only the step-table stored.

Remark that running update persists the summary frames instead (or everything in case you specify all_in_memory=True). This might be considered “a strange and unexpected behaviour”. Sorry for that (but the authors of this package is also a bit strange…).

(OK, I will change it. Soon.)

Parameters:

mark_bad (bool) – mark bad cells (default: False)

**kwargs: passed to _link_cellpy_file
max_cycle (int): maximum cycle number to link/load (remark that the

cellpy objects will get the property overwrite_able set to False if you give a max_cycle to prevent accidentally saving a “truncated” file (use c.save(filename, overwrite=True) to force overwrite))

parallel_update(all_in_memory=None, cell_specs=None, logging_mode=None, **kwargs)[source]#

Updates the selected datasets in parallel.

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).

  • kwargs

    transferred all the way to the instrument loader, 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:
    recalc (Bool): set to False if you don’t want automatic “recalc” of

    cycle numbers etc. when merging several data-sets.

    Loading:

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

    Debugging:

    debug (Bool): set to True if you want to run in debug mode (should never be used by non-developers).

Debug-mode:
  • runs only for the first item in your journal

Examples

>>> # Don't perform recalculation of cycle numbers etc. when merging
>>> # All cells:
>>> b.update(recalc=False)
>>> # For specific cell(s):
>>> cell_specs_cell_01 = {"name_of_cell_01": {"recalc": False}}
>>> b.update(cell_specs=cell_specs_cell_01)
recalc(save=True, step_opts=None, summary_opts=None, indexes=None, calc_steps=True, testing=False)[source]#

Run make_step_table and make_summary on all cells.

Parameters:
  • save (bool) – Save updated cellpy-files if True.

  • step_opts (dict) – parameters to inject to make_steps.

  • summary_opts (dict) – parameters to inject to make_summary.

  • indexes (list) – Only recalculate for given indexes (i.e. list of cell-names).

  • calc_steps (bool) – Run make_steps before making the summary.

  • testing (bool) – Only for testing purposes.

Returns:

None

save_cells(**kwargs)[source]#

Save all cells in the experiment.

Parameters:

kwargs – passed to the save method of the CellpyData-object.

Returns:

None

status()[source]#

Describe the status and health of your experiment.

update(all_in_memory=None, cell_specs=None, logging_mode=None, accept_errors=None, **kwargs)[source]#

Updates the selected datasets.

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.

  • kwargs

    transferred all the way to the instrument loader, 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:
    recalc (Bool): set to False if you don’t want automatic “recalc” of

    cycle numbers etc. when merging several data-sets.

    Loading:

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

    Debugging:

    debug (Bool): set to True if you want to run in debug mode (should never be used by non-developers).

Debug-mode:
  • runs only for the first item in your journal

Examples

>>> # Don't perform recalculation of cycle numbers etc. when merging
>>> # All cells:
>>> b.update(recalc=False)
>>> # For specific cell(s):
>>> cell_specs_cell_01 = {"name_of_cell_01": {"recalc": False}}
>>> b.update(cell_specs=cell_specs_cell_01)
class ImpedanceExperiment[source]#

Bases: BaseExperiment

class LifeTimeExperiment[source]#

Bases: BaseExperiment

cellpy.utils.batch_tools.batch_exporters module#

class CSVExporter(use_screen_dumper=False)[source]#

Bases: BaseExporter

Export experiment(s) to csv-files.

CSV Exporter looks at your experiments and exports data to csv format. It contains two engines: summary_engine and cycles_engine, and two dumpers: csv_dumper and screen_dumper.

You assign experiments to CSVExporter either as input during instantiation or by issuing the assign(experiment) method.

To perform the exporting, issue CSVExporter.do()

Example

>>> exporter = CSVExporter(my_experiment)
>>> exporter.do()
Parameters:

use_screen_dumper (bool) – dump info to screen (default False).

run_dumper(dumper)[source]#

run dumber (once pr. engine)

Parameters:

dumper – dumper to run (function or method).

The dumper takes the attributes experiments, farms, and barn as input.

run_engine(engine, **kwargs)[source]#

run engine (once pr. experiment).

Parameters:

engine – engine to run (function or method).

The method issues the engine command (with experiments and farms as input) that returns an updated farms as well as the barn and assigns them both to self.

The farms attribute is a list of farms, i.e. [farm1, farm2, …], where each farm contains pandas DataFrames.

The barns attribute is a pre-defined string used for picking what folder(s) the file(s) should be exported to. For example, if barn equals “batch_dir”, the file(s) will be saved to the experiments batch directory.

class ExcelExporter[source]#

Bases: BaseExporter

Exporter that saves the file in a format that Excel likes.

class OriginLabExporter[source]#

Bases: BaseExporter

Exporter that saves the files in a format convenient for OriginLab.

cellpy.utils.batch_tools.batch_helpers module#

create_factory()[source]#
create_folder_structure(project_name, batch_name)[source]#

This function creates a folder structure for the batch project.

The folder structure consists of main working folder project_name` located in the ``outdatadir (as defined in the cellpy configuration file) with a sub-folder named batch_name. It also creates a folder inside the batch_name folder for storing the raw data. If the folders does not exist, they will be made. The function also returns the name of the info-df.

Parameters:
  • project_name – name of the project

  • batch_name – name of the batch

Returns: (info_file, (project_dir, batch_dir, raw_dir))

create_labels(label, *args)[source]#

Returns a re-formatted label (currently it only removes the dates from the run-name)

create_selected_summaries_dict(summaries_list)[source]#

Creates a dictionary with summary column headers.

Examples

>>> summaries_to_output = ["discharge_capacity_gravimetric", "charge_capacity_gravimetric"]
>>> summaries_to_output_dict = create_selected_summaries_dict(
>>>    summaries_to_output
>>> )
>>> print(summaries_to_output_dict)
{'discharge_capacity_gravimetric': "discharge_capacity_gravimetric",
       'charge_capacity_gravimetric': "discharge_capacity_gravimetric"}
Parameters:

summaries_list – list containing cellpy summary column id names

Returns: dictionary of the form {cellpy id name: cellpy summary

header name,}

export_dqdv(cell_data, savedir, sep, last_cycle=None)[source]#

Exports dQ/dV data from a CellpyCell instance.

Parameters:
  • cell_data – CellpyCell instance

  • savedir – path to the folder where the files should be saved

  • sep – separator for the .csv-files.

  • last_cycle – only export up to this cycle (if not None)

find_files(info_dict, file_list=None, pre_path=None, sub_folders=None, skip_file_search=False, **kwargs)[source]#

Find files using cellpy.filefinder.

Parameters:
  • info_dict – journal pages.

  • file_list – list of files names to search through.

  • pre_path – path to prepend found files from file_list (if file_list is given).

  • sub_folders (bool) – perform search also in sub-folders.

  • skip_file_search (bool) – if True, do not search for files; use existing raw_file_names and cellpy_file_name in info_dict if present (e.g. when custom JSON already contains paths). Default False.

**kwargs (filefinder.search_for_files):

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)

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). 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.

Returns:

info_dict

fix_groups(groups)[source]#

Takes care of strange group numbers.

generate_folder_names(name, project)[source]#

Creates sensible folder names.

join_summaries(summary_frames, selected_summaries, keep_old_header=False, mitigation_strategy='drop', mitigation_keep_method='first')[source]#

parse the summaries and combine based on column (selected_summaries)

look_up_and_get(cellpy_file_name, table_name, root=None, max_cycle=None)[source]#

Extracts table from cellpy hdf5-file.

make_sub_groups(info_df)[source]#
make_unique_groups(info_df)[source]#

This function cleans up the group numbers a bit.

pick_summary_data(key, summary_df, selected_summaries)[source]#

picks the selected pandas.DataFrame

save_multi(data, file_name, sep=';')[source]#

Convenience function for storing data column-wise in a csv-file.

cellpy.utils.batch_tools.batch_journals module#

class LabJournal(db_reader='default', engine=None, batch_col=None, db_file=None, **kwargs)[source]#

Bases: BaseJournal, ABC

add_cell(cell_id, **kwargs)[source]#

Add a cell to the pages

add_comment(comment)[source]#

add a comment (will be saved in the journal file)

create_empty_pages(description=None)[source]#
duplicate_journal(folder=None) None[source]#

Copy the journal to folder.

Parameters:
  • folder (str or pathlib.Path) – folder to copy to (defaults to the

  • folder). (current)

from_db(project=None, name=None, batch_col=None, dbreader_kwargs=None, **kwargs)[source]#

populate journal from db.

Parameters:
  • project (str) – project name.

  • name (str) – experiment name.

  • batch_col (int) – batch column.

  • dbreader_kwargs – sent to simple db_reader.

**kwargs: sent to engine.

simple_db-engine -> filefinder.search_for_files:

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)

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) [not finished yet].

reg_exp(str): use regular expression instead (defaults to None) [not finished yet]. 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.

Returns:

None

from_dict(info_dict, **kwargs)[source]#
from_file(file_name=None, paginate=True, **kwargs)[source]#

Loads a DataFrame with all the needed info about the experiment

from_file_old(file_name=None)[source]#

Loads a DataFrame with all the needed info about the experiment

from_frame(frame, name=None, project=None, paginate=None, **kwargs)[source]#
generate_empty_session()[source]#
generate_file_name(to_project_folder=False) None[source]#

generate a suitable file name for the experiment

Parameters:

to_project_folder (bool) – if True, save to prms.Paths.outdatadir/project/, otherwise save to current directory (default False)

generate_folder_names(use_outdatadir=False)[source]#

Set appropriate folder names.

Parameters:

use_outdatadir (bool) – if True, use prms.Paths.outdatadir as base for all directories, otherwise use current_directory as base.

get_cell(id_key)[source]#

get additional cell info from db

get_column(header)[source]#

populate new column from db

look_for_file()[source]#
paginate() tuple[str, str, str][source]#

Make folders where we would like to put results etc.

classmethod read_journal_excel_file(file_name, **kwargs)[source]#
classmethod read_journal_jason_file(file_name: Path | str | bytes | bytearray, **kwargs) tuple[DataFrame, dict, dict][source]#

Loads a journal file in json format.

remove_cell(cell_id)[source]#
remove_comment(comment_id)[source]#
select_all() None[source]#

Select all cells.

select_by(criterion: str) None[source]#

Select only cells based on criterion as used by the pandas query method.

select_distinct(column_name: str, value: str | int | float) None[source]#

Select cells based on a column value.

select_group(group: int) None[source]#

Toggle the selected status of a group of cells.

to_file(file_name=None, paginate=True, to_project_folder=False, duplicate_to_project_folder=False, duplicate_to_local_folder=None)[source]#

Saves a DataFrame with all the needed info about the experiment.

Parameters:
  • file_name (str or pathlib.Path) – journal file name (.json or .xlsx)

  • paginate (bool) – make project folders

  • to_project_folder (bool) – if True, save journal file to prms.Paths.outdatadir/project/ (default False, saves to current directory)

  • duplicate_to_project_folder (bool) – if True, copy journal file to prms.Paths.outdatadir/project/ after saving to current directory (default False)

  • duplicate_to_local_folder (bool) – Deprecated. For backward compatibility only. If provided, it is ignored since the default behavior now saves to current directory.

Returns:

None

toggle_selected(cell_name: str) None[source]#

Toggle the selected status of a cell.

unselect_all() None[source]#

Unselect all cells.

unselect_group(group: int) None[source]#

Toggle the selected status of a group of cells.

update_group_labels(group_labels: dict) None[source]#
view_comments()[source]#

cellpy.utils.batch_tools.batch_plotters module#

class CyclingSummaryPlotter(*args, reset_farms=True)[source]#

Bases: BasePlotter

property columns#
property fig#

Alias for figure.

property figure#

Get the (first) figure/canvas.

property figures#

Get all figures/canvases.

run_dumper(dumper)[source]#

run dumber (once pr. engine)

Parameters:

dumper – dumper to run (function or method).

The dumper takes the attributes experiments, farms, and barn as input. It does not return anything. But can, if the dumper designer feels in a bad and nasty mood, modify the input objects (for example experiments).

run_engine(engine, **kwargs)[source]#

run engine (once pr. experiment).

Parameters:

engine – engine to run (function or method).

The method issues the engine command (with experiments and farms as input) that returns an updated farms as well as the barn and assigns them both to self.

The farms attribute is a list of farms, i.e. [farm1, farm2, …], where each farm contains pandas DataFrames.

The barns attribute is a pre-defined string used for picking what folder(s) the file(s) should be exported to. For example, if barn equals “batch_dir”, the file(s) will be saved to the experiments batch directory.

The engine(s) is given self.experiments and self.farms as input and returns farms to self.farms and barn to self.barn. Thus, one could in principle modify self.experiments within the engine without explicitly ‘notifying’ the poor soul who is writing a batch routine using that engine. However, it is strongly advised not to do such things. And if you, as engine designer, really need to, then at least notify it through a debug (logger) statement.

class EISPlotter[source]#

Bases: BasePlotter

do()[source]#

Do what is needed and dump it for each engine.

create_legend(info, c, option='clean', use_index=False)[source]#

creating more informative legends

create_plot_option_dicts(info, marker_types=None, colors=None, line_dash=None, size=None, palette=None)[source]#

Create two dictionaries with plot-options.

The first iterates colors (based on group-number), the second iterates through marker types.

Returns: group_styles (dict), sub_group_styles (dict)

create_summary_plot_bokeh(data, info, group_styles, sub_group_styles, label=None, title='Capacity', x_axis_label='Cycle number', y_axis_label='Capacity (mAh/g)', width=900, height=400, legend_option='clean', legend_location='bottom_right', x_range=None, y_range=None, tools=None)[source]#
exporting_plots(**kwargs)[source]#
generate_summary_frame_for_plotting(pages, experiment, **kwargs) DataFrame[source]#
generate_summary_plots(experiment, **kwargs)[source]#
look_up_group(info, c)[source]#
plot_cycle_life_summary_bokeh(info, summaries, width=900, height=800, height_fractions=None, legend_option='all', add_rate=True, **kwargs)[source]#
plot_cycle_life_summary_matplotlib(info, summaries, width=900, height=800, height_fractions=None, legend_option='all', **kwargs)[source]#
plot_cycle_life_summary_plotly(summaries: DataFrame, **kwargs)[source]#

Plotting cycle life summaries using plotly.

plot_cycle_life_summary_seaborn(summaries: DataFrame, **kwargs)[source]#

Plotting cycle life summaries using seaborn.

summary_plotting_engine(**kwargs)[source]#

creates plots of summary data.

cellpy.utils.batch_tools.batch_reporters module#

class HTMLReporter[source]#

Bases: BaseReporter

run_dumper(dumper)[source]#
run_engine(engine)[source]#

Set the current_engine and run it.

The method sets and engages the engine (callable) and provide appropriate binding to at least the class attributes self.farms and self.barn.

Example

self.current_engine = engine self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms, **kwargs)

Parameters:
  • engine (callable) – the function that should be called.

  • **kwargs – additional keyword arguments sent to the callable.

class PPTReporter[source]#

Bases: BaseReporter

run_dumper(dumper)[source]#
run_engine(engine)[source]#

Set the current_engine and run it.

The method sets and engages the engine (callable) and provide appropriate binding to at least the class attributes self.farms and self.barn.

Example

self.current_engine = engine self.farms, self.barn = engine(experiments=self.experiments, farms=self.farms, **kwargs)

Parameters:
  • engine (callable) – the function that should be called.

  • **kwargs – additional keyword arguments sent to the callable.

cellpy.utils.batch_tools.dumpers module#

Dumpers are functions that are used by the Do-ers. Keyword Args: experiments, farms, barn, engine Returns nothing.

csv_dumper(**kwargs)[source]#

dump data to csv

excel_dumper(**kwargs)[source]#

Dump data to excel xlxs-format.

origin_dumper(**kwargs)[source]#

Dump data to a format suitable for use in OriginLab.

ram_dumper(**kwargs)[source]#

Dump data to ‘memory’ for later usage.

screen_dumper(**kwargs)[source]#

Dump data to screen.

cellpy.utils.batch_tools.engines module#

Engines are functions that are used by the Do-ers.

Keyword Args: experiments, farms, barn, optionals Returns: farms, barn

cycles_engine(**kwargs)[source]#

engine to extract cycles

dq_dv_engine(**kwargs)[source]#

engine that performs incremental analysis of the cycle-data

raw_data_engine(**kwargs)[source]#

engine to extract raw data

simple_db_engine(reader=None, cell_ids=None, file_list=None, pre_path=None, include_key=False, include_individual_arguments=True, additional_column_names=None, batch_name=None, clean_journal=False, **kwargs)[source]#

Engine that gets values from the db for given set of cell IDs.

The simple_db_engine looks up values for mass, names, etc. from the db using the reader object. In addition, it searches for the corresponding raw files / data.

Parameters:
  • reader – a reader object (defaults to dbreader.Reader)

  • cell_ids – keys (cell IDs) (assumes that the db has already been filtered, if not, use batch_name).

  • 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 (only valid for the simple excel reader).

  • batch_name – name of the batch (used if cell_ids are not given)

  • clean_journal – remove the file_name_indicator column from the pages (default: True).

  • **kwargs – sent to filefinder

Returns:

pages (pandas.DataFrame)

sql_db_engine(*args, **kwargs) DataFrame[source]#
summary_engine(**kwargs)[source]#

engine to extract summary data

cellpy.utils.batch_tools.sqlite_from_excel_db module#

class DbColsRenamer(cellpy_col: str = '', dtype: str = '', excel_col: str = '', db_col: str = '')[source]#

Bases: object

cellpy_col: str = ''#
db_col: str = ''#
dtype: str = ''#
excel_col: str = ''#
clean_up(df, columns)[source]#

Clean up the dataframe and return using ‘proper cellpy headers’.

create_column_names_from_prms()[source]#

Create a list of DbColsRenamer objects from the cellpy.prms.DbCols object.

load_xlsx(db_file='cellpy_db.xlsx', table_name='db_table', header_row=0, unit_row=1)[source]#

Load the Excel file and return a pandas dataframe.

main()[source]#
run()[source]#
save_sqlite(sheet, out_file='excel.db', table_name='cells', set_index=False)[source]#

Save the pandas dataframe to a sqlite database.

Module contents#