Skip to content

Commit

Permalink
Observed Spectrum option for the Plotly plot
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed Jul 29, 2021
1 parent 8903c13 commit 65099eb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tardis/visualization/tools/sdec_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,8 @@ def generate_plot_ply(
distance : astropy.Quantity or None, optional
Distance used to calculate flux instead of luminosity in the plot.
It should have a length unit like m, Mpc, etc. Default value is None
observed_spectrum : tuple or list of two astropy quantities, optional
Option to plot the observed spectrum.
show_modeled_spectrum : bool, optional
Whether to show modeled spectrum in SDEC Plot. Default value is
True
Expand Down Expand Up @@ -1547,6 +1549,32 @@ def generate_plot_ply(
)
)

# Plot observed spectrum
if observed_spectrum:
observed_spectrum_wavelength = None
observed_spectrum_luminosity = None

if (
type(observed_spectrum[0]) is u.quantity.Quantity
and type(observed_spectrum[1]) is u.quantity.Quantity
):
# If the observed spectrum is a list of quantities, then convert to wavelength and luminosity units
observed_spectrum_wavelength = observed_spectrum[0].to(u.AA)
observed_spectrum_luminosity = observed_spectrum[1].to(
u.erg / (u.s)
)

else:
raise ValueError(
"Both wavelength and luminosity should be astropy quantities."
)

self.fig.add_scatter(
x=observed_spectrum_wavelength,
y=observed_spectrum_luminosity,
name="Observed Spectrum",
)

# Plot photosphere
self.fig.add_trace(
go.Scatter(
Expand Down

0 comments on commit 65099eb

Please sign in to comment.