The Selection Function Module

class atelier.selfun.ClippedFunction(fun, minval, maxval)

A helper class to clip output between two values.

class atelier.selfun.CompositeQsoSelectionFunction(selfun_list, mag_range=None, redsh_range=None)

Composite quasar selection function class

This class provides the capabilities for composite quasar selection functions and updates the base class evaluate and call methods accordingly.

selfun_list

List of quasar selection functions

Type:

list(atelier.selfun.QsoSelectionFunction)

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)

evaluate(mag, redsh)

Evaluate the composite selection function at magnitude and redshift.

Parameters:
  • mag (float or np.ndarray) – Magnitude at which the quasar selection function is evaluated.

  • redsh (float or np.ndarray) – Redshift at which the quasar selection function is evaluated.

Returns:

Value of selection function at given redshift and magnitude.

Return type:

float or np.ndarray

class atelier.selfun.QsoSelectionFunction(mag_range=None, redsh_range=None)

Quasar selection function class.

This class provides the basic capabilities for quasar selection functions.

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)

evaluate(mag, redsh)

Evaluate selection function at magnitude and redshift.

Parameters:
  • mag (float or np.ndarray) – Magnitude at which the quasar selection function is evaluated.

  • redsh (float or np.ndarray) – Redshift at which the quasar selection function is evaluated.

Returns:

Value of selection function at given redshift and magnitude.

Return type:

float or np.ndarray

plot_selfun(mag_res=0.01, redsh_res=0.01, mag_range=None, redsh_range=None, title=None, levels=[0.2, 0.5, 0.7], level_color='k', cmap=<matplotlib.colors.ListedColormap object>, vmin=0, vmax=1, sample_mag=None, sample_z=None, sample_color='red', sample_mec='k', sample_marker='D', save_name=None)

Plot the selection function on a grid of redshift and magnitude.

To calculate the map of the selection function the selection function is evaluated using the .evaluate method.

If no magnitude and redshift range is provided the class attributes are used to determine the ranges.

Parameters:
  • mag_res (float) – Magnitude resolution (default = 0.01)

  • redsh_res (float) – Redshift resolution (default = 0.01)

  • mag_range (tuple) – Magnitude range over which the quasar selection function is evaluated. (default = None)

  • redsh_range (tuple) – Redshift range over which the quasar selection function is evaluated. (default = None)

  • title (string) – Title of the plot (default = None)

  • levels (list(float)) – Values of contour levels to plot

  • level_color (string) – Color for the level contours

  • cmap (Matplotlib colormap) – Color map for the selection function

  • save_name (string) – Populate with name to save the plot. Default=’None’

Returns:

class atelier.selfun.QsoSelectionFunctionConst(value)

Composite quasar selection function class

This class provides the capabilities for the constant quasar selection function and updates the base class evaluate and call methods accordingly.

value

Value of the constant quasar selection function

Type:

float

evaluate(mag, redsh)

Evaluate the constant selection function at magnitude and redshift.

Parameters:

redsh (float or np.ndarray) – Redshift at which the quasar selection function is evaluated.

Returns:

Value of selection function at given redshift and magnitude.

Returns:

Value of selection function at given redshift and magnitude.

Return type:

float or np.ndarray

class atelier.selfun.QsoSelectionFunctionGrid(mag_range=None, redsh_range=None, mag_bins=None, redsh_bins=None, selfungrid=None, clip=True, filename=None, format='csv')

Gridded quasar selection function class.

This class provides the capabilities for a quasar selection function calculated on a magnitude redshift grid of sources defined by a query of the source properties. It updates the base class evaluate and call methods accordingly.

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)

selfungrid

Grid with selection function values

Type:

(np.ndarray)

clip

Boolean to indicate whether to clip the output value of the selection function between 0 and 1.

Type:

(bool)

calc_selfungrid_from_df(df, mag_col_name, redshift_col_name, query=None, sel_idx=None, n_per_bin=None, verbose=1)

Calculate the selection function grid from a pandas DataFrame

Parameters:
  • df (pandas.DataFrame) – Data frame to calculate the selection function from

  • query (string) – A query describing the subsample that is compared to the full data set in order to calculate the selection function.

  • mag_col_name (string) – Name of the magnitude column in the data frame.

  • redshift_col_name (string) – Name of the redshift 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.

  • verbose (int) – Verbosity

Returns:

None

evaluate(mag, redsh)

Evaluate the interpolation of the selection function grid at magnitude and redshift.

Parameters:

redsh (float or np.ndarray) – Redshift at which the quasar selection function is evaluated.

Returns:

Value of selection function at given redshift and magnitude.

Returns:

Value of selection function at given redshift and magnitude.

Return type:

float or np.ndarray

get_selfun_from_grid()

Calculate an interpolation (RectBivariateSpline) of the selection function grid to allow evaluations of the selection function at any point within the magnitude and redshift range.

This methods need to be called before the selection function can be evaluated.

Returns:

None

load(filename, format='csv')

Load a QsoSelectionFunctionGrid from a file.

Parameters:
  • filename (string) – Filename to load a saved QsoSelectionFunctionGrid from.

  • format – File format of saved QsoSelectionFunctionGrid.

Currently implemented formats are: “.csv” :type format: string :return:

plot_grid(title=None)

Plot the selection function grid as a map of magnitude and redshift.

Parameters:

title (string) – Title of the plot

Returns:

None

save(filename, format='csv')

Save a QsoSelectionFunctionGrid object to a file

Parameters:
  • filename (string) – Filename to save the QsoSelectionFunctionGrid to.

  • format – File format of saved QsoSelectionFunctionGrid.

Currently implemented formats are: “csv” :type format: string :return: