arcan3 commited on
Commit
715f3b0
·
1 Parent(s): 29afbe3

added plot colors and the gap size issue

Browse files
Files changed (3) hide show
  1. app.py +1 -3
  2. funcs/plot_func.py +4 -2
  3. funcs/processor.py +1 -5
app.py CHANGED
@@ -19,12 +19,10 @@ with gr.Blocks(title='Cabasus') as cabasus_sensor:
19
  repeat_process = gr.Button('Restart process')
20
  with gr.Row():
21
  leg_dropdown = gr.Dropdown(choices=['GZ1', 'GZ2', 'GZ3', 'GZ4'], label='select leg', value='GZ1')
 
22
  with gr.Row():
23
  plot_box_leg = gr.Plot(label="Filtered Signal Plot")
24
  plot_box_overlay = gr.Plot(label="Overlay Signal Plot")
25
-
26
- with gr.Row():
27
- slice_slider = gr.Slider(minimum=1, maximum=300, label='Current slice', step=1)
28
 
29
  with gr.Row():
30
  plot_slice_leg = gr.Plot(label="Sliced Signal Plot")
 
19
  repeat_process = gr.Button('Restart process')
20
  with gr.Row():
21
  leg_dropdown = gr.Dropdown(choices=['GZ1', 'GZ2', 'GZ3', 'GZ4'], label='select leg', value='GZ1')
22
+ slice_slider = gr.Slider(minimum=1, maximum=300, label='Current slice', step=1)
23
  with gr.Row():
24
  plot_box_leg = gr.Plot(label="Filtered Signal Plot")
25
  plot_box_overlay = gr.Plot(label="Overlay Signal Plot")
 
 
 
26
 
27
  with gr.Row():
28
  plot_slice_leg = gr.Plot(label="Sliced Signal Plot")
funcs/plot_func.py CHANGED
@@ -39,7 +39,7 @@ def plot_sensor_data_from_json(json_file, sensor, slice_select=1):
39
 
40
  # Plot the sensor data
41
  fig, ax = plt.subplots(figsize=(12, 6))
42
- ax = plt.plot(data['time'].to_list(), data[sensor].to_list())
43
 
44
  df_temp = data[data['slice selection'] == int(slice_select)].reset_index()
45
  y = [np.NaN]*((int(slice_select)-1)*len(df_temp[sensor].to_list())) + df_temp[sensor].to_list() + [np.NaN]*((len(slices) - int(slice_select))*len(df_temp[sensor].to_list()))
@@ -152,8 +152,10 @@ def plot_other_sensor_with_same_timestamp(json_file, sensor, slice_select):
152
  # Create a DataFrame with the sensor data
153
  data = pd.DataFrame({'data': sensor_data, 'sensor': slice_item, 'time': timestamps})
154
 
 
 
155
  fig, ax = plt.subplots(figsize=(12, 6))
156
- ax = sns.lineplot(data, x='time', y='data', hue='sensor')
157
 
158
  plt.xlabel("Timestamp")
159
  plt.ylabel(sensor)
 
39
 
40
  # Plot the sensor data
41
  fig, ax = plt.subplots(figsize=(12, 6))
42
+ ax = plt.plot(data['time'].to_list(), data[sensor].to_list(), '-b')
43
 
44
  df_temp = data[data['slice selection'] == int(slice_select)].reset_index()
45
  y = [np.NaN]*((int(slice_select)-1)*len(df_temp[sensor].to_list())) + df_temp[sensor].to_list() + [np.NaN]*((len(slices) - int(slice_select))*len(df_temp[sensor].to_list()))
 
152
  # Create a DataFrame with the sensor data
153
  data = pd.DataFrame({'data': sensor_data, 'sensor': slice_item, 'time': timestamps})
154
 
155
+ sensor_unique = sorted(list(data.sensor.unique()), reverse=True)
156
+
157
  fig, ax = plt.subplots(figsize=(12, 6))
158
+ ax = sns.lineplot(data, x='time', y='data', hue='sensor', hue_order=sensor_unique)
159
 
160
  plt.xlabel("Timestamp")
161
  plt.ylabel(sensor)
funcs/processor.py CHANGED
@@ -69,7 +69,7 @@ def process_data(input_file, slice_size=64, min_slice_size=16, sample_rate=20, w
69
  if not no_significant_change_index.empty:
70
  # Save the data up to the point where no significant change appears in all channels
71
  data = data.loc[:no_significant_change_index[0]]
72
- return None, None, f'Warning: gap of {gap_size} ms found at line {gap_start_index}', None, None, None, None, None
73
 
74
  # Save the resulting DataFrame to a new file
75
  data.to_csv('output.csv', sep=";", na_rep="NaN", float_format="%.0f")
@@ -80,8 +80,4 @@ def process_data(input_file, slice_size=64, min_slice_size=16, sample_rate=20, w
80
  sensor_fig, slice_fig, get_all_slice = plot_sensor_data_from_json(file, "GZ1")
81
  overlay_fig = plot_overlay_data_from_json(file, ["GZ1", "GZ2", "GZ3", "GZ4"], use_precise_timestamp=True)
82
 
83
- # plot all the curves from the timestep
84
-
85
-
86
-
87
  return 'output.csv', file, f'{len_}', sensor_fig, overlay_fig, gr.Slider.update(interactive=True, maximum=len_, minimum=1, value=1), slice_fig, get_all_slice
 
69
  if not no_significant_change_index.empty:
70
  # Save the data up to the point where no significant change appears in all channels
71
  data = data.loc[:no_significant_change_index[0]]
72
+ return None, None, f'Warning: Significantly shortened > check the recordings', None, None, None, None, None
73
 
74
  # Save the resulting DataFrame to a new file
75
  data.to_csv('output.csv', sep=";", na_rep="NaN", float_format="%.0f")
 
80
  sensor_fig, slice_fig, get_all_slice = plot_sensor_data_from_json(file, "GZ1")
81
  overlay_fig = plot_overlay_data_from_json(file, ["GZ1", "GZ2", "GZ3", "GZ4"], use_precise_timestamp=True)
82
 
 
 
 
 
83
  return 'output.csv', file, f'{len_}', sensor_fig, overlay_fig, gr.Slider.update(interactive=True, maximum=len_, minimum=1, value=1), slice_fig, get_all_slice