CSMAnalysis (xsnap.CSMAnalysis)#

class CSMAnalysis(manager=None)#

Bases: object

Supernova circumstellar medium (CSM) analysis, including fitting \(L(t) \propto t^x\) to deriving unshocked CSM densities and mass-loss rates of the supernova progenitor.

Note

As our emission measure (EM) comes from the normalization of the thermal-bremsstrahlung, the CSMAnalysis class can only be used if the SpectrumManager class contains exactly one bremss model.

manager#

Input manager spectra analysis.

Type:

SpectrumManager or None

distance#

Source distance in Mpc.

Type:

float or None

r_shock#

Shock radius.

Type:

pandas.DataFrame or None

times#

Times since explosion.

Type:

pandas.DataFrame or None

fit_lumin_params#
Best-fit luminosity parameters wrapped in DataFrame table with

columns ['model', 'norm','lo_norm_err','hi_norm_err', 'exp','lo_exp_err','hi_exp_err','ndata'].

Type:

pandas.DataFrame or None

fit_temp_params#
Best-fit temperature parameters wrapped in DataFrame table with

columns ['model', 'norm','lo_norm_err','hi_norm_err', 'exp','lo_exp_err','hi_exp_err','ndata'].

Type:

pandas.DataFrame or None

fit_density_params#

Best-fit density parameters, i.e. the fitted mass-loss rates in \(\rm g \ s^{-1}\), wrapped in DataFrame table with columns ['mdot', 'lo_mdot_err', 'hi_mdot_err']

Type:

pandas.DataFrame or None

densities#

Computed unshocked CSM density in \(\rm g \ {cm}^{-3}\) wrapped in DataFrame table with columns ['time_since_explosion', 'rho', 'lo_rho_err', 'hi_rho_err']

Type:

pandas.DataFrame or None

mass_loss_rate#

Computed mass-loss rates of the supernova progenitor in \(\rm M_{\bigodot} \ {yr}^{-1}\), wrapped in a DataFrame with columns ['m_dot', 'lo_m_dot_err', 'hi_m_dot_err']

Type:

pandas.DataFrame

__init__(manager=None)#

Initialization of the CSMAnalysis class

Parameters:

manager (SpectrumManager, optional) – Pre-populated SpectrumManager instance.

calc_density(distance=None, lo_dist_err=None, hi_dist_err=None, z=None, lo_z_err=None, hi_z_err=None, mu_e=1.14, mu_ion=1.24, radius_ratio=1.2, f=1, v_wind=20.0, H0=70, nwalkers=500, nsteps=10000, nburn=2000, show_plots=True)#

Calculate unshocked CSM density \(\rho_{\mathrm{CSM}}(r)\) and fit using Markov chain Monte-Carlo (MCMC) based on 'bremss_norm' in params.

In calculating the density, we use the model of D. Brethauer et al. (2022), where the unshocked CSM density is expressed by:

\[\rho_{\mathrm{CSM}}(r) = \frac{m_p}{4} \left(\frac{2 \times \mathrm{EM}(r)\mu_e \mu_I}{V_{\mathrm{FS}}(r)}\right)^{1/2}\]

where we parameterized:

\[ \begin{align}\begin{aligned}\mathrm{{bremss} \ {norm}} = \frac{3.02 \cdot 10^{-15}}{4 \pi d^2} \times \mathrm{EM}\\\mathrm{V}_{\mathrm{FS}} = \frac{4 \pi}{3} f \left(R_{\mathrm{out}}^3 - R_{\mathrm{in}}^3\right)\end{aligned}\end{align} \]

From there, we fit \(\rho_{\mathrm{CSM}}(r)\) and \(\dot{M}\) with:

\[\rho_{\mathrm{CSM}} = \frac{\dot{M}}{4 \pi r_{\mathrm{shock}}^2 v_{\mathrm{wind}}}\]
Parameters:
  • distance (float, optional) – distance to source in Mpc.

  • z (float, optional) – redshift to source.

  • mu_e (float, optional) – mean molecular weight per electron. Defaults to 1.14 (solar value).

  • mu_ion (float, optional) – mean molecular weight per ion. Defaults to 1.24 (solar value).

  • radius_ratio (float, optional) – shock Rout/Rin ratio. Defaults to 1.2.

  • f (int, optional) – filling factor. Defaults to 1.

  • v_wind (float, optional) – wind velocity in km/s. Defaults to 20.

  • H0 (float, optional) – Hubble constant in km/s/Mpc. Defaults to 70.

  • nwalkers (int, optional) – Number of MCMC walkers. Defaults to 500.

  • nsteps (int, optional) – Number of steps per walker. Defaults to 10000.

  • nburn (int, optional) – Number of burn-in steps. Defaults to 2000.

  • show_plots (bool, optional) – If True, display diagnostic plots. Defaults to True.

  • fit (bool, optional) – If True, will fit density and get mass-loss rate in \(\rm g \ s^{-1}\). Defaults to True

Returns:

Densitypandas.DataFrame

Computed unshocked CSM density in \(\rm g \ {cm}^{-3}\) wrapped in DataFrame table with columns ['time_since_explosion', 'rho', 'lo_rho_err', 'hi_rho_err']

Raises:
  • RuntimeError – When params do not have these columns: ['bremss_norm', 'lo_bremss_norm_err', 'hi_bremss_norm_err', 'time_since_explosion']

  • ValueError – When distance or redshift is not entered

