Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
#64 --- implementing Experiment format for .mpr
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrowlinson committed Apr 20, 2023
1 parent 37810d2 commit 96b859f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions harvester/harvester/harvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def import_file(core_path: str, file_path: str) -> bool:
'task': 'import',
'status': 'in_progress',
'data': [v for v in column_data.values()],
'labels': tuple(input_file.get_data_labels()),
'test_date': serialize_datetime(core_metadata['Date of Test'])
})
if report is None:
Expand Down
37 changes: 30 additions & 7 deletions harvester/harvester/parse/biologic_input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,46 @@ def get_data_labels(self):
3: 'Rest',
}
last_Ns_change = 1

column_names = self.mpr_file.data.dtype.names
time_col = next((i for i, c in enumerate(column_names) if c.startswith("time")), 3)
cont_col = next((i for i, c in enumerate(column_names) if c.startswith("control")), 4)
prev_time = 0

for i in range(len(self.mpr_file.data)):
last_mode = modes[i-1]
last_Ns = self.mpr_file.data[i-1][Ns_index]
Ns_change = Ns_changes[i]
if Ns_change:
time = self.mpr_file.data[i][time_col]
mode_label = mode_labels.get(last_mode)
if mode_label.casefold() == "rest":
experiment_label = "Rest "
else:
control = self.mpr_file.data[i - 1][cont_col]
if control > 0:
experiment_label = "Charge "
else:
experiment_label = "Discharge "

is_const_curr = mode_label.casefold() == "cc"
experiment_label += f"at {control} {'mA' if is_const_curr else 'V'} "
experiment_label += f"for {time - prev_time} seconds"

if last_mode in mode_labels:
yield (
'Ns_{}_{}'.format(last_Ns,
mode_labels[last_mode]),
(last_Ns_change, i-1)
data_label = (
f"Ns_{last_Ns}_{mode_label}", (last_Ns_change, i - 1), experiment_label
)
else:
yield (
'Ns_{}'.format(last_Ns),
(last_Ns_change, i-1)
data_label = (
f"Ns_{last_Ns}", (last_Ns_change, i - 1), experiment_label
)

last_Ns_change = i
prev_time = time

yield data_label


def load_metadata(self):
file_path = self.file_path
Expand Down
8 changes: 4 additions & 4 deletions harvester/harvester/parse/input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ def tsv_format(value):
raise

def load_data(self, file_path, available_desired_columns):
raise UnsupportedFileTypeError
raise UnsupportedFileTypeError()

def get_data_labels(self):
raise UnsupportedFileTypeError
raise UnsupportedFileTypeError()

def get_file_column_to_standard_column_mapping(self):
"""
returns map of file column name strings to column id numbers
"""
raise UnsupportedFileTypeError
raise UnsupportedFileTypeError()

def load_metadata(self):
raise UnsupportedFileTypeError
raise UnsupportedFileTypeError()

0 comments on commit 96b859f

Please sign in to comment.