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

add value error to ensure active virtual packet logging in SDECPlotter #1597

Merged
Merged
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
4 changes: 2 additions & 2 deletions docs/io/visualization/sdec_plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
"source": [
"<div class=\"alert alert-warning\">\n",
"\n",
"**Important:** The virtual packet logging capability must be active in order to produce SDEC Plot. Thus, make sure to set `virtual_packet_logging: True` in your configuration file. It should be added under `virtual` property of `spectrum` property, as described in [configuration schema](https://tardis-sn.github.io/tardis/using/components/configuration/configuration.html#spectrum).\n",
"**Important:** The virtual packet logging capability must be active in order to produce SDEC Plot for virtual packets population. Thus, make sure to set `virtual_packet_logging: True` in your configuration file if you want to generate SDEC Plot with virtual packets. It should be added under `virtual` property of `spectrum` property, as described in [configuration schema](https://tardis-sn.github.io/tardis/using/components/configuration/configuration.html#spectrum).\n",
"\n",
"</div>"
]
Expand Down Expand Up @@ -1002166,4 +1002166,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
27 changes: 22 additions & 5 deletions tardis/visualization/tools/sdec_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,20 @@ def from_simulation(cls, sim):
-------
SDECPlotter
"""
return cls(
dict(
virtual=SDECData.from_simulation(sim, "virtual"),
real=SDECData.from_simulation(sim, "real"),
if sim.runner.virt_logging:
return cls(
dict(
virtual=SDECData.from_simulation(sim, "virtual"),
real=SDECData.from_simulation(sim, "real"),
)
)
else:
return cls(
dict(
virtual=None,
real=SDECData.from_simulation(sim, "real"),
)
)
)

@classmethod
def from_hdf(cls, hdf_fpath):
Expand Down Expand Up @@ -568,6 +576,15 @@ def _calculate_plotting_data(
"allowed values are 'virtual' or 'real'"
)

if packets_mode == "virtual" and self.data[packets_mode] is None:
raise ValueError(
"SDECPlotter doesn't have any data for virtual packets population and SDEC "
"plot for the same was requested. Either set virtual_packet_logging: True "
"in your configuration file to generate SDEC plot with virtual packets, or "
"pass packets_mode='real' in your function call to generate SDEC plot with "
"real packets."
)

# Store the plottable range of each spectrum property which is
# same as entire range, initially
self.plot_frequency_bins = self.data[
Expand Down