From 9f270b6364bd47ed74575252b34045c78689d644 Mon Sep 17 00:00:00 2001 From: "etienne.frank" Date: Fri, 7 Sep 2018 14:31:10 +0200 Subject: [PATCH 1/2] Fix comments typo in extraction --- explore_data.py | 4 ++-- extraction/extract_item_into_dict.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/explore_data.py b/explore_data.py index b101d63..d56ad20 100644 --- a/explore_data.py +++ b/explore_data.py @@ -116,10 +116,10 @@ def impedance_iteration(impedance_items, filename): path = "output_graphs/impedance/degree" + str(ambiant_temp) sense_current = item[3][0][0][0][0] # Current in sense branch (Amps)| Complexes - battery_current = item[3][0][0][1][0] # urrent in battery branch (Amps)| Complexes + battery_current = item[3][0][0][1][0] # Current in battery branch (Amps)| Complexes current_ratio = item[3][0][0][2][0] # Ratio of the above currents| Complexes battery_impedance = item[3][0][0][3] # Battery impedance (Ohms) computed from raw data| Complexes but multiple array of 1 complexe - rectified_impedance = item[3][0][0][4] # alibrated and smoothed battery impedance (Ohms)| Complexes but multiple array of 1 complexe + rectified_impedance = item[3][0][0][4] # Calibrated and smoothed battery impedance (Ohms)| Complexes but multiple array of 1 complexe re = item[3][0][0][5][0][0] # Estimated electrolyte resistance (Ohms)| float_ rct = item[3][0][0][6][0][0] # Estimated charge transfer resistance (Ohms)| float_ diff --git a/extraction/extract_item_into_dict.py b/extraction/extract_item_into_dict.py index 1e3ad38..d078102 100644 --- a/extraction/extract_item_into_dict.py +++ b/extraction/extract_item_into_dict.py @@ -28,7 +28,7 @@ def extract_charge_from_item(item): dict_item = {} dict_item["test_type"] = item[0][0] # charge impedence discharge - dict_item["ambiant_temp"] = _format_temperature(item[1][0][0]) # temperature: 4 ~24 ~43 + dict_item["ambient_temp"] = _format_temperature(item[1][0][0]) # temperature: 4 ~24 ~43 dict_item["datetime"] = _convert_matlab_datetime_vector_to_utc(item[2][0]) dict_item["voltage_measured"] = item[3][0][0][0][0] # Battery terminal voltage (Volts) floats @@ -46,7 +46,7 @@ def extract_discharge_from_item(item): dict_item = {} dict_item["test_type"] = item[0][0] # charge impedence discharge - dict_item["ambiant_temp"] = _format_temperature(item[1][0][0]) # temperature: 4 ~24 ~43 + dict_item["ambient_temp"] = _format_temperature(item[1][0][0]) # temperature: 4 ~24 ~43 dict_item["datetime"] = _convert_matlab_datetime_vector_to_utc(item[2][0]) dict_item["voltage_measured"] = item[3][0][0][0][0] # Battery terminal voltage (Volts) floats @@ -64,15 +64,16 @@ def extract_discharge_from_item(item): def extract_impedance_from_item(item): dict_item = {} - dict_item["test_type"] = item[0][0] # charge impedence discharge - dict_item["ambiant_temp"] = _format_temperature(item[1][0][0]) # temperature: 4 ~24 ~43 + # TODO maybe split complexe into two arrays (Re and Im) + dict_item["test_type"] = item[0][0] # Charge impedence discharge + dict_item["ambient_temp"] = _format_temperature(item[1][0][0]) # Temperature: 4 ~24 ~43 dict_item["datetime"] = _convert_matlab_datetime_vector_to_utc(item[2][0]) dict_item["sense_current"] = item[3][0][0][0][0] # Current in sense branch (Amps)| Complexes - dict_item["battery_current"] = item[3][0][0][1][0] # urrent in battery branch (Amps)| Complexes + dict_item["battery_current"] = item[3][0][0][1][0] # Current in battery branch (Amps)| Complexes dict_item["current_ratio"] = item[3][0][0][2][0] # Ratio of the above currents| Complexes dict_item["battery_impedance"] = item[3][0][0][3] # Battery impedance (Ohms) computed from raw data| Complexes but multiple array of 1 complexe - dict_item["rectified_impedance"] = item[3][0][0][4] # alibrated and smoothed battery impedance (Ohms)| Complexes but multiple array of 1 complexe + dict_item["rectified_impedance"] = item[3][0][0][4] # Calibrated and smoothed battery impedance (Ohms)| Complexes but multiple array of 1 complexe dict_item["re"] = item[3][0][0][5][0][0] # Estimated electrolyte resistance (Ohms)| float_ dict_item["rct"] = item[3][0][0][6][0][0] # Estimated charge transfer resistance (Ohms)| float_ -- GitLab From 216e29a307b5f7cdf7802b56a2f8c081435db485 Mon Sep 17 00:00:00 2001 From: "etienne.frank" Date: Fri, 7 Sep 2018 14:31:57 +0200 Subject: [PATCH 2/2] Explore a bit with the example file --- example_retrieve_battery_data.py | 54 +++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/example_retrieve_battery_data.py b/example_retrieve_battery_data.py index 27a4d2f..ea68b87 100644 --- a/example_retrieve_battery_data.py +++ b/example_retrieve_battery_data.py @@ -3,6 +3,11 @@ from glob import glob from extraction.retrieve_battery_data import extract_charge_discharge_impedance +def print_length(items, key): + mesures = [x[key] for x in items] + len_measures = [len(x) for x in mesures] + print(sum(len_measures)) + def example_how_to_use_this_module(): all_folders_containing_batteries_mat_files = [ @@ -14,18 +19,43 @@ def example_how_to_use_this_module(): "./data/BatteryAgingARC-FY08Q4/", ] - filepaths = [y for x in os.walk("./data/") for y in glob(os.path.join(x[0], '*.mat'))] - filepaths = sorted(filepaths) - - # TODO warning for for the [:1] - for filepath in filepaths[:]: - print(filepath) - charge_items, discharge_items, impedance_items = extract_charge_discharge_impedance(filepath) - print(len(charge_items[0]["voltage_measured"]) == len(charge_items[1]["voltage_measured"])) - print(len(charge_items[0]["voltage_measured"]) == len(discharge_items[0]["voltage_measured"])) - print(len(charge_items[0]["voltage_measured"])) - print(len(charge_items[1]["voltage_measured"])) - print(len(discharge_items[0]["voltage_measured"])) + for root in all_folders_containing_batteries_mat_files: + print("----------------------------") + # filepaths = [y for x in os.walk("./data/") for y in glob(os.path.join(x[0], '*.mat'))] + filepaths = [y for x in os.walk(root) for y in glob(os.path.join(x[0], '*.mat'))] + filepaths = sorted(filepaths) + + for filepath in filepaths[:]: + print(filepath) + charge_items, discharge_items, impedance_items = extract_charge_discharge_impedance(filepath) + + ## EXPLORATION PART + # print("charges") + # print_length(charge_items, "voltage_measured") + # print_length(charge_items, "current_measured") + # print_length(charge_items, "temperature_measured") + # print_length(charge_items, "current_charge") + # print_length(charge_items, "voltage_charge") + + # print("discharges") + # print_length(discharge_items, "voltage_measured") + # print_length(discharge_items, "current_measured") + # print_length(discharge_items, "temperature_measured") + # print_length(discharge_items, "current_charge") + # print_length(discharge_items, "voltage_charge") + + # print("impedance") + print_length(impedance_items, "sense_current") + print_length(impedance_items, "battery_current") + print_length(impedance_items, "current_ratio") + print_length(impedance_items, "battery_impedance") + print_length(impedance_items, "rectified_impedance") + + # print(len() == len(charge_items[1]["voltage_measured"])) + # print(len(charge_items[0]["voltage_measured"]) == len(discharge_items[0]["voltage_measured"])) + # print(len(charge_items[0]["voltage_measured"])) + # print(len(charge_items[1]["voltage_measured"])) + # print(len(discharge_items[0]["voltage_measured"])) if __name__ == "__main__": -- GitLab