예제 #1
0
    def test_get_step_index(self):
        structured_datapath_loc = os.path.join(
            TEST_FILE_DIR, "PreDiag_000240_000227_truncated_structure.json")

        parameters_path = os.path.join(TEST_FILE_DIR, "data-share", "raw",
                                       "parameters")
        structured_datapath = auto_load_processed(structured_datapath_loc)
        data = structured_datapath.diagnostic_data
        hppc_cycles = data.loc[data.cycle_type == "hppc"]
        # print(hppc_cycles.step_index.unique())
        _, protocol_name = os.path.split(structured_datapath.metadata.protocol)
        parameter_row, _ = parameters_lookup.get_protocol_parameters(
            protocol_name, parameters_path=parameters_path)

        for cycle in hppc_cycles.cycle_index.unique():
            hppc_cycle = hppc_cycles[hppc_cycles.cycle_index == cycle]
            for step in hppc_cycle.step_index.unique():
                hppc_cycle_step = hppc_cycle[(hppc_cycle.step_index == step)]
                for step_iter in hppc_cycle_step.step_index_counter.unique():
                    hppc_cycle_step_iter = hppc_cycle_step[(
                        hppc_cycle_step.step_index_counter == step_iter)]
                    duration = hppc_cycle_step_iter.test_time.max(
                    ) - hppc_cycle_step_iter.test_time.min()
                    median_crate = np.round(
                        hppc_cycle_step.current.median() /
                        parameter_row["capacity_nominal"].iloc[0], 2)
                    # print(step, median_crate, duration)

        step_ind = featurizer_helpers.get_step_index(structured_datapath,
                                                     cycle_type="hppc",
                                                     diag_pos=0)
        self.assertEqual(len(step_ind.values()), 6)
        print([
            step_ind["hppc_long_rest"], step_ind["hppc_discharge_pulse"],
            step_ind["hppc_short_rest"], step_ind["hppc_charge_pulse"],
            step_ind["hppc_discharge_to_next_soc"]
        ])

        self.assertEqual(
            step_ind, {
                'hppc_charge_to_soc': 9,
                'hppc_long_rest': 11,
                'hppc_discharge_pulse': 12,
                'hppc_short_rest': 13,
                'hppc_charge_pulse': 14,
                'hppc_discharge_to_next_soc': 15
            })
        step_ind = featurizer_helpers.get_step_index(structured_datapath,
                                                     cycle_type="hppc",
                                                     diag_pos=1)
        self.assertEqual(len(step_ind.values()), 6)
        self.assertEqual(
            step_ind, {
                'hppc_charge_to_soc': 41,
                'hppc_long_rest': 43,
                'hppc_discharge_pulse': 44,
                'hppc_short_rest': 45,
                'hppc_charge_pulse': 46,
                'hppc_discharge_to_next_soc': 47
            })
예제 #2
0
 def test_get_step_index_3(self):
     structured_datapath_loc = os.path.join(
         TEST_FILE_DIR,
         "PredictionDiagnostics_000136_00002D_truncated_structure.json")
     structured_datapath = auto_load_processed(structured_datapath_loc)
     step_ind = featurizer_helpers.get_step_index(structured_datapath,
                                                  cycle_type="hppc",
                                                  diag_pos=0)
     self.assertEqual(len(step_ind.values()), 6)
예제 #3
0
 def test_get_step_index_3(self):
     pcycler_run_loc = os.path.join(
         TEST_FILE_DIR,
         "PredictionDiagnostics_000136_00002D_truncated_structure.json")
     os.environ["BEEP_PROCESSING_DIR"] = TEST_FILE_DIR
     pcycler_run = auto_load_processed(pcycler_run_loc)
     step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                  cycle_type="hppc",
                                                  diag_pos=0)
     self.assertEqual(len(step_ind.values()), 6)
예제 #4
0
    def test_get_step_index_2(self):
        pcycler_run_loc = os.path.join(
            TEST_FILE_DIR, "PreDiag_000400_000084_truncated_structure.json")
        parameters_path = os.path.join(TEST_FILE_DIR, "data-share", "raw",
                                       "parameters")
        os.environ["BEEP_PROCESSING_DIR"] = TEST_FILE_DIR
        pcycler_run = auto_load_processed(pcycler_run_loc)
        _, protocol_name = os.path.split(pcycler_run.metadata.protocol)
        parameter_row, _ = parameters_lookup.get_protocol_parameters(
            protocol_name, parameters_path=parameters_path)

        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="hppc",
                                                     diag_pos=0)
        self.assertEqual(len(step_ind.values()), 7)

        self.assertEqual(
            step_ind, {
                'hppc_charge_to_soc': 9,
                'hppc_long_rest': 11,
                'hppc_discharge_pulse': 12,
                'hppc_short_rest': 13,
                'hppc_charge_pulse': 14,
                'hppc_discharge_to_next_soc': 15,
                'hppc_final_discharge': 17
            })
        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="hppc",
                                                     diag_pos=1)
        self.assertEqual(len(step_ind.values()), 7)
        self.assertEqual(
            step_ind, {
                'hppc_charge_to_soc': 41,
                'hppc_long_rest': 43,
                'hppc_discharge_pulse': 44,
                'hppc_short_rest': 45,
                'hppc_charge_pulse': 46,
                'hppc_discharge_to_next_soc': 47,
                'hppc_final_discharge': 49
            })
        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="reset",
                                                     diag_pos=0)
        self.assertEqual(step_ind, {'reset_charge': 5, 'reset_discharge': 6})
        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="reset",
                                                     diag_pos=1)
        self.assertEqual(step_ind, {'reset_charge': 38, 'reset_discharge': 39})

        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="rpt_0.2C",
                                                     diag_pos=0)
        self.assertEqual(step_ind, {
            'rpt_0.2C_charge': 19,
            'rpt_0.2C_discharge': 20
        })
        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="rpt_0.2C",
                                                     diag_pos=1)
        self.assertEqual(step_ind, {
            'rpt_0.2C_charge': 51,
            'rpt_0.2C_discharge': 52
        })

        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="rpt_1C",
                                                     diag_pos=0)
        self.assertEqual(step_ind, {
            'rpt_1C_charge': 22,
            'rpt_1C_discharge': 23
        })
        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="rpt_1C",
                                                     diag_pos=1)
        self.assertEqual(step_ind, {
            'rpt_1C_charge': 54,
            'rpt_1C_discharge': 55
        })

        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="rpt_2C",
                                                     diag_pos=0)
        self.assertEqual(step_ind, {
            'rpt_2C_charge': 25,
            'rpt_2C_discharge': 26
        })
        step_ind = featurizer_helpers.get_step_index(pcycler_run,
                                                     cycle_type="rpt_2C",
                                                     diag_pos=1)
        self.assertEqual(step_ind, {
            'rpt_2C_charge': 57,
            'rpt_2C_discharge': 58
        })