Note

If distance is not supplied, it is inferred from redshift via the Doppler relation:

\[\begin{split}v = \begin{cases} c\,z, & z \ll 1, \\ c\,\frac{(1 + z)^2 - 1}{(1 + z)^2 + 1}, & \text{otherwise.} \end{cases}\end{split}\]

and then:

\[d = \frac{v}{H_0} \ (\mathrm{Mpc}).\]
References:

Hogg, D. W. (1999). Distance measures in cosmology. arXiv:astro-ph/9905116

clear()#

Reset all loaded data and computed results.

fit_lumin(nwalkers=500, nsteps=10000, nburn=2000, show_plots=True)#

Fit power-law luminosity \(L(t) \propto t^x\) using Markov chain Monte-Carlo (MCMC).

Parameters:
  • nwalkers (int, optional) – Number of MCMC walkers. Defaults to 500.

  • nsteps (int, optional) – Number of steps per walker. Defaults to 10000.

  • nburn (int, optional) – Number of burn-in steps. Defaults to 2000.

  • show_plots (bool, optional) – If True, display diagnostic plots. Defaults to True

Returns:

Best-fit luminosity parameterspandas.DataFrame

Best-fit luminosity parameters wrapped in DataFrame table with columns ['model', 'norm','lo_norm_err','hi_norm_err', 'exp','lo_exp_err','hi_exp_err','ndata'].

fit_temp(nwalkers=500, nsteps=10000, nburn=2000, show_plots=True)#

Fit power-law temperature \(T(t) \propto t^x\) using Markov chain Monte-Carlo (MCMC).

Parameters:
  • nwalkers (int, optional) – Number of MCMC walkers. Defaults to 500.

  • nsteps (int, optional) – Number of steps per walker. Defaults to 10000.

  • nburn (int, optional) – Number of burn-in steps. Defaults to 2000.

  • show_plots (bool, optional) – If True, display diagnostic plots. Defaults to True

Returns:

Best-fit temperature parameterspandas.DataFrame

Best-fit temperature parameters wrapped in DataFrame table with columns ['model', 'norm','lo_norm_err','hi_norm_err', 'exp','lo_exp_err','hi_exp_err','ndata'].

get_mdot()#

Get mass loss rate in \(\rm M_{\bigodot} \ {yr}^{-1}\)

Returns:

Mass-loss rate and its errors in \(\rm M_{\bigodot} \ {yr}^{-1}\), wrapped in a DataFrame with columns ['m_dot', 'lo_m_dot_err', 'hi_m_dot_err']

load(manager, distance=None, lo_dist_err=None, hi_dist_err=None, z=None, lo_z_err=None, hi_z_err=None, v_shock=10000.0, H0=70)#

Load manager luminosity & parameter tables and compute shock radius.

Parameters:
  • manager (SpectrumManager) – Must contain one 'bremss' model in lumin & params.

  • distance (float, optional) – Distance in Mpc. Required if z is None.

  • z (float, optional) – Redshift to compute distance. Required if distance is None. Defaults to None.

  • lo_dist_err (float, optional) – Lower uncertainty of distance in Mpc. Defaults to None.

  • hi_dist_err (float, optional) – Upper uncertainty of distance in Mpc. Defaults to None.

  • lo_z_err (float, optional) – Lower uncertainty of redshift. Defaults to None.

  • hi_z_err (float, optional) – Upper uncertainty of redshift. Defaults to None.

  • H0 (float, optional) – Hubble constant in km/s/Mpc. Defaults to 70.0.

  • v_shock (float, optional) – Shock velocity in km/s. Defaults to 10000.

Returns:

selfCSMAnalysis

The same CSMAnalysis with times and r_shock populated.

Raises:
  • RuntimeError – If more than one bremss model is present.

  • ValueError – If required tables/columns are missing.

Note

If distance is not supplied, it is inferred from redshift via the Doppler relation:

\[\begin{split}v = \begin{cases} c\,z, & z \ll 1, \\ c\,\frac{(1 + z)^2 - 1}{(1 + z)^2 + 1}, & \text{otherwise.} \end{cases}\end{split}\]

and then:

\[d = \frac{v}{H_0} \ (\mathrm{Mpc}).\]
References:

Hogg, D. W. (1999). Distance measures in cosmology. arXiv:astro-ph/9905116

plot_density(model_color='red', v_wind=20)#

Plot the unshocked CSM density profile with its best-fit mass-loss rate.

Parameters:
  • model_color (str, optional) – Color for the fit line. Defaults to 'red'.

  • v_wind (float) – Wind velocity (needed as the best-fit parameter is in terms of the mass-loss rate).

Returns:

Plotmatplotlib.figure.Figure

The density profile plot with data and fit

plot_lumin(model_color='red')#

Plot luminosity light curve with best-fit power-law.

Parameters:

model_color (str, optional) – Color for the fit line. Defaults to 'red'.

Returns:

Plotmatplotlib.figure.Figure

The fitted luminosity light curve plot with data and fit.

Data are grouped and labeled by instruments.

plot_temp(model_color='red')#

Plot temperature evolution with best-fit power-law.

Parameters:

model_color (str, optional) – Color for the fit line. Defaults to 'red'.

Returns:

Plotmatplotlib.figure.Figure

The fitted temperature evolution plot with data and fit.

Data are grouped and labeled by instruments.