Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for eventbrowser #557

Merged
merged 61 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6506f46
Merge branch 'develop' of https://github.com/nu-radio/NuRadioMC into …
Nov 9, 2021
c5fb755
add option to correct for cable delays in channelAddCableDelay
Nov 9, 2021
ecd37b7
add relative_position option for devices
Nov 9, 2021
b7d7654
get relative position for devices
Nov 9, 2021
2d35435
Merge branch 'device_relposition' of https://github.com/nu-radio/NuRa…
Nov 10, 2021
ef9c2b3
Merge branch 'adapt_channelAddCableDelay' of https://github.com/nu-ra…
Nov 10, 2021
a4922d5
add sphericalwavefitter for pulser position
Nov 10, 2021
427f80b
Merge branch 'rnog_eventbrowser' of https://github.com/nu-radio/NuRad…
Nov 10, 2021
aef5139
Merge branch 'adapt_channelAddCableDelay' of https://github.com/nu-ra…
Nov 10, 2021
3a769fc
add steering file for rnog reconstruction and corresponding data
Nov 10, 2021
9698f87
add rnog example
Nov 10, 2021
3dd7ea3
adapt range spherical wave fitter
Nov 10, 2021
5d50f4d
change channels used for reco in example
Nov 10, 2021
6084214
Merge branch 'RNOG_data_example' of github.com:nu-radio/NuRadioMC int…
shallmann Nov 16, 2021
d7c5f26
Merge remote-tracking branch 'origin/develop' into RNOG_data_example
shallmann Nov 16, 2021
dfd1288
optimizing single event readout
sjoerd-bouma Nov 16, 2021
5a3ea52
Merge branch 'develop' of https://github.com/nu-radio/NuRadioMC into …
Nov 16, 2021
71452eb
pull from develop
Nov 16, 2021
e64f4da
remove duplicated data
Nov 16, 2021
9cd6ffd
Merge branch 'RNOG_data_example' of github.com:nu-radio/NuRadioMC int…
shallmann Nov 17, 2021
6624ae3
Merge branch 'uproot_cleanup' of github.com:nu-radio/NuRadioMC into u…
shallmann Nov 17, 2021
1a68513
remove (tentatively) unnecessary split between header and combined
shallmann Nov 18, 2021
fccb035
added file and event lru_cache
sjoerd-bouma Nov 22, 2021
b5f1452
merge develop into rnog_eventbrowser
sjoerd-bouma Jul 4, 2022
a9d6002
reduce number of events in iterator (maybe solves memory issues on on…
sjoerd-bouma Jul 11, 2022
8eb627a
Singleton metaclass no longer alters class signature
sjoerd-bouma Aug 1, 2022
3206f32
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Sep 8, 2022
d999501
Merge branch 'rnog_eventbrowser' of github.com:nu-radio/NuRadioMC int…
sjoerd-bouma Sep 8, 2022
4cbe9f3
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Sep 14, 2022
973f14c
change trigger_time -> readout_time
sjoerd-bouma Sep 14, 2022
5e5e466
sort simulated electric fields in plot
sjoerd-bouma Nov 4, 2022
b124daf
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Feb 23, 2023
4ebb6f4
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Apr 25, 2023
3fca0f6
Merge branch 'add-rnog-noise-importer' of github.com:nu-radio/NuRadio…
sjoerd-bouma Apr 25, 2023
14c897a
update eventbrowser dataprovider
sjoerd-bouma Apr 26, 2023
d5b2af0
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma May 26, 2023
3eca1cd
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Jun 23, 2023
bbfafc2
use NuRadioMC conventions for FFT normalization
sjoerd-bouma Jun 24, 2023
f8e4239
update eventbrowser root (RNO-G) reader
sjoerd-bouma Jul 6, 2023
7c4e85a
hardcode sampling rate to 3.2 GHz for RNO-G
sjoerd-bouma Jul 18, 2023
43ea9a8
add toggle for log/linear scale to frequency spectra
sjoerd-bouma Jul 19, 2023
0f6a617
add log/linear toggle to frequency spectra
sjoerd-bouma Jul 24, 2023
cebd3cf
update dash version
sjoerd-bouma Jul 24, 2023
6f005c2
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Aug 4, 2023
9a4e21d
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Sep 13, 2023
94c95c6
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Sep 29, 2023
e3b6409
add thread-locking to prevent multiple file_handlers with same id
sjoerd-bouma Sep 29, 2023
3af7aac
make sure event ids are always initialised
sjoerd-bouma Sep 29, 2023
55d729a
explicitly cast slider positions to ints to avoid mysterious error
sjoerd-bouma Sep 29, 2023
83e4e6d
change to new RNO-G data reader for example
sjoerd-bouma Sep 29, 2023
95a80d1
add methods get_header, get_detector to wrapper to prevent errors
sjoerd-bouma Oct 19, 2023
e0b9f1f
add support for reading multiple files simultaneously
sjoerd-bouma Oct 25, 2023
213c22b
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Oct 25, 2023
a810b93
correctly label channels
sjoerd-bouma Oct 25, 2023
cdfcbf0
added readRNOGData wrapper for eventbrowser
sjoerd-bouma Oct 25, 2023
86ea3a3
merge eventbrowser dataproviders into one
sjoerd-bouma Oct 25, 2023
79cf646
identify file reader by file endings
sjoerd-bouma Oct 26, 2023
ba1e393
Merge branch 'develop' of github.com:nu-radio/NuRadioMC into rnog_eve…
sjoerd-bouma Nov 16, 2023
ba29dd2
recycle user_id=None
sjoerd-bouma Nov 16, 2023
57b7a7b
Update dataprovider.py
fschlueter Nov 20, 2023
31236bd
fix dropping of oldest user
sjoerd-bouma Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def update_sim_spectrum_plot(i_event, filename, signal_types, station_id, juser_
if sim_station is None:
return {}
fig = plotly.subplots.make_subplots(rows=1, cols=1)
for i_electric_field, electric_field in enumerate(sim_station.get_electric_fields()):
efields = list(sim_station.get_electric_fields())
efield_ids = [efield.get_unique_identifier() for efield in efields]
efields_sorted = [k[1] for k in sorted(zip(efield_ids, efields))]
for i_electric_field, electric_field in enumerate(efields_sorted):
if electric_field.get_parameter(efp.ray_path_type) in signal_types:
for polarization in range(1, 3):
fig.append_trace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def update_sim_trace_plot(i_event, filename, signal_types, station_id, juser_id)
if sim_station is None:
return {}
fig = plotly.subplots.make_subplots(rows=1, cols=1)
for i_electric_field, electric_field in enumerate(sim_station.get_electric_fields()):
efields = list(sim_station.get_electric_fields())
efield_ids = [efield.get_unique_identifier() for efield in efields]
efields_sorted = [k[1] for k in sorted(zip(efield_ids, efields))]
for i_electric_field, electric_field in enumerate(efields_sorted):
if electric_field.get_parameter(efp.ray_path_type) in signal_types:
for polarization in range(1, 3):
fig.append_trace(
Expand Down
31 changes: 14 additions & 17 deletions NuRadioReco/eventbrowser/apps/trace_plots/channel_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from NuRadioReco.utilities import units
from NuRadioReco.eventbrowser.default_layout import default_layout
import numpy as np
from dash import dcc
from dash import dcc, callback
from dash.dependencies import State
from NuRadioReco.eventbrowser.app import app
# from NuRadioReco.eventbrowser.app import app
import NuRadioReco.eventbrowser.dataprovider

provider = NuRadioReco.eventbrowser.dataprovider.DataProvider()
Expand All @@ -16,14 +16,16 @@
]


@app.callback(
@callback(
dash.dependencies.Output('channel-spectrum', 'figure'),
[dash.dependencies.Input('trigger-trace', 'children'),
dash.dependencies.Input('event-counter-slider', 'value'),
dash.dependencies.Input('filename', 'value'),
dash.dependencies.Input('station-id-dropdown', 'value')],
[State('user_id', 'children')])
def update_channel_spectrum(trigger, evt_counter, filename, station_id, juser_id):
[State('user_id', 'children'),
State('channel-spectrum-log-linear-switch', 'children')]
)
def update_channel_spectrum(trigger, evt_counter, filename, station_id, juser_id, yscale):
if filename is None or station_id is None:
return {}
user_id = json.loads(juser_id)
Expand All @@ -33,27 +35,22 @@ def update_channel_spectrum(trigger, evt_counter, filename, station_id, juser_id
station = evt.get_station(station_id)
fig = plotly.subplots.make_subplots(rows=1, cols=1)
for i, channel in enumerate(station.iter_channels()):
if channel.get_trace() is None:
spec = channel.get_frequency_spectrum()
if spec is None:
continue
tt = channel.get_times()
dt = tt[1] - tt[0]
if channel.get_trace() is None:
continue
trace = channel.get_trace()
ff = np.fft.rfftfreq(len(tt), dt)
spec = np.abs(np.fft.rfft(trace, norm='ortho'))
freqs = channel.get_frequencies()
fig.append_trace(plotly.graph_objs.Scatter(
x=ff / units.MHz,
y=spec / units.mV,
x=freqs / units.MHz,
y=np.abs(spec) / units.mV,
opacity=0.7,
marker={
'color': colors[i % len(colors)],
'line': {'color': colors[i % len(colors)]}
},
name='Channel {}'.format(i)
name='Channel {}'.format(channel.get_id())
), 1, 1)
fig['layout'].update(default_layout)
fig['layout']['legend']['uirevision'] = filename
fig['layout']['xaxis1'].update(title='frequency [MHz]')
fig['layout']['yaxis1'].update(title='amplitude [mV]')
fig['layout']['yaxis'].update(title='amplitude [mV]', type=yscale)
return fig
10 changes: 5 additions & 5 deletions NuRadioReco/eventbrowser/apps/trace_plots/channel_time_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from NuRadioReco.utilities import units
from NuRadioReco.eventbrowser.default_layout import default_layout
import numpy as np
from dash import dcc
from dash import dcc, callback
from dash.dependencies import State
from NuRadioReco.eventbrowser.app import app
# from NuRadioReco.eventbrowser.app import app
import NuRadioReco.eventbrowser.dataprovider

provider = NuRadioReco.eventbrowser.dataprovider.DataProvider()
Expand All @@ -16,7 +16,7 @@
]


@app.callback(
@callback(
dash.dependencies.Output('time-trace', 'figure'),
[dash.dependencies.Input('trigger-trace', 'children'),
dash.dependencies.Input('event-counter-slider', 'value'),
Expand Down Expand Up @@ -52,8 +52,8 @@ def update_time_trace(trigger, evt_counter, filename, station_id, juser_id):
'color': colors[i % len(colors)],
'line': {'color': colors[i % len(colors)]}
},
name='Channel {}'.format(i),
uid='Channel {}'.format(i)
name='Channel {}'.format(channel.get_id()),
uid='Channel {}'.format(channel.get_id())
), 1, 1)
fig['layout'].update(default_layout)
fig['layout']['legend']['uirevision'] = filename # only update channel selection on changing files.
Expand Down
18 changes: 10 additions & 8 deletions NuRadioReco/eventbrowser/apps/trace_plots/multi_channel_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
from NuRadioReco.utilities import trace_utilities
"""
import numpy as np
from dash import html
from dash import dcc
from dash import dcc, html, callback
from dash.dependencies import Input, Output, State
from NuRadioReco.eventbrowser.app import app
# from NuRadioReco.eventbrowser.app import app
import os
import NuRadioReco.detector.antennapattern
import NuRadioReco.eventbrowser.dataprovider
Expand Down Expand Up @@ -72,7 +71,7 @@
]


@app.callback(
@callback(
dash.dependencies.Output('dropdown-traces', 'options'),
[dash.dependencies.Input('event-counter-slider', 'value'),
dash.dependencies.Input('filename', 'value'),
Expand All @@ -99,7 +98,7 @@ def get_dropdown_traces_options(evt_counter, filename, station_id, juser_id):
return options


@app.callback(
@callback(
Output('template-input-group', 'style'),
[Input('dropdown-traces', 'value')]
)
Expand All @@ -117,7 +116,7 @@ def get_L1(a):
return l1


@app.callback(
@callback(
dash.dependencies.Output('time-traces', 'figure'),
[dash.dependencies.Input('event-counter-slider', 'value'),
dash.dependencies.Input('filename', 'value'),
Expand All @@ -126,9 +125,11 @@ def get_L1(a):
dash.dependencies.Input('station-id-dropdown', 'value'),
dash.dependencies.Input('open-template-button', 'n_clicks_timestamp')],
[State('user_id', 'children'),
State('template-directory-input', 'value')])
State('template-directory-input', 'value'),
State('channel-spectrum-log-linear-switch', 'children')]
)
def update_multi_channel_plot(evt_counter, filename, dropdown_traces, dropdown_info, station_id,
open_template_timestamp, juser_id, template_directory):
open_template_timestamp, juser_id, template_directory, yscale):
if filename is None or station_id is None:
return {}
user_id = json.loads(juser_id)
Expand Down Expand Up @@ -420,6 +421,7 @@ def update_multi_channel_plot(evt_counter, filename, dropdown_traces, dropdown_i
fig['layout']['yaxis{:d}'.format(i * 2 + 1)].update(
title='<b>Ch. {}</b><br>voltage [mV]'.format(channel_id)
)
fig['layout']['yaxis{:d}'.format(i * 2 + 2)].update(type=yscale)

if channel.get_trace() is None:
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from NuRadioReco.utilities import units
from NuRadioReco.eventbrowser.default_layout import default_layout
import numpy as np
from dash import dcc
from dash import dcc, html
from dash.dependencies import State
from NuRadioReco.eventbrowser.app import app
import NuRadioReco.eventbrowser.dataprovider
Expand All @@ -22,8 +22,9 @@
dash.dependencies.Input('event-counter-slider', 'value'),
dash.dependencies.Input('filename', 'value'),
dash.dependencies.Input('station-id-dropdown', 'value')],
[State('user_id', 'children')])
def update_efield_spectrum(trigger, evt_counter, filename, station_id, juser_id):
[State('user_id', 'children'),
State('channel-spectrum-log-linear-switch', 'children')])
def update_efield_spectrum(trigger, evt_counter, filename, station_id, juser_id, yscale):
if filename is None or station_id is None:
return {}
user_id = json.loads(juser_id)
Expand Down Expand Up @@ -61,5 +62,5 @@ def update_efield_spectrum(trigger, evt_counter, filename, station_id, juser_id)
), 1, 1)
fig['layout'].update(default_layout)
fig['layout']['xaxis1'].update(title='frequency [MHz]')
fig['layout']['yaxis1'].update(title='amplitude [mV/m]')
fig['layout']['yaxis'].update(title='amplitude [mV/m]', type=yscale)
return fig
75 changes: 62 additions & 13 deletions NuRadioReco/eventbrowser/apps/traces.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import absolute_import, division, print_function # , unicode_literals
from dash import html
from dash import html, no_update
import NuRadioReco.eventbrowser.apps.trace_plots.rec_electric_field_trace
import NuRadioReco.eventbrowser.apps.trace_plots.rec_electric_field_spectrum
import NuRadioReco.eventbrowser.apps.trace_plots.channel_time_trace
Expand Down Expand Up @@ -27,6 +27,9 @@
html.Div([
html.Div([
'Electric Field Spectrum',
' (y-scale: ',
html.Button(id='efield-spectrum-log-linear-switch', children='linear'),
')',
html.Button('Show', id='toggle_efield_spectrum', n_clicks=0, style={'float':'right'})
], className='panel-heading'),
html.Div(NuRadioReco.eventbrowser.apps.trace_plots.rec_electric_field_spectrum.layout,
Expand All @@ -45,6 +48,9 @@
html.Div([
html.Div([
'Channel Spectrum',
' (y-scale: ',
html.Button(id='channel-spectrum-log-linear-switch', children='linear'),
')',
html.Button('Show', id='toggle_channel_spectrum', n_clicks=0, style={'float':'right'})
], className='panel-heading'),
html.Div(NuRadioReco.eventbrowser.apps.trace_plots.channel_spectrum.layout,
Expand All @@ -60,53 +66,96 @@
])

@app.callback(
[Output('channel_traces_layout', 'children'),
[Output('channel_traces_layout', 'style'),
Output('toggle_channel_traces', 'children')],
[Input('toggle_channel_traces', 'n_clicks')],
State('toggle_channel_traces', 'children'),
prevent_initial_callbacks=True
)
def toggle_channel_trace_plot(button_clicks, showhide):
if showhide == 'Hide':
return [], 'Show'
return {'flex': '1', 'display': 'none'}, 'Show'
else:
return NuRadioReco.eventbrowser.apps.trace_plots.channel_time_trace.layout, 'Hide'
return {'flex' : '1'}, 'Hide'

@app.callback(
[Output('channel_spectrum_layout', 'children'),
[Output('channel_spectrum_layout', 'style'),
Output('toggle_channel_spectrum', 'children')],
[Input('toggle_channel_spectrum', 'n_clicks')],
State('toggle_channel_spectrum', 'children'),
prevent_initial_callbacks=True
)
def toggle_channel_spectrum_plot(button_clicks, showhide):
if showhide == 'Hide':
return [], 'Show'
return {'flex': '1', 'display': 'none'}, 'Show'
else:
return NuRadioReco.eventbrowser.apps.trace_plots.channel_spectrum.layout, 'Hide'
return {'flex': '1'}, 'Hide'

@app.callback(
[Output('efield_traces_layout', 'children'),
[Output('efield_traces_layout', 'style'),
Output('toggle_efield_traces', 'children')],
[Input('toggle_efield_traces', 'n_clicks')],
State('toggle_efield_traces', 'children'),
prevent_initial_callbacks=True
)
def toggle_efield_traces_plot(button_clicks, showhide):
if showhide == 'Hide':
return [], 'Show'
return {'flex': '1', 'display': 'none'}, 'Show'
else:
return NuRadioReco.eventbrowser.apps.trace_plots.rec_electric_field_trace.layout, 'Hide'
return {'flex': '1'}, 'Hide'

@app.callback(
[Output('efield_spectrum_layout', 'children'),
[Output('efield_spectrum_layout', 'style'),
Output('toggle_efield_spectrum', 'children')],
[Input('toggle_efield_spectrum', 'n_clicks')],
State('toggle_efield_spectrum', 'children'),
prevent_initial_callbacks=True
)
def toggle_efield_spectrum_plot(button_clicks, showhide):
if showhide == 'Hide':
return [], 'Show'
return {'flex': '1', 'display': 'none'}, 'Show'
else:
return NuRadioReco.eventbrowser.apps.trace_plots.rec_electric_field_spectrum.layout, 'Hide'
return {'flex': '1'}, 'Hide'

# callback to change frequency spectra between linear and log scale
@app.callback(
[Output('efield-spectrum', 'figure', allow_duplicate=True), # this is a 'duplicate' callback - requires dash >= 2.9
Output('channel-spectrum', 'figure', allow_duplicate=True), # this is a 'duplicate' callback - requires dash >= 2.9
Output('time-traces', 'figure', allow_duplicate=True),
Output('channel-spectrum-log-linear-switch', 'children'),
Output('efield-spectrum-log-linear-switch', 'children')
],
[Input('channel-spectrum-log-linear-switch', 'n_clicks'),
Input('efield-spectrum-log-linear-switch', 'n_clicks')],
[State('channel-spectrum-log-linear-switch', 'children'),
State('efield-spectrum', 'figure'),
State('channel-spectrum', 'figure'),
State('time-traces', 'figure'),
], prevent_initial_call=True
)
def toggle_linear_log_scale(button_clicks, button2_clicks, button_current_value, efield_spectrum, channel_spectrum, multichannel_plot):
outputs = []
if button_current_value == 'linear': # switch to log
new_value = 'log'
else:
new_value = 'linear'
for spectrum_plot in [efield_spectrum, channel_spectrum]:
try:
spectrum_plot['layout']['yaxis']['type'] = new_value
outputs.append(spectrum_plot)
except KeyError:
outputs.append(no_update)

try:
yaxes = [key for key in multichannel_plot['layout'].keys() if 'yaxis' in key]
yaxes = [key for key in yaxes if len(key)>5] # omit key 'yaxis'
yaxes_even = [key for key in yaxes if not (int(key.split('yaxis')[-1]) % 2)]
for yaxis in yaxes_even:
multichannel_plot['layout'][yaxis]['type'] = new_value
outputs.append(multichannel_plot)
except KeyError as e:
outputs.append(no_update)

outputs.append(new_value)
outputs.append(new_value)
return outputs
Loading