コード例 #1
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
        ]
コード例 #2
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)