============ Analysis ============ Sometimes, we wish to do further analysis after we fit. Or before fitting get a understanding of the priors to set, develop a new model, plot the spectrum etc. In :code:`redback` we have a :code:`Analysis` class that can be used to do this. This class provides wrappers around the plot_lightcurve/plot_multiband_lightcurve functions in :code:`redback.plotting` and provides a :code:`plot_spectrum` function and some additional diagnostic/supplementary plots that are specific to certain models. For example, if we wanted to plot a some specific parameters on top of the plot_lightcurve plot, we can do the following: .. code:: python from redback import analysis analysis.plot_lightcurve(transient, parameters, model, model_kwargs=None) Here - transient is the transient object. - Parameters is a dictionary or pandas dataframe containing the parameters we wish to plot. - model is the model we wish to plot. This can be a string or a function. - model_kwargs is a dictionary of keyword arguments to pass to the model function. Spectral Template Matching ========================== The :code:`SpectralTemplateMatcher` class provides SNID-like spectral classification: .. code:: python from redback.analysis import SpectralTemplateMatcher matcher = SpectralTemplateMatcher() result = matcher.match_spectrum(spectrum, redshift_range=(0, 0.3)) print(f"Type: {result['type']}, z={result['redshift']:.3f}") For detailed documentation on spectral template matching, see :doc:`spectral_template_matching`. Spectral Velocity Fitting ========================== The :code:`SpectralVelocityFitter` class provides tools for measuring expansion velocities from spectral line profiles. This is particularly useful for analyzing Type Ia supernovae and other transients with P-Cygni profiles. .. code:: python from redback.analysis import SpectralVelocityFitter # Create fitter fitter = SpectralVelocityFitter(wavelength, flux) # Measure Si II 6355 velocity v, v_err = fitter.measure_line_velocity(6355) print(f"Si II velocity: {v:.0f} +/- {v_err:.0f} km/s") # Measure multiple lines lines = {'Si II': 6355, 'Ca II': 3934, 'Fe II': 5169} velocities = fitter.measure_multiple_lines(lines) # Track velocity evolution times, vels, errs = SpectralVelocityFitter.photospheric_velocity_evolution( wavelength_list, flux_list, times, line_wavelength=6355 ) # Detect high-velocity features has_hvf, v_hvf, err = fitter.identify_high_velocity_features(6355, v_phot_expected=11000) For detailed documentation on spectral line models and velocity fitting, see :doc:`spectral_models`. Please look at the API for the other methods available in the :code:`Analysis` class.