diff --git a/software/management/dashboard/processing.py b/software/management/dashboard/processing.py index de2eb57e..4d438a60 100644 --- a/software/management/dashboard/processing.py +++ b/software/management/dashboard/processing.py @@ -22,6 +22,7 @@ def plot_data(title, x_axis_label, y_axis_label, x_axis_data, y_axis_data): axis.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S')) axis.xaxis.set_label_text(x_axis_label) axis.yaxis.set_label_text(y_axis_label) + axis.figure.autofmt_xdate(rotation=45, bottom=0.3) plt.plot(x_axis_data, y_axis_data) plt.show() @@ -34,7 +35,7 @@ def get_voltage_time_series(data, tottag_label): plot_data('Battery Voltage for {}'.format(tottag_label), 'Date and Time', 'Voltage (mV)', timestamps, voltages) def get_motion_time_series(data, tottag_label): - motions = data.loc['m'].fillna(method='pad') + motions = data.loc['m'].ffill() timestamps = mdates.date2num([datetime.fromtimestamp(ts) for ts in motions.keys()]) plot_data('Motion Status for {}'.format(tottag_label), 'Date and Time', 'Motion Status', timestamps, motions) diff --git a/software/management/dashboard/tottag.py b/software/management/dashboard/tottag.py index a040284f..62702c82 100644 --- a/software/management/dashboard/tottag.py +++ b/software/management/dashboard/tottag.py @@ -116,15 +116,16 @@ def unpack_experiment_details(data): 'labels': experiment_struct[(6+6*MAX_NUM_DEVICES):], } -def process_tottag_data(from_uid, storage_directory, details, data): +def process_tottag_data(from_uid, storage_directory, details, data, save_raw_file=False): uid_to_labels = defaultdict(lambda: 'Unknown') for i in range(details['num_devices']): label = details['labels'][i].decode().rstrip('\x00') uid_to_labels[int(details['uids'][i][0])] = label if label else details['uids'][i][0] i = 0 log_data = defaultdict(dict) - with open(os.path.join(storage_directory, uid_to_labels[from_uid] + '.ttg'), 'wb') as file: - file.write(data) + if save_raw_file: + with open(os.path.join(storage_directory, uid_to_labels[from_uid] + '.ttg'), 'wb') as file: + file.write(data) while i < len(data): timestamp = struct.unpack('