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 IntegrationError causing refdata generation failure #2595

Merged
merged 3 commits into from
Apr 22, 2024
Merged
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
29 changes: 23 additions & 6 deletions tardis/montecarlo/montecarlo_transport_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
from astropy import units as u

from tardis.io.util import HDFWriterMixin
from tardis.montecarlo.spectrum import TARDISSpectrum
from tardis.montecarlo.estimators.dilute_blackbody_properties import (
MCDiluteBlackBodyRadFieldSolver,
)
from tardis.montecarlo.montecarlo_numba.formal_integral import IntegrationError
from tardis.montecarlo.spectrum import TARDISSpectrum


class MonteCarloTransportState(HDFWriterMixin):
Expand Down Expand Up @@ -74,6 +75,7 @@ def __init__(
self.integrator_settings = None
self._spectrum_integrated = None
self.enable_full_relativity = False
self.enable_continuum_processes = False
self.geometry_state = geometry_state
self.opacity_state = opacity_state
self.rpacket_tracker = rpacket_tracker
Expand Down Expand Up @@ -224,11 +226,26 @@ def spectrum_integrated(self):
if self._spectrum_integrated is None:
# This was changed from unpacking to specific attributes as compute
# is not used in calculate_spectrum
self._spectrum_integrated = self.integrator.calculate_spectrum(
self.spectrum_frequency[:-1],
points=self.integrator_settings.points,
interpolate_shells=self.integrator_settings.interpolate_shells,
)
try:
self._spectrum_integrated = self.integrator.calculate_spectrum(
self.spectrum_frequency[:-1],
points=self.integrator_settings.points,
interpolate_shells=self.integrator_settings.interpolate_shells,
)
except IntegrationError:
# if integration is impossible or fails, return an empty spectrum
warnings.warn(
"The FormalIntegrator is not yet implemented for the full "
"relativity mode or continuum processes. "
"Please run with config option enable_full_relativity: "
"False and continuum_processes_enabled: False "
"This RETURNS AN EMPTY SPECTRUM!",
UserWarning,
)
return TARDISSpectrum(
np.array([np.nan, np.nan]) * u.Hz,
np.array([np.nan]) * u.erg / u.s,
)
return self._spectrum_integrated

@property
Expand Down
Loading