Preprocessing functions¶
- class ionworkspipeline.data_fits.preprocess.PiecewiseLinearTimeseries(t_data, y_data, atol=None, rtol=None, name=None, options=None)¶
A class to preprocess and linearize time series data using piecewise linear approximation.
Attributes:¶
- t_dataarray-like
The time data points.
- y_dataarray-like
The corresponding data points.
- atolfloat, optional
Absolute tolerance for the solver. If None, uses the default solver atol of 1e-6.
- rtolfloat, optional
Relative tolerance for the solver. If None, uses the default solver rtol of 1e-4.
- namestr, optional
The name of the timeseries. Default is “Piecewise linear timeseries”.
- optionsdict, optional
Additional options for preprocessing. If None, default options are used.
- solver_max_save_pointsint
Maximum number of points to save in the solver. Default is 10000.
- interactive_preprocessingbool
Whether to use interactive preprocessing to select atol and rtol. Default is False.
- window_maxint
Maximum window size for removing neighboring points. Default is 10.
Extends:
ionworkspipeline.controllers.OptionsController
- interpolant(interpolator='linear', name=None, **kwargs)¶
Generate an interpolant for the given sparse time series data.
Parameters¶
- interpolatorstr, optional
The type of interpolation to use. Default is “linear”.
- namestr, optional
The name of the interpolant. Default is the name of the timeseries.
- **kwargs
Additional keyword arguments to pass to pybamm.Interpolant.
Returns¶
- pybamm.Interpolant
An interpolant object for the sparse time series data.
- ionworkspipeline.data_fits.preprocess.pulse_data_to_ocp(pulse_data_in, ocp_file_out=None, method='explicit', include_first_point=True)¶
Extract the open-circuit potential (OCP) from data from a pulse test (e.g. GITT or HPPC test)
Parameters¶
- pulse_data_instr or pd.DataFrame
The pulse test data to use. Can be a string giving the path to the data, or a DataFrame containing the data.
- ocp_file_outstr, optional
The file to write the OCP data to. If not provided, the data is not written.
- methodstr, optional
The method to use to extract the OCP. Can be “explicit” (default) or “extrapolation”. If “explicit”, the OCP is taken to be the voltage at the last data point of each cycle. If “extrapolation”, the OCP is calculated by extrapolating the voltage to its asymptote, to account for the relaxation being incomplete at the end of the cycle. Only “explicit” is currently implemented.
- include_first_pointbool, optional
Whether to include the first point of the data. Should be True if the first point is after a sufficiently long rest period (i.e. the voltage of the first point is the open-circuit voltage), and False otherwise.
Returns¶
- pd.DataFrame
A dataframe containing the OCP data.
- ionworkspipeline.data_fits.preprocess.sort_capacity_and_ocp(data)¶
For OCP data, make sure that the capacity is always increasing and the voltage is always decreasing
Parameters¶
- data:
pd.DataFrame
Pandas dataframe containing the data, should include one column with the voltage and one column with the capacity
- data:
- ionworkspipeline.data_fits.preprocess.remove_duplicate_ocp(data, capacity_column_name='Capacity [A.h]')¶
Remove any duplicate capacity and voltage values
- ionworkspipeline.data_fits.preprocess.remove_ocp_extremes(data)¶
Remove any data points at the start and end of the OCP curve where the second derivative of the voltage with respect to capacity is zero. This is to remove any data points where the voltage is not changing smoothly, which can have an outsized effect on the fit. For example, in some datasets, the OCP at the extremes is linearly extrapolated from the first and last few data points (zero second derivative), which can cause a bad fit in the MSMR model.
Parameters¶
- data:
pd.DataFrame
Pandas dataframe containing the data, should include one column with the voltage in Volts (“Voltage [V]”) and one column with the capacity in Amp-hours (“Capacity [A.h]”)
Returns¶
pd.DataFrame
Pandas dataframe containing the trimmed data
- data: