Пример #1
0
    def test_from_raw_cycler_run_arbin(self):
        rcycler_run = RawCyclerRun.from_file(self.arbin_file)
        pcycler_run = ProcessedCyclerRun.from_raw_cycler_run(rcycler_run)
        self.assertIsInstance(pcycler_run, ProcessedCyclerRun)
        # Ensure barcode/protocol are passed
        self.assertEqual(pcycler_run.barcode, "EL151000429559")
        self.assertEqual(pcycler_run.protocol,
                         r"2017-12-04_tests\20170630-4_65C_69per_6C.sdu")

        all_summary = pcycler_run.summary
        reg_dtypes = all_summary.dtypes.tolist()
        reg_columns = all_summary.columns.tolist()
        reg_dtypes = [str(dtyp) for dtyp in reg_dtypes]
        for indx, col in enumerate(reg_columns):
            self.assertEqual(reg_dtypes[indx],
                             STRUCTURE_DTYPES['summary'][col])

        all_interpolated = pcycler_run.cycles_interpolated
        cycles_interpolated_dyptes = all_interpolated.dtypes.tolist()
        cycles_interpolated_columns = all_interpolated.columns.tolist()
        cycles_interpolated_dyptes = [
            str(dtyp) for dtyp in cycles_interpolated_dyptes
        ]
        for indx, col in enumerate(cycles_interpolated_columns):
            self.assertEqual(cycles_interpolated_dyptes[indx],
                             STRUCTURE_DTYPES['cycles_interpolated'][col])
Пример #2
0
    def test_from_raw_cycler_run_maccor(self):
        rcycler_run = RawCyclerRun.from_file(self.maccor_file_w_diagnostics)
        pcycler_run = ProcessedCyclerRun.from_raw_cycler_run(rcycler_run)
        self.assertIsInstance(pcycler_run, ProcessedCyclerRun)
        # Ensure barcode/protocol are passed
        self.assertEqual(pcycler_run.barcode, "EXP")
        self.assertEqual(pcycler_run.protocol, "xTESLADIAG_000020_CH71.000")
        steps = pcycler_run.cycles_interpolated.step_type.unique().tolist()
        # Ensure that charge and discharge steps are processed
        self.assertEqual(steps, ['discharge', 'charge'])

        min_index = pcycler_run.cycles_interpolated.cycle_index.min()
        if 'step_type' in pcycler_run.cycles_interpolated.columns:
            discharge_interpolated = pcycler_run.cycles_interpolated[(
                pcycler_run.cycles_interpolated.step_type == 'discharge')]
            min_index_df = pcycler_run.cycles_interpolated[
                (pcycler_run.cycles_interpolated.cycle_index == min_index)
                & (pcycler_run.cycles_interpolated.step_type == 'discharge')]
        else:
            discharge_interpolated = pcycler_run.cycles_interpolated
            min_index_df = pcycler_run.cycles_interpolated[(
                pcycler_run.cycles_interpolated.cycle_index == min_index)]
        matches = discharge_interpolated.groupby(
            "cycle_index").apply(lambda x: np.allclose(
                x.voltage.values, min_index_df.voltage.values))
        if not np.all(matches):
            raise ValueError("cycles_interpolated are not uniform")
Пример #3
0
 def test_from_raw_cycler_run_maccor(self):
     rcycler_run = RawCyclerRun.from_file(self.maccor_file_w_diagnostics)
     pcycler_run = ProcessedCyclerRun.from_raw_cycler_run(rcycler_run)
     self.assertIsInstance(pcycler_run, ProcessedCyclerRun)
     # Ensure barcode/protocol are passed
     self.assertEqual(pcycler_run.barcode, "EXP")
     self.assertEqual(pcycler_run.protocol, "xTESLADIAG_000020_CH71.000")
Пример #4
0
 def test_from_raw_cycler_run_arbin(self):
     rcycler_run = RawCyclerRun.from_file(self.arbin_file)
     pcycler_run = ProcessedCyclerRun.from_raw_cycler_run(rcycler_run)
     self.assertIsInstance(pcycler_run, ProcessedCyclerRun)
     # Ensure barcode/protocol are passed
     self.assertEqual(pcycler_run.barcode, "EL151000429559")
     self.assertEqual(pcycler_run.protocol,
                      r"2017-12-04_tests\20170630-4_65C_69per_6C.sdu")
Пример #5
0
 def test_from_raw_cycler_run_parameters(self):
     rcycler_run = RawCyclerRun.from_file(self.maccor_file_w_parameters)
     pcycler_run = ProcessedCyclerRun.from_raw_cycler_run(rcycler_run)
     self.assertIsInstance(pcycler_run, ProcessedCyclerRun)
     # Ensure barcode/protocol are passed
     self.assertEqual(pcycler_run.barcode, "0001BC")
     self.assertEqual(pcycler_run.protocol, "PredictionDiagnostics_000109.000")
     self.assertEqual(pcycler_run.channel_id, 10)
Пример #6
0
def memory_profile(s3_objs=None):
    """
    Function for memory profiling pipelines with s3_objs.

    Args:
        s3_objs ([str]): list of s3_objs in the kitware d3batt
            publication s3 bucket.

    """
    s3_objs = s3_objs or MEMORY_PROFILE_S3_OBJS

    # Cache s3 objects
    cache_s3_objs(s3_objs, filter_existing_files=True)

    with ScratchDir("."):
        # Copy all pre-defined s3 objects
        for obj_name in s3_objs:
            shutil.copy(os.path.join(S3_CACHE, obj_name), ".")

        # Snip data path prefix
        data_paths = [
            os.path.basename(obj) for obj in s3_objs if "Metadata" not in obj
        ]

        # Validation
        # validator = ValidatorBeep()
        # validator.validate_from_paths(data_paths)

        # Data structuring
        raw_cycler_runs = [
            RawCyclerRun.from_file(data_path) for data_path in data_paths
        ]
        processed_cycler_runs = [
            ProcessedCyclerRun.from_raw_cycler_run(raw_cycler_run)
            for raw_cycler_run in raw_cycler_runs
        ]

        # Featurization
        predictors = [
            DegradationPredictor.init_full_model(processed_cycler_run)
            for processed_cycler_run in processed_cycler_runs
        ]

        # Prediction
        [
            DegradationModel.init_full_model().predict(predictor)
            for predictor in predictors
        ]
Пример #7
0
    def test_to_binary(self):
        pcycler_run = loadfn(self.pcycler_run_file)
        with ScratchDir('.'):
            pcycler_run.save_numpy_binary("test")
            loaded = ProcessedCyclerRun.load_numpy_binary("test")

        self.assertTrue(
            np.allclose(pcycler_run.summary[pcycler_run.SUMMARY_COLUMN_ORDER].values,
                        loaded.summary.values))

        self.assertTrue(
            np.allclose(pcycler_run.cycles_interpolated[pcycler_run.CYCLES_INTERPOLATED_COLUMN_ORDER].values,
                        loaded.cycles_interpolated.values))

        for attribute in pcycler_run.METADATA_ATTRIBUTE_ORDER:
            self.assertEqual(getattr(pcycler_run, attribute), getattr(loaded, attribute))
Пример #8
0
 def test_diagnostic_feature_generation(self):
     os.environ['BEEP_ROOT'] = TEST_FILE_DIR
     maccor_file_w_parameters = os.path.join(
         TEST_FILE_DIR, "PredictionDiagnostics_000136_00002D.037")
     raw_run = RawCyclerRun.from_file(maccor_file_w_parameters)
     v_range, resolution, nominal_capacity, full_fast_charge, diagnostic_available = \
         raw_run.determine_structuring_parameters()
     pcycler_run = ProcessedCyclerRun.from_raw_cycler_run(
         raw_run, diagnostic_available=diagnostic_available)
     predictor = DegradationPredictor.init_full_model(
         pcycler_run,
         predict_only=False,
         mid_pred_cycle=11,
         final_pred_cycle=12,
         diagnostic_features=True)
     diagnostic_feature_label = predictor.feature_labels[-1]
     self.assertEqual(diagnostic_feature_label,
                      "median_diagnostic_cycles_discharge_capacity")
     np.testing.assert_almost_equal(
         predictor.X[diagnostic_feature_label][0], 4.2327690032, decimal=8)
Пример #9
0
 def test_auto_load(self):
     loaded = ProcessedCyclerRun.auto_load(self.arbin_file)
     self.assertIsInstance(loaded, ProcessedCyclerRun)
Пример #10
0
 def test_from_raw_cycler_run_neware(self):
     rcycler_run = RawCyclerRun.from_file(self.neware_file)
     pcycler_run = ProcessedCyclerRun.from_raw_cycler_run(rcycler_run)
     self.assertIsInstance(pcycler_run, ProcessedCyclerRun)