示例#1
0
    def test_from_formation_txt(self):
        biologic_file = os.path.join(
            TEST_FILE_DIR, "raw", "test_FormRegu_000100_CG1_Append_short.txt"
        )
        dp = BiologicDatapath.from_file(biologic_file)

        self.assertTrue(
            {
                "cycle_index",
                "step_index",
                "voltage",
                "current",
                "discharge_capacity",
                "charge_capacity",
                "data_point",
                "charge_energy",
                "discharge_energy",
            }
            < set(dp.raw_data.columns),
        )

        dp.structure(v_range=[1.0, 4.4])

        self.assertAlmostEqual(dp.structured_summary["charge_capacity"].tolist()[0], 0.2673875, 6)
        self.assertAlmostEqual(dp.structured_summary["discharge_capacity"].tolist()[0], 0.2573631, 6)
        self.assertEqual(dp.structured_summary["date_time_iso"].iloc[0], "2022-01-18T22:09:40.640000+00:00")
        self.assertEqual(dp.structured_summary["date_time_iso"].iloc[1], "2022-01-22T09:15:10.020000+00:00")
        self.assertAlmostEqual(dp.raw_data["test_time"].min(), 0, 3)
        self.assertAlmostEqual(dp.raw_data["test_time"].max(), 784864.55, 3)
        self.assertAlmostEqual(dp.structured_data["test_time"].min(), 259220.283, 3)
        self.assertAlmostEqual(dp.structured_data["test_time"].max(), 784853.102, 3)
        self.assertGreater(dp.structured_summary["discharge_capacity"].tolist()[4], 0)
        self.assertGreater(dp.structured_summary["discharge_capacity"].tolist()[20], 0)
        self.assertGreater(dp.structured_summary["discharge_capacity"].tolist()[40], 0)
示例#2
0
    def test_from_file(self):

        biologic_file = os.path.join(
            TEST_FILE_DIR, "raw", "biologic_test_file_short.mpt"
        )
        dp = BiologicDatapath.from_file(biologic_file)

        self.assertTrue(
            {
                "cycle_index",
                "step_index",
                "voltage",
                "current",
                "discharge_capacity",
                "charge_capacity",
                "data_point",
                "charge_energy",
                "discharge_energy",
            }
            < set(dp.raw_data.columns),
        )

        self.assertEqual(
            {"_today_datetime", "filename", "barcode", "protocol", "channel_id"},
            set(dp.metadata.raw.keys()),
        )
示例#3
0
 def test_mapping_file(self):
     biologic_file = os.path.join(
         TEST_FILE_DIR, "raw", "test_loopsnewoutput_MB_CE1_short10k.txt"
     )
     biotest_file = os.path.join(TEST_FILE_DIR, "BioTest_000001.000.technique_1_cycle_rules.json")
     dp = BiologicDatapath.from_file(biologic_file, mapping_file=biotest_file)
     self.assertIn("cycle_index", dp.raw_data.columns)
     self.assertListEqual([1, 2, 3], dp.raw_data["cycle_index"].unique().tolist())
示例#4
0
def auto_load(filename):
    """Load any supported raw battery cycler file to the correct Datapath automatically.

    Matches raw file patterns to the correct datapath and returns the datapath object.

    Example:
        auto_load("2017-05-09_test-TC-contact_CH33.csv")

        >>> <ArbinDatapath object>

        auto_load("PreDiag_000287_000128short.092")

        >>> <MaccorDatapath object>

    Args:
        filename (str, Pathlike): string corresponding to battery cycler file filename.

    Returns:
        (beep.structure.base.BEEPDatapath): The datapath child class corresponding to this file.

    """
    if re.match(ARBIN_CONFIG["file_pattern"], filename) or re.match(
            FastCharge_CONFIG["file_pattern"], filename):
        return ArbinDatapath.from_file(filename)
    elif re.match(MACCOR_CONFIG["file_pattern"], filename) or re.match(
            xTesladiag_CONFIG["file_pattern"], filename):
        return MaccorDatapath.from_file(filename)
    elif re.match(INDIGO_CONFIG["file_pattern"], filename):
        return IndigoDatapath.from_file(filename)
    elif re.match(BIOLOGIC_CONFIG["file_pattern"], filename):
        return BiologicDatapath.from_file(filename)
    elif re.match(NEWARE_CONFIG["file_pattern"], filename):
        return NewareDatapath.from_file(filename)
    elif re.match(BatteryArchiveDatapath.FILE_PATTERN, filename):
        return BatteryArchiveDatapath.from_file(filename)
    else:
        raise ValueError(
            "{} does not match any known file pattern".format(filename))
示例#5
0
    def test_from_csv(self):

        biologic_file = os.path.join(
            TEST_FILE_DIR, "raw", "test_loopsnewoutput_MB_CE1_short10k.csv"
        )
        dp = BiologicDatapath.from_file(biologic_file)

        self.assertTrue(
            {
                "cycle_index",
                "step_index",
                "voltage",
                "current",
                "discharge_capacity",
                "charge_capacity",
                "data_point",
                "charge_energy",
                "discharge_energy",
            }
            < set(dp.raw_data.columns),
        )

        self.assertEqual(
            {"_today_datetime", "filename", "barcode", "protocol", "channel_id"},
            set(dp.metadata.raw.keys()),
        )

        dp.structure(v_range=[3.0, 4.4])

        self.assertAlmostEqual(dp.structured_summary["charge_capacity"].tolist()[0], 1.4618750, 6)
        self.assertAlmostEqual(dp.structured_summary["discharge_capacity"].tolist()[0], 2.324598, 6)
        self.assertEqual(dp.structured_summary["date_time_iso"].iloc[0], "2021-05-05T22:36:22.757000+00:00")
        self.assertEqual(dp.structured_summary["date_time_iso"].iloc[1], "2021-05-06T09:44:45.604000+00:00")
        self.assertAlmostEqual(dp.raw_data["test_time"].min(), 0, 3)
        self.assertAlmostEqual(dp.raw_data["test_time"].max(), 102040.77, 3)
        # self.assertAlmostEqual(dp.structured_data["test_time"].min(), 13062.720560, 3)
        self.assertAlmostEqual(dp.structured_data["test_time"].min(), 101.089, 2)
        self.assertAlmostEqual(dp.structured_data["test_time"].max(), 101972.885, 3)