Electrochemistry
CycleBlock
¶
CycleBlock(item_id: str | None = None, collection_id: str | None = None, init_data: dict | None = None, unique_id: str | None = None)
Bases: DataBlock
A data block for processing electrochemical cycling data.
This class that contains functions for processing dataframes created by navani from raw cycler files and plotting them with Bokeh.
Navani documentation: be-smith.github.io/navani/
The file formats currently supported are:
- Biologic (.mpr) - requires galvani echemdata/galvani
- Arbin (.res, .xls and .xlsx) - the .res format requires galvani echemdata/galvani
- Neware (.nda, .ndax)
- Ivium (.txt)
- Lanhe/Lande (.xls, .xlsx) - most formats, certain exports may not work depending on the software version or settings
- Preprocessed (.csv) - CSV files with appropriate columns ['Capacity', 'Voltage', 'half cycle', 'full cycle', 'Current', 'state']
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
str | None
|
The item to which the block is attached, or |
None
|
collection_id
|
str | None
|
The collection to which the block is attached. |
None
|
init_data
|
dict | None
|
A dictionary of data to initialise the block with. |
None
|
unique_id
|
str | None
|
A unique id for the block, used in the DOM and database. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
accepted_file_extensions |
|
|
block_db_model |
|
|
block_id |
|
|
blocktype |
|
|
data |
|
|
defaults |
dict[str, Any]
|
|
description |
|
|
multi_file |
bool
|
Whether this block can accept multiple files as input. |
name |
|
|
plot_functions |
|
|
version |
str
|
The implementation version of this particular block. |
accepted_file_extensions
¶
accepted_file_extensions = ('.mpr', '.txt', '.xls', '.xlsx', '.res', '.nda', '.ndax', '.csv', '.bdf', '.bdf.csv', '.bdf.parquet', '.bdf.gz')
data
¶
data = {'item_id': item_id, 'collection_id': collection_id, 'blocktype': blocktype, 'block_id': block_id, None: defaults}
defaults
¶
defaults: dict[str, Any] = {'p_spline': 5, 's_spline': 5, 'win_size_2': 101, 'win_size_1': 1001, 'derivative_mode': None}
description
¶
description = "This block can plot data from electrochemical cycling experiments from many different cycler's file formats.\n The file formats currently supported are:\n\n - Biologic (.mpr)\n - Arbin (.res, .xls and .xlsx)\n - Neware (.nda, .ndax)\n - Ivium (.txt)\n - Lanhe/Lande (.xls, .xlsx)\n - Preprocessed (.csv) (previously extracted by navani or other tools)\n - Battery Data Format (.bdf, .bdf.csv, .bdf.parquet, .bdf.gz) - a standardized format defined by the Battery Data Alliance project (https://battery-data-alliance.github.io/battery-data-format/)\n\n "
events_by_name
¶
Returns a dict of registered events for this block.
from_web
¶
from_web(data: dict)
Initialise the block state from data passed via web request with a given item, collection and block ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The block data to initialiaze the block with. |
required |
null_event
¶
null_event(**kwargs)
A null debug event that does nothing but logs its kwargs and overwrites the data dict with the args.
plot_cycle
¶
plot_cycle()
Plots the electrochemical cycling data from the file ID provided in the request.
process_events
¶
Handle any supported events passed to the block.
process_raw_echem_df
¶
process_raw_echem_df(raw_df: DataFrame, cycle_summary_df: DataFrame | None) -> tuple[DataFrame, DataFrame | None]
Filter and rename columns of a raw navani DataFrame to standardised unit-suffixed names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_df
|
DataFrame
|
The raw DataFrame returned by navani. |
required |
cycle_summary_df
|
DataFrame | None
|
The cycle summary DataFrame, or None if unavailable. |
required |
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, DataFrame | None]
|
A tuple of (raw_df, cycle_summary_df) with standardised column names. |
to_db
¶
to_db() -> dict
returns a dictionary with the data for this block, ready to be input into mongodb
to_web
¶
Returns a JSON serializable dictionary to render the data block on the web.
update_from_web
¶
update_from_web(data: dict)
Update the block with validated data received from a web request. Will strip any fields that are "computed" or otherwise not controllable by the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary of data to update the block with. |
required |