|
|
|
@ -76,7 +76,40 @@ def parse_contents(contents, filename):
|
|
|
|
|
# Round dataframe to save disk space
|
|
|
|
|
df = df.round(1)
|
|
|
|
|
|
|
|
|
|
return df.to_json(orient='table')
|
|
|
|
|
# Create dataframe for statistics
|
|
|
|
|
stats = pd.DataFrame(columns=range(15))
|
|
|
|
|
|
|
|
|
|
# Create datafrae for energy spectrum
|
|
|
|
|
f = np.arange(0, 2.5, step=0.01)
|
|
|
|
|
dfs = pd.DataFrame(index=f)
|
|
|
|
|
|
|
|
|
|
for col in df.columns:
|
|
|
|
|
t = df.index.values[:, np.newaxis]
|
|
|
|
|
x = df[[col]].values
|
|
|
|
|
|
|
|
|
|
# Get spectral statistics
|
|
|
|
|
xx = wo.mat2timeseries(np.hstack([t, x]))
|
|
|
|
|
S = xx.tospecdata()
|
|
|
|
|
values, _, keys = S.characteristic(range(15))
|
|
|
|
|
S.freqtype = 'f'
|
|
|
|
|
|
|
|
|
|
# Interpolate
|
|
|
|
|
dfs[col] = np.interp(f, S.args, S.data)
|
|
|
|
|
|
|
|
|
|
# Update column names
|
|
|
|
|
if stats.columns[0] == 0:
|
|
|
|
|
stats.columns = keys
|
|
|
|
|
|
|
|
|
|
# Add spectral values to dataframe
|
|
|
|
|
stats.loc[col, keys] = values
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_data = {}
|
|
|
|
|
json_data['timeseries'] = df.to_json(orient='table')
|
|
|
|
|
json_data['spectrum'] = dfs.to_json(orient='table')
|
|
|
|
|
json_data['statistics'] = stats.to_json(orient='table')
|
|
|
|
|
|
|
|
|
|
return json.dumps(json_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.callback(Output('json-storage', 'children'), [
|
|
|
|
@ -94,7 +127,7 @@ def read_json_data(json_data):
|
|
|
|
|
if json_data is None:
|
|
|
|
|
return html.Div([])
|
|
|
|
|
|
|
|
|
|
df = pd.read_json(json_data, orient='table')
|
|
|
|
|
df = pd.read_json(json.loads(json_data)['timeseries'], orient='table')
|
|
|
|
|
ts = []
|
|
|
|
|
for col in df.columns:
|
|
|
|
|
trace = go.Scatter(x=df.index, y=df[col], name=col, opacity=0.8)
|
|
|
|
@ -107,29 +140,12 @@ def read_json_data(json_data):
|
|
|
|
|
'layout': layout
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
# Create spectral dataframe
|
|
|
|
|
dfs = pd.DataFrame(columns=range(15))
|
|
|
|
|
|
|
|
|
|
dfs = pd.read_json(json.loads(json_data)['spectrum'],
|
|
|
|
|
orient='table')
|
|
|
|
|
spec = []
|
|
|
|
|
for col in df.columns:
|
|
|
|
|
t = df.index.values[:, np.newaxis]
|
|
|
|
|
x = df[[col]].values
|
|
|
|
|
|
|
|
|
|
# Get spectral statistics
|
|
|
|
|
xx = wo.mat2timeseries(np.hstack([t, x]))
|
|
|
|
|
S = xx.tospecdata()
|
|
|
|
|
values, _, keys = S.characteristic(range(15))
|
|
|
|
|
S.freqtype = 'f'
|
|
|
|
|
|
|
|
|
|
# Update column names
|
|
|
|
|
if dfs.columns[0] == 0:
|
|
|
|
|
dfs.columns = keys
|
|
|
|
|
|
|
|
|
|
# Add spectral values to dataframe
|
|
|
|
|
dfs.loc[col, keys] = values
|
|
|
|
|
|
|
|
|
|
for col in dfs.columns:
|
|
|
|
|
# Plot energy spectrum
|
|
|
|
|
trace = go.Scatter(x=S.args, y=S.data, name=col, opacity=0.8)
|
|
|
|
|
trace = go.Scatter(x=dfs.index, y=dfs[col], name=col, opacity=0.8)
|
|
|
|
|
spec.append(trace)
|
|
|
|
|
|
|
|
|
|
graph_energy = dcc.Graph(id='energy-spectrum',
|
|
|
|
@ -145,6 +161,9 @@ def read_json_data(json_data):
|
|
|
|
|
# Add location column
|
|
|
|
|
dfs['location'] = dfs.index
|
|
|
|
|
|
|
|
|
|
# Round spectral values
|
|
|
|
|
dfs = dfs.round(1)
|
|
|
|
|
|
|
|
|
|
variables = {
|
|
|
|
|
'location': '',
|
|
|
|
|
'Hm0': '◊',
|
|
|
|
|