The K-correction Module
- class atelier.kcorrection.KCorrection(cosmology)
Base class for an astronomical K-correction.
- cosmology
Cosmology
- Type:
astropy.cosmology.Cosmology
- M2m(mag, redsh)
Calculate the apparent (observed) magnitude based on the rest-frame absolute magnitude and redshift using the K-correction and specified cosmology.
- Parameters:
mag (float) – Absolute magnitude
redsh (float) – Redshift
- Returns:
Apparent magnitude
- evaluate(mag, redsh)
Evaluate the K-correction for an object of given apparent magnitude and redshift.
This method is not implemented and will be overwritten by children methods.
- Parameters:
mag (float) – Magnitude
redsh (float) – Redshift
- Returns:
None
- m2M(mag, redsh)
Calculate the rest-frame absolute magnitude based on the apparent (observed) source magnitude and redshift using the K-correction and specified cosmology.
- Parameters:
mag (float) – Magnitude
redsh (float) – Redshift
- Returns:
Absolute magnitude
- class atelier.kcorrection.KCorrectionGrid(mag_range, redsh_range, mag_bins, redsh_bins, cosmology, kcorrgrid=None, min_n_per_bin=11)
K-correction between the observed filter band and the rest-frame filter band determined on a grid of data.
Note that an astronomical K-correction is specific to the filter bands for which it was determined. The current implementation relies on the user’s understanding of the K-correction in order to apply it properly.
The K-correction is calculated in redshift and rest-frame magnitude bins on a grid of data for which redshift, rest-frame magnitudes (either from the continuum or through a filter band) and observed frame apparent magnitudes through a filter band are provided. The bins are then interpolated to provide a smooth K-correction as a function of apparent magnitude and redshift.
- mag_range
Magnitude range over which the quasar selection function is evaluated.
- Type:
(tuple)
- redsh_range
Redshift range over which the quasar selection function is evaluated.
- Type:
(tuple)
- mag_bins
Number of bins in magnitude
- Type:
(int)
- redsh_bins
Number of bins in redshift
- Type:
(int)
- cosmology
Cosmology
- Type:
astropy.cosmology.Cosmology
- slope
Slope of the power law (in frequency)
- Type:
float
- kcorrgird
Grid of K-correction values
- Type:
np.ndarray
- calc_kcorrection_from_df(df, redshift_col_name, mag_col_name, appmag_col_name, n_per_bin=None, statistic='median', inverse=True, verbose=1)
Calculate the K-correction grid from a data frame
- Parameters:
df (pandas.DataFrame) – Data frame with redshift, absolute reference (filter band) magnitude, and apparent (filter band) magnitude
redshift_col_name (string) – Name of the redshift column in the data frame.
mag_col_name (string) – Name of the absolute reference (filter band) magnitude column in the data frame.
appmag_col_name (string) – Name of the apparent (filter band) magnitude column in the data frame
n_per_bin (int) – Number of sources per bin (default = None). This keyword argument is used to check whether the redshift and magnitude ranges and the number of bins per dimension produce a uniform distribution of sources per bin.
statistic (string (default = 'median')) – A string indicating whether to use the ‘median’ or ‘mean’ of the K-correction value in the bin when calculating the grid.
inverse – Boolean to indicate whether inverse kcorrection will
be calculated (default=True). :type inverse: bool :param verbose: Verbosity :type verbose: int :return: None
- evaluate(mag, redsh, inverse=False)
Evaluate the K-correction for an object of given apparent magnitude and redshift.
- Parameters:
mag (float) – Magnitude
redsh (float) – Redshift
- Returns:
K-correction
- Return type:
float
- get_inv_kcorrection_from_grid()
Interpolate the inverse K-correction grid (apparent magnitude, redshift) using a linear interpolation over a rectangular mesh
- Returns:
None
- get_kcorrection_from_grid()
Interpolate the K-correction grid (absolute magnitude, redshift) using a linear interpolation over a rectangular mesh
- Returns:
None
- plot_grid(title=None, ylabel=None, show_mad=False)
Plot the K-correction grid values using matplotlib.
- Parameters:
title (string) – Title of the plot
ylabel (string) – String for the y-label of the plot.
show_mad (bool (default = False)) – Boolean to indicate whether to show the median absolute deviation of the K-correction instead of the mean/median values.
- Returns:
None
- plot_kcorrection(redsh_arr=None, mag_arr=None, ylabel=None, save=False, save_filename=None, mag_label='$M_{{1450}}={}$')
Plot the K-correction (interpolation) for a range of magnitudes over the given redshifts.
- Parameters:
redsh_arr (np.ndarray) – Array of redshifts for which the K-correction is evaluated.
mag_arr – Array of rest-frame (filter band) magnitudes for which the K-correction is evaluated over the given redshift array.
ylabel (string) – String for the y-label of the plot.
save (bool) – Boolean to indicate whether to save the plot.
save_filename (string) – Path and name to save the plot.
mag_label (string) – Label for the magnitude
- Returns:
None
- class atelier.kcorrection.KCorrectionPL(slope, cosmology)
K-correction for a power law spectrum source with a specified spectral slope per unit frequency.
Note that an astronomical K-correction is specific to the filter bands for which it was determined. The current implementation relies on the user’s understanding of the K-correction in order to apply it properly.
Only for the special case of a power law spectrum source (this case) this is independent of the astronomical filter bands.
- cosmology
Cosmology
- Type:
astropy.cosmology.Cosmology
- slope
Slope of the power law (in frequency)
- Type:
float
- evaluate(mag, redsh, inverse=False)
Evaluate the K-correction for an object of given apparent magnitude and redshift.
The power law K-correction does not depend on magnitude. Hence the argument ‘mag’ and the keyword argument ‘inverse’ play no role.
- Parameters:
mag (float) – Magnitude
redsh (float) – Redshift
- Returns:
K-correction
- Return type:
float