def get_hppc_features(processed_cycler_run, diag_pos=1, soc_window=7): """ This method calculates features based on voltage and resistance changes in hppc and rpt cycles Args: processed_cycler_run (beep.structure.ProcessedCyclerRun) parameters_path (str): path to the project parameters file diag_pos (int): diagnostic cycle occurence for a specific <diagnostic_cycle_type>. e.g. if rpt_0.2C, occurs at cycle_index = [2, 42, 147, 249 ...], <diag_pos>=2 would correspond to cycle_index 147 parameters_path (str): location of parameter table csv soc_window (int): step index counter corresponding to the soc window of interest. Returns: dataframe of features based on voltage and resistance changes over a SOC window in hppc cycles """ data = processed_cycler_run.diagnostic_interpolated cycle_hppc = data.loc[data.cycle_type == 'hppc'] cycle_hppc = cycle_hppc.loc[cycle_hppc.current.notna()] cycles = cycle_hppc.cycle_index.unique() [f2_d, f2_c] = featurizer_helpers.get_hppc_r(processed_cycler_run, cycles[diag_pos]) f3 = featurizer_helpers.get_hppc_ocv(processed_cycler_run, cycles[diag_pos]) v_diff = featurizer_helpers.get_v_diff(cycles[diag_pos], processed_cycler_run, soc_window) params, _ = get_protocol_parameters(processed_cycler_run.protocol.split('.')[0]) params = params[['charge_cutoff_voltage', 'discharge_cutoff_voltage']].reset_index(drop=True) df_c = pd.DataFrame() df_c = df_c.append({'var(v_diff)': np.var(v_diff), 'resistance_d': f2_d, 'resistance_c': f2_c, 'var(ocv)': f3}, ignore_index=True) df_c.reset_index(drop=True, inplace=True) df_c = pd.concat([df_c, params], axis=1) df_c.reset_index(drop=True, inplace=True) return df_c
def test_get_protocol_parameters(self): os.environ['BEEP_ROOT'] = TEST_FILE_DIR filepath = os.path.join(TEST_FILE_DIR, "PredictionDiagnostics_000109_tztest.010") test_path = os.path.join('data-share', 'raw', 'parameters') parameters, _ = get_protocol_parameters(filepath, parameters_path=test_path) self.assertEqual(parameters['diagnostic_type'].iloc[0], 'HPPC+RPT') self.assertEqual(parameters['seq_num'].iloc[0], 109) self.assertEqual(len(parameters.index), 1) parameters_missing, project_missing = get_protocol_parameters( 'Fake', parameters_path=test_path) self.assertEqual(parameters_missing, None) self.assertEqual(project_missing, None)
def test_get_protocol_parameters(self): os.environ["BEEP_PROCESSING_DIR"] = TEST_FILE_DIR filepath = os.path.join(TEST_FILE_DIR, "PredictionDiagnostics_000109_tztest.010") test_path = os.path.join("data-share", "raw", "parameters") parameters, _ = get_protocol_parameters(filepath, parameters_path=test_path) self.assertEqual(parameters["diagnostic_type"].iloc[0], "HPPC+RPT") self.assertEqual(parameters["diagnostic_parameter_set"].iloc[0], "Tesla21700") self.assertEqual(parameters["seq_num"].iloc[0], 109) self.assertEqual(len(parameters.index), 1) parameters_missing, project_missing = get_protocol_parameters( "Fake", parameters_path=test_path) self.assertEqual(parameters_missing, None) self.assertEqual(project_missing, None) filepath = os.path.join(TEST_FILE_DIR, "PreDiag_000292_tztest.010") parameters, _ = get_protocol_parameters(filepath, parameters_path=test_path) self.assertIsNone(parameters)
def get_parameter_dict(file_list, parameters_path): """ Helper function to generate a dictionary with Args: file_list (list): List of filenames from self.filenames parameters_path (str): Root directory storing project parameter files. Returns: Dictionary with file_list as keys, and corresponding dictionary of protocol parameters as values """ d = { } # dict allows combining two different project parameter sets into the same structure for file in file_list: param_row, _ = get_protocol_parameters(file, parameters_path) d[file] = param_row.to_dict('records')[ 0] # to_dict('records') returns a list. return d