redback.utils

Functions

abmag_to_flambda(mag, lam_eff)

Converts an AB magnitude to flux density in erg/s/cm^2/Å using the effective wavelength for the band.

abmag_to_flux_density_and_error_inmjy(m_AB, ...)

Convert an AB magnitude and its uncertainty to a flux density in millijanskys (mJy) along with the associated error.

bandflux_error_from_limiting_mag(...)

Function to compute the error associated with the flux measurement of the transient source, computed based on the observation databse determined five-sigma depth.

bandpass_flux_to_flux_density(flux, ...)

Convert an integrated flux (and its error) measured over a bandpass in erg/s/cm² into a flux density (in erg/s/cm²/Hz) and then into millijanskys (mJy).

bandpass_flux_to_magnitude(flux, bands)

Convert flux to magnitude

bandpass_magnitude_to_flux(magnitude, bands)

Convert magnitude to flux

bands_to_effective_width(bands)

Converts a list of bands into an array of effective width in Hz

bands_to_frequency(bands)

Converts a list of bands into an array of frequency in Hz

bands_to_reference_flux(bands)

Looks up the reference flux for a given band from the filters table.

bands_to_zeropoint(bands)

Bands to zero point

bin_ttes(ttes, bin_size)

Bin TimeTaggedEvents into bins of size bin_size

calc_ABmag_from_flux_density(fluxdensity)

Calculate AB magnitude from flux density assuming monochromatic AB filter

calc_credible_intervals(samples[, interval])

Calculate credible intervals from samples

calc_flux_density_error_from_monochromatic_magnitude(...)

Calculate flux density error from magnitude error

calc_flux_density_from_ABmag(magnitudes)

Calculate flux density from AB magnitude assuming monochromatic AB filter

calc_flux_density_from_vegamag(magnitudes, ...)

Calculate flux density from Vega magnitude assuming Vega filter

calc_flux_error_from_magnitude(magnitude, ...)

Calculate flux error from magnitude error

calc_kcorrected_properties(frequency, ...)

Perform k-correction

calc_one_dimensional_median_and_error_bar(samples)

Calculates the median and error bars for a one-dimensional sample array.

calc_tfb(binding_energy_const, mbh_6, ...)

Calculate the fall back timescale for a SMBH disrupting a stellar mass object :param binding_energy_const: :param mbh_6: SMBH mass in solar masses :param stellar_mass: stellar mass in solar masses :return: fall back time in seconds

calc_vegamag_from_flux_density(fluxdensity, ...)

Calculate Vega magnitude from flux density assuming Vega filter

calculate_normalisation(unique_frequency, ...)

Calculate the normalisation for smoothly joining two models together at a reference time.

cdf(x[, plot])

Cumulative distribution function

check_element(driver, id_number)

checks that an element exists on a website, and provides an exception

check_kwargs_validity(kwargs)

Check the validity of the kwargs passed to a model

citation_wrapper(r)

Wrapper for citation function to allow functions to have a citation attribute :param r: proxy argument :return: wrapped function

convert_absolute_mag_to_apparent(magnitude, ...)

Convert absolute magnitude to apparent

convert_apparent_mag_to_absolute(...)

Convert apparent magnitude to absolute magnitude assuming planck18 cosmology.

date_to_jd(year, month, day)

Convert date to JD

date_to_mjd(year, month, day)

Convert date to MJD

deceleration_timescale(e0, g0, n0)

Calculate the deceleration timescale for an afterglow

download_pointing_tables()

Download the pointing tables from zenodo.

electron_fraction_from_kappa(kappa)

Uses interpolation from Tanaka+19 to calculate the electron fraction based on the temperature independent gray opacity :param kappa: temperature independent gray opacity :return: electron_fraction

fetch_driver()

find_nearest(array, value)

Find the nearest value in an array to a given value.

find_path(path)

Find the path of some data in the package

flambda_err_from_mag_err(flux, mag_err)

Compute the error on the flux given an error on the magnitude. Using error propagation for f = A*10^(-0.4*mag): df/dmag = -0.4 ln(10)* f => σ_f = 0.4 ln(10)* f * σ_mag.

fnu_to_flambda(f_nu, wavelength_A)

Convert flux density from erg/s/cm^2/Hz to erg/s/cm^2/Angstrom.

frequency_to_bandname(frequency)

Converts a list of frequencies into an array corresponding band names

get_csm_properties(nn, eta)

Calculate CSM properties for CSM interacting models

get_functions_dict(module)

get_heating_terms(ye, vel, **kwargs)

heatinggrids()

interpolated_barnes_and_kasen_thermalisation_efficiency(...)

Uses Barnes+2016 and interpolation to calculate the r-process thermalisation efficiency depending on the input mass and velocity :param mej: ejecta mass in solar masses :param vej: initial ejecta velocity as a fraction of speed of light :return: av, bv, dv constants in the thermalisation efficiency equation Eq 25 in Metzger 2017

jd_to_date(jd)

Convert JD to date

jd_to_mjd(jd)

Convert JD to MJD

kappa_from_electron_fraction(ye)

Uses interpolation from Tanaka+19 to calculate the opacity based on the electron fraction :param ye: electron fraction :return: electron_fraction

kde_scipy(x[, bandwidth])

Kernel Density Estimation with Scipy

lambda_to_nu(wavelength)

lorentz_factor_from_velocity(velocity)

Calculates the Lorentz factor for a given velocity :param velocity: velocity in cm/s :return: Lorentz factor

magnitude_error_from_flux_error(bandflux, ...)

Function to propagate the flux error to the mag system.

mjd_to_date(mjd)

Convert MJD to date

mjd_to_jd(mjd)

Convert MJD to JD

nu_to_lambda(frequency)

setup_logger([outdir, label, log_level])

Setup logging output: call at the start of the script to use

sncosmo_bandname_from_band(bands[, ...])

Convert redback data band names to sncosmo compatible band names

velocity_from_lorentz_factor(lorentz_factor)

Calculates the velocity for a given Lorentz factor :param Lorentz_factor: relativistic Lorentz factor :return: velocity in cm/s

Classes

DataModeSwitch(data_mode)

Descriptor class to access boolean data_mode switches.

KwargsAccessorWithDefault(kwarg[, default])

Descriptor class to access a kwarg dictionary with defaults.

MetaDataAccessor(property_name[, default])

Generic descriptor class that allows handy access of properties without long boilerplate code.

UserCosmology(H0, Om0, Tcmb0[, ...])

Dummy cosmology class that behaves like an Astropy cosmology, except that the luminosity distance is fixed to the user‐specified value.