battdeg package¶
Submodules¶
battdeg.battdeg module¶
This module can be used to read cycling data of the CX2, CS2 and PL type cells as a dataframe. It converts cumulative values into individual values for each cycle and determines net charge of the battery at every datapoint. It can also be used to train and test a LSTM model and predict discharge capacity using the LSTM model.
-
battdeg.battdeg.capacity(df_data)[source]¶ This function calculates the net capacity of the battery from the charge capacity and discharge capacity values.
Args: df_data(dataframe): Concatenated dataframe which has the values of charge capacity and discharge capacity for which net capacity has to be calculated.
Returns: Dataframe with net capacity of the battery for every point of the charge and discharge cycle.
-
battdeg.battdeg.concat_df(df_dict)[source]¶ This function concatenates all the dataframes and edits the cycle index for the concatenated dataframes.
Args: df_dict(dictionary): Dictionary of dataframes to be concatenated.
Returns: A concatenated dataframe with editted cycle index
-
battdeg.battdeg.concat_dict_dataframes(dict_ord_cycling_data)[source]¶ This function takes in a dictionary with ordered keys and concatenates the dataframes in the values of the dictionary to create a large dataframe with all the records.
- Args:
- dict_ord_cycling_data (dict):
- The dictionary with ordered integer keys and dataframes as values
- Returns:
- The dataframe after concatenation
-
battdeg.battdeg.cx2_file_reader(data_dir, file_name_format, sheet_name)[source]¶ This function reads in the data for CX2 samples experiment and returns a well formatted dataframe with cycles in ascending order.
Args: data_dir (string): This is the absolute path to the data directory. file_name_format (string): Format of the filename, used to deduce other files. sheet_name (string): Sheet name containing the data in the excel file.
Returns: The complete test data in a dataframe with extra column for capacity in Ah.
-
battdeg.battdeg.data_formatting(merged_df)[source]¶ This function formats the merged dataframe so that it can be used to frame the given time series data as a supervised learning dataset.
- Args:
- merged_df(dataframe): The merged dataframe which can be obtained by using the function ‘cx2_file_reader’
- Returns:
- A numpy array with only values required to frame a time series as a supervised learning dataset.
-
battdeg.battdeg.date_time_converter(date_time_list)[source]¶ This function gets the numpy array with date_time in matlab format and returns a numpy array with date_time in human readable format.
-
battdeg.battdeg.file_name_sorting(file_name_list)[source]¶ This function sorts all the file names according to the date on the file name.
Args: file_name_list(list): List containing all the file names to be read
Returns: A list of file names sorted according to the date on the file name.
-
battdeg.battdeg.file_reader(data_dir, file_name_format, sheet_name, ignore_file_indices)[source]¶ This function reads PL sample, CX2 and CS2 files and returns a nice dataframe with cyclic values of charge and discharge capacity with cycles in ascending order
Args: data_dir (string): This is the absolute path to the data directory. file_name_format (string): Format of the filename, used to deduce other files. sheet_name (string): Sheet name containing the data in the excel file. ignore_file_indices (list, int): This list of ints tells which to ignore.
Returns: The complete test data in a dataframe with extra column for capacity in Ah.
-
battdeg.battdeg.get_cycle_capacities(df_out)[source]¶ This function takes the dataframe, creates a new index and then calculates capacities per cycle from cumulative charge and discharge capacities
- Args:
- df_out (pandas.DataFrame):
- Concatenated dataframe
- Returns:
- the dataframe with capacities per cycle
-
battdeg.battdeg.get_dict_files(data_dir, file_name_format, ignore_file_indices)[source]¶ This function finds all the files at the location of the file name format as specified and then creates a dictionary after ignoring the list of file specified
- Args:
- data_dir (string): This is the absolute path to the data directory. file_name_format (string): Format of the filename, used to deduce other files. ignore_file_indices (list, int): This list of ints tells which to ignore.
- Returns:
- The dictionary with all data from files dataframes.
-
battdeg.battdeg.long_short_term_memory(model_data)[source]¶ This function splits the input dataset into training and testing datasets. The keras LSTM model is then trained and tested using the respective datasets.
- Args:
- model_data(dataframe): Values of input and output variables of time series data framed as a supervised learning dataset.
- Returns:
- model_loss(dictionary): Returns the history dictionary (more info to be added) y_hat(array): Predicted response for the testing dataset. y_prediction(array): Predicted response for the completely new dataset.
-
battdeg.battdeg.model_prediction(input_data)[source]¶ This function can be used to forecast the discharge capacity of a battery using the trained LSTM model
Args: input_data(dataframe): This is the dataframe containing the current, voltage and discharge capacity values at a prior time which can be used to forecast discharge capacity at a further time.
Returns: y_predicted: The forecasted values of discharge capacity.
-
battdeg.battdeg.model_training(data_dir, file_name_format, sheet_name)[source]¶ This function converts cumulative battery cycling data into individual cycle data and trains the LSTM model with the converted data set.
- Args:
- data_dir (string): This is the absolute path to the data directory. file_name_format (string): Format of the filename, used to deduce other files. sheet_name(string or int): Sheet name or sheet number in the excel file containing the relevant data.
- Returns:
- model_loss(dictionary): Returns the history dictionary (more info to be added) y_hat(array): Predicted response for the testing dataset. # y_prediction(array): Predicted response for the completely new dataset # (The input has to be the time series cycling data including values of # Current, Voltage and Discharge Capacity)
-
battdeg.battdeg.pl_samples_file_reader(data_dir, file_name_format, ignore_file_indices)[source]¶ This function reads in the data for PL Samples experiment and returns a nice dataframe with cycles in ascending order.
- Args:
- data_dir (string): This is the absolute path to the data directory. file_name_format (string): Format of the filename, used to deduce other files. ignore_file_indices (list, int): This list of ints tells which to ignore.
- Returns:
- The complete test data in a dataframe with extra column for capacity in Ah.
-
battdeg.battdeg.reading_dataframes(file_names, sheet_name, path)[source]¶ This function reads all the files in the sorted file names list as a dataframe
Args(list): file_names: Sorted file names list sheet_name: Sheet name in the excel file containing the data.
Returns: Dictionary of dataframes in the order of the sorted file names.
-
battdeg.battdeg.series_to_supervised(data, n_in=1, n_out=1, dropnan=True)[source]¶ Frame a time series as a supervised learning dataset.
- Arguments:
- data: Sequence of observations as a list or NumPy array. n_in: Number of lag observations as input (X). n_out: Number of observations as output (y). dropnan: Boolean whether or not to drop rows with NaN values.
- Returns:
- Pandas DataFrame of series framed for supervised learning.