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

[WIP] Jupyter widgets: automatic update of plot options #2911

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions lib/python/picongpu/plugins/data/base_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,38 @@ def _get_for_iteration(self, iteration, **kwargs):
dependent format and type.
"""
raise NotImplementedError

# NOTE: this can be hard to define abstractly since we should make each
# parameter query dependent on all other possible choices of parameters
# thus requiring kwargs?!

# e.g. get all species strings for defined values of filter, iteration
# and other parameters
def get_species(self, iteration=None, species_filter=None):
"""
Get the available species abbreviations for which data exists.
Optionally specific iterations and/or filters can be given.


Returns
-------
A list of species abbreviation strings for which data exists.
In case iteration or species_filter are not None, only species
are returned that match iteration and species_filter.
"""
raise NotImplementedError

def get_species_filters(self, iteration=None, species=None):
raise NotImplementedError

def get_options(self, iteration=None, species=None, species_filter=None):
"""
Returns
-------
a dictionary mapping keywords that a visualizer might use
to the values for which data is present.
"""
return {
'species': self.get_species(iteration, species_filter),
'species_filter': self.get_species_filters(iteration, species)
}
6 changes: 6 additions & 0 deletions lib/python/picongpu/plugins/data/energy_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,9 @@ def _get_for_iteration(self, iteration, species, species_filter="all",
return data.loc[iteration].values, bins, iteration, dt
else:
return data.loc[iteration].values[0, :], bins, iteration, dt

def get_species(self, iteration=None, species_filter=None):
raise NotImplementedError

def get_species_filters(self):
raise NotImplementedError
19 changes: 19 additions & 0 deletions lib/python/picongpu/plugins/data/phase_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,22 @@ def _get_for_iteration(self, iteration, ps, species, species_filter='all',
return ret[0]
else:
return ret

def get_species(self, iteration=None, species_filter=None):
raise NotImplementedError

def get_species_filters(self, iteration=None, species=None):
raise NotImplementedError

def get_ps(self, iteration=None, species=None, species_filter=None):
raise NotImplementedError

def get_options(self, iteration=None, species=None, species_filter=None):

# the options for species and species_filter
d = super().get_options()

# also append options for ps
d['ps'] = self.get_ps()

return d
10 changes: 10 additions & 0 deletions lib/python/picongpu/plugins/jupyter_widgets/base_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ def _handle_run_dir_selection(self, run_dir_selection):
# (without triggering the callback)
self._update_available_sim_times()

# TODO: update the widgets that allow choosing of parameter
# vaues for plotting with the options that are common to
# a) the selected simulations and
# b) to the selected simulation time
# BUT: is this enough to update the options only on choice of
# simulations? shouldn't this also be updated when
# a) some other option changes
# and
# b) the simulation time changes?

def _handle_run_dir_selection_callback(self, change):
"""
Callback function when user selects a subset of the
Expand Down