Measurement loading

Options controlling how measurement data is selected and preprocessed before a fit sees it, and the payload shapes a measurement can be supplied in.

Schema for the options accepted when loading measurement data.

class ionworks_schema.data_loader.DataLoaderTransforms(*, gitt_to_ocp: bool | None = None, rest_to_ocp: bool | None = None, sort: bool | None = None, remove_duplicates: bool | None = None, remove_extremes: bool | None = None, filters: dict[str, Any] | None = None, interpolate: float | list[float] | None = None, keep_first_ocp_point: bool | None = None)

Bases: BaseSchema

Preprocessing steps applied to a measurement before a fit sees it.

Each step may also be given at the top level of the options bag, which is the older spelling; both are merged before the transforms run.

Parameters

gitt_to_ocpbool, optional

Reduce a GITT measurement to an OCP curve.

rest_to_ocpbool, optional

Reduce rest periods to an OCP curve. Mutually exclusive with gitt_to_ocp.

sortbool, optional

Sort by the independent variable.

remove_duplicatesbool, optional

Drop duplicated rows.

remove_extremesbool, optional

Drop the first and last points of an OCP curve.

filtersdict, optional

Column filters to apply, keyed by column name.

interpolatefloat or list of float, optional

Resample onto this spacing or these points.

keep_first_ocp_pointbool, optional

Keep the first point when reducing to an OCP curve. Ignored unless gitt_to_ocp or rest_to_ocp is set.

Examples

>>> iws.DataLoaderTransforms(sort=True, remove_duplicates=True).to_config()
{'sort': True, 'remove_duplicates': True}

Extends: ionworks_schema.base.BaseSchema

gitt_to_ocp: bool | None
rest_to_ocp: bool | None
sort: bool | None
remove_duplicates: bool | None
remove_extremes: bool | None
filters: dict[str, Any] | None
interpolate: float | list[float] | None
keep_first_ocp_point: bool | None
model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

class ionworks_schema.data_loader.DataLoaderOptions(*, transforms: DataLoaderTransforms | None = None, first_step: int | str | dict[str, Any] | None = None, last_step: int | str | dict[str, Any] | None = None, capacity_column: str | None = None, first_step_dict: int | str | dict[str, Any] | None = None, last_step_dict: int | str | dict[str, Any] | None = None, gitt_to_ocp: bool | None = None, rest_to_ocp: bool | None = None, sort: bool | None = None, remove_duplicates: bool | None = None, remove_extremes: bool | None = None, filters: dict[str, Any] | None = None, interpolate: float | list[float] | None = None, keep_first_ocp_point: bool | None = None)

Bases: BaseSchema

Options controlling how measurement data is loaded and preprocessed.

Selects a subset of the measurement and applies preprocessing transforms before a fit sees it. Every field is optional; unknown keys are rejected, so a misspelt option fails when you build the config rather than being silently ignored and changing your results.

Parameters

transformsdict, optional

Preprocessing steps to apply, keyed by name — sort, remove_duplicates, remove_extremes, gitt_to_ocp, rest_to_ocp, keep_first_ocp_point, filters, interpolate. Each may also be given at the top level, which is the older spelling.

first_stepint, str, or dict, optional

Where to start the slice: a step index, a Polars SQL query against the steps table, or the deprecated dict form ({"cycle": 3}, {"step": 7}).

last_stepint, str, or dict, optional

Where to end the slice, in the same form as first_step.

capacity_columnstr, optional

Name of the column to treat as capacity when the default is not present.

first_step_dictdict, optional

Deprecated spelling of first_step.

last_step_dictdict, optional

Deprecated spelling of last_step.

gitt_to_ocpbool, optional

Reduce a GITT measurement to an OCP curve.

rest_to_ocpbool, optional

Reduce rest periods to an OCP curve. Mutually exclusive with gitt_to_ocp.

sortbool, optional

Sort by the independent variable before use.

remove_duplicatesbool, optional

Drop duplicated rows.

remove_extremesbool, optional

Drop the first and last points of an OCP curve.

filtersdict, optional

Column filters to apply, keyed by column name.

interpolatefloat or list of float, optional

Resample onto this spacing or these points.

keep_first_ocp_pointbool, optional

Keep the first point when reducing to an OCP curve. Ignored unless gitt_to_ocp or rest_to_ocp is set.

Examples

>>> options = iws.DataLoaderOptions(first_step=2, transforms={"sort": True})
>>> options.to_config()
{'transforms': {'sort': True}, 'first_step': 2}

Extends: ionworks_schema.base.BaseSchema

transforms: DataLoaderTransforms | None
first_step: int | str | dict[str, Any] | None
last_step: int | str | dict[str, Any] | None
capacity_column: str | None
first_step_dict: int | str | dict[str, Any] | None
last_step_dict: int | str | dict[str, Any] | None
gitt_to_ocp: bool | None
rest_to_ocp: bool | None
sort: bool | None
remove_duplicates: bool | None
remove_extremes: bool | None
filters: dict[str, Any] | None
interpolate: float | list[float] | None
keep_first_ocp_point: bool | None
model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

class ionworks_schema.data_loader.TimeSeriesSpec(*, time_series: Any, steps: Any = None)

Bases: BaseSchema

A measurement given as its time-series table, optionally with steps.

Parameters

time_seriesAny

The time-series table, as a DataFrame or a column mapping.

stepsAny, optional

The step table, in the same form.

Extends: ionworks_schema.base.BaseSchema

time_series: Any
steps: Any
model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

class ionworks_schema.data_loader.DataPayloadSpec(*, data: Any, options: DataLoaderOptions | None = None)

Bases: BaseSchema

A measurement plus the options controlling how it is loaded.

Parameters

dataAny

The measurement itself — a path spec, a table, or a nested payload.

optionsDataLoaderOptions, optional

How to slice and preprocess it. Unknown keys are rejected.

Extends: ionworks_schema.base.BaseSchema

data: Any
options: DataLoaderOptions | None
model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

class ionworks_schema.data_loader.MetadataSpec(*, data: Any, metadata: dict[str, Any])

Bases: BaseSchema

A measurement carried alongside its provenance metadata.

Parameters

dataAny

The measurement itself.

metadatadict

Provenance recorded when the measurement was loaded.

Extends: ionworks_schema.base.BaseSchema

data: Any
metadata: dict[str, Any]
model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.