tardis.visualization.tools.sdec_plot module¶
Spectral element DEComposition (SDEC) Plot for TARDIS simulation models.
This plot is a spectral diagnostics plot similar to those originally proposed by M. Kromer (see, for example, Kromer et al. 2013, figure 4).
- class tardis.visualization.tools.sdec_plot.SDECData(last_interaction_type, last_line_interaction_in_id, last_line_interaction_out_id, last_line_interaction_in_nu, lines_df, packet_nus, packet_energies, r_inner, spectrum_delta_frequency, spectrum_frequency_bins, spectrum_luminosity_density_lambda, spectrum_wavelength, t_inner, time_of_simulation)[source]¶
- Bases: - object- The data of simulation model used by Spectral element DEComposition (SDEC) Plot. - This preprocesses the data required by SDECPlotter class for doing calculations and plotting. - Initialize the SDECData with required properties of simulation model. - Parameters
- last_interaction_typenp.array
- Interaction type (no-interaction: -1, e-scattering: 1 and line interaction: 2) values of emitted packets 
- last_line_interaction_in_idnp.array
- IDs of atomic lines with which emitted packet had their last absorption (interaction in) 
- last_line_interaction_out_idnp.array
- IDs of atomic lines with which emitted packet had their last emission (interaction out) 
- last_line_interaction_in_nunp.array
- Frequency values of the last absorption of emitted packets 
- lines_dfpd.DataFrame
- Data about the atomic lines present in simulation model’s plasma 
- packet_nusastropy.Quantity
- Frequency values of the last emission of emitted packets, having unit of Hz 
- packet_energiesastropy.Quantity
- Energy values of emitted packets, having unit of erg 
- r_innerastropy.Quantity
- Radius of innermost shell, having unit of cm 
- spectrum_delta_frequencyastropy.Quantity
- Frequency bin width of spectrum, having unit of Hz 
- spectrum_frequency_binsastropy.Quantity
- Frequency bin edges of spectrum, having unit of Hz 
- spectrum_wavelengthastropy.Quantity
- Wavelength values of spectrum, having unit of Angstrom 
- t_innerastropy.Quantity
- Temperature of innermost shell, having unit of K 
- time_of_simulationastropy.Quantity
- Time of simulation, having unit of s (second) 
 
 - classmethod from_hdf(hdf_fpath, packets_mode)[source]¶
- Create an instance of SDECData from a simulation HDF file. - Parameters
- hdf_fpathstr
- Valid path to the HDF file where simulation is saved 
- packets_mode{‘virtual’, ‘real’}
- Mode of packets to be considered, either real or virtual 
 
- Returns
- SDECData
 
 
 - classmethod from_simulation(sim, packets_mode)[source]¶
- Create an instance of SDECData from a TARDIS simulation object. - Parameters
- simtardis.simulation.Simulation
- TARDIS Simulation object produced by running a simulation 
- packets_mode{‘virtual’, ‘real’}
- Mode of packets to be considered, either real or virtual 
 
- Returns
- SDECData
 
 
 
- class tardis.visualization.tools.sdec_plot.SDECPlotter(data)[source]¶
- Bases: - object- Plotting interface for Spectral element DEComposition (SDEC) Plot. - It performs necessary calculations to generate SDEC Plot for a simulation model, and allows to plot it in matplotlib and plotly. - Initialize the SDECPlotter with required data of simulation model. - Parameters
- datadict of SDECData
- Dictionary to store data required for SDEC plot, for both packet modes i.e. real and virtual 
 
 - classmethod from_hdf(hdf_fpath)[source]¶
- Create an instance of SDECPlotter from a simulation HDF file. - Parameters
- hdf_fpathstr
- Valid path to the HDF file where simulation is saved 
 
- Returns
- SDECPlotter
 
 
 - classmethod from_simulation(sim)[source]¶
- Create an instance of SDECPlotter from a TARDIS simulation object. - Parameters
- simtardis.simulation.Simulation
- TARDIS Simulation object produced by running a simulation 
 
- Returns
- SDECPlotter
 
 
 - generate_plot_mpl(packets_mode='virtual', packet_wvl_range=None, distance=None, observed_spectrum=None, show_modeled_spectrum=True, ax=None, figsize=(12, 7), cmapname='jet', nelements=None, species_list=None)[source]¶
- Generate Spectral element DEComposition (SDEC) Plot using matplotlib. - Parameters
- packets_mode{‘virtual’, ‘real’}, optional
- Mode of packets to be considered, either real or virtual. Default value is ‘virtual’ 
- packet_wvl_rangeastropy.Quantity or None, optional
- Wavelength range to restrict the analysis of escaped packets. It should be a quantity having units of Angstrom, containing two values - lower lambda and upper lambda i.e. [lower_lambda, upper_lambda] * u.AA. Default value is None 
- distanceastropy.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_spectrumtuple or list of astropy.Quantity, optional
- Option to plot an observed spectrum in the SDEC plot. If given, the first element should be the wavelength and the second element should be flux, i.e. (wavelength, flux). The assumed units for wavelength and flux are angstroms and erg/(angstroms * s * cm^2), respectively. Default value is None. 
- show_modeled_spectrumbool, optional
- Whether to show modeled spectrum in SDEC Plot. Default value is True 
- axmatplotlib.axes._subplots.AxesSubplot or None, optional
- Axis on which to create plot. Default value is None which will create plot on a new figure’s axis. 
- figsizetuple, optional
- Size of the matplotlib figure to display. Default value is (12, 7) 
- cmapnamestr, optional
- Name of matplotlib colormap to be used for showing elements. Default value is “jet” 
- nelements: int
- Number of elements to include in plot. Determined by the largest contribution to total luminosity absorbed and emitted. Other elements are shown in silver. Default value is None, which displays all elements 
- species_list: list of strings or None
- list of strings containing the names of species that should be included in the SDEC plots. Must be given in Roman numeral format. Can include specific ions, a range of ions, individual elements, or any combination of these: e.g. [‘Si II’, ‘Ca II’, ‘C’, ‘Fe I-V’] 
 
- Returns
- matplotlib.axes._subplots.AxesSubplot
- Axis on which SDEC Plot is created 
 
 
 - generate_plot_ply(packets_mode='virtual', packet_wvl_range=None, distance=None, observed_spectrum=None, show_modeled_spectrum=True, fig=None, graph_height=600, cmapname='jet', nelements=None, species_list=None)[source]¶
- Generate interactive Spectral element DEComposition (SDEC) Plot using plotly. - Parameters
- packets_mode{‘virtual’, ‘real’}, optional
- Mode of packets to be considered, either real or virtual. Default value is ‘virtual’ 
- packet_wvl_rangeastropy.Quantity or None, optional
- Wavelength range to restrict the analysis of escaped packets. It should be a quantity having units of Angstrom, containing two values - lower lambda and upper lambda i.e. [lower_lambda, upper_lambda] * u.AA. Default value is None 
- distanceastropy.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_spectrumtuple or list of astropy.Quantity, optional
- Option to plot an observed spectrum in the SDEC plot. If given, the first element should be the wavelength and the second element should be flux, i.e. (wavelength, flux). The assumed units for wavelength and flux are angstroms and erg/(angstroms * s * cm^2), respectively. Default value is None. 
- show_modeled_spectrumbool, optional
- Whether to show modeled spectrum in SDEC Plot. Default value is True 
- figplotly.graph_objs._figure.Figure or None, optional
- Figure object on which to create plot. Default value is None which will create plot on a new Figure object. 
- graph_heightint, optional
- Height (in px) of the plotly graph to display. Default value is 600 
- cmapnamestr, optional
- Name of the colormap to be used for showing elements. Default value is “jet” 
- nelements: int
- Number of elements to include in plot. Determined by the largest contribution to total luminosity absorbed and emitted. Other elements are shown in silver. Default value is None, which displays all elements 
- species_list: list of strings or None
- list of strings containing the names of species that should be included in the SDEC plots. Must be given in Roman numeral format. Can include specific ions, a range of ions, individual elements, or any combination of these: e.g. [‘Si II’, ‘Ca II’, ‘C’, ‘Fe I-V’] 
- Returns
- ——-
- plotly.graph_objs._figure.Figure
- Figure object on which SDEC Plot is created 
 
 
 - static to_rgb255_string(color_tuple)[source]¶
- Convert a matplotlib RGBA tuple to a generic RGB 255 string. - Parameters
- color_tupletuple
- Matplotlib RGBA tuple of float values in closed interval [0, 1] 
 
- Returns
- str
- RGB string of format rgb(r,g,b) where r,g,b are integers between 0 and 255 (both inclusive)