Correctly load wave statistics into table

master
Dan Howe 5 years ago
parent 36cd0a68cc
commit 8b0022c054

@ -103,7 +103,6 @@ def parse_contents(contents, filename):
# Add spectral values to dataframe # Add spectral values to dataframe
stats.loc[col, keys] = values stats.loc[col, keys] = values
json_data = {} json_data = {}
json_data['timeseries'] = df.to_json(orient='table') json_data['timeseries'] = df.to_json(orient='table')
json_data['spectrum'] = dfs.to_json(orient='table') json_data['spectrum'] = dfs.to_json(orient='table')
@ -140,8 +139,7 @@ def read_json_data(json_data):
'layout': layout 'layout': layout
}) })
dfs = pd.read_json(json.loads(json_data)['spectrum'], dfs = pd.read_json(json.loads(json_data)['spectrum'], orient='table')
orient='table')
spec = [] spec = []
for col in dfs.columns: for col in dfs.columns:
# Plot energy spectrum # Plot energy spectrum
@ -158,11 +156,13 @@ def read_json_data(json_data):
} }
}) })
stats = pd.read_json(json.loads(json_data)['statistics'], orient='table')
# Add location column # Add location column
dfs['location'] = dfs.index stats['location'] = stats.index
# Round spectral values # Round spectral values
dfs = dfs.round(1) stats = stats.round(1)
variables = { variables = {
'location': '', 'location': '',
@ -178,13 +178,13 @@ def read_json_data(json_data):
'name': [val, key], 'name': [val, key],
'id': key 'id': key
} for key, val in variables.items()], } for key, val in variables.items()],
data=dfs.to_dict('records'), data=stats.to_dict('records'),
editable=False, editable=False,
sort_action='native', sort_action='native',
sort_mode='multi', sort_mode='multi',
row_selectable='multi', row_selectable='multi',
row_deletable=False, row_deletable=False,
selected_rows=np.arange(dfs.shape[0]), selected_rows=np.arange(stats.shape[0]),
style_as_list_view=True, style_as_list_view=True,
style_cell={ style_cell={
'minWidth': '100px', 'minWidth': '100px',

Loading…
Cancel
Save