samples

samples.base module

class xga.samples.base.BaseSample(ra, dec, redshift=None, name=None, cosmology=LambdaCDM(name=None, H0=<Quantity 70. km / (Mpc s)>, Om0=0.3, Ode0=0.7, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=None, Ob0=None), load_products=True, load_fits=False, no_prog_bar=False)[source]

Bases: object

The superclass for all sample classes. These store whole samples of sources, to make bulk analysis of interesting X-ray sources easy. This in particular creates samples of BaseSource object. It doesn’t seem likely that users should need to declare one of these, they should use one of the general ExtendedSample or PointSample classes if they are doing exploratory analyses, or a more specific subclass like ClusterSample.

Parameters
  • ra (ndarray) – The right-ascensions of the sources, in degrees.

  • dec (ndarray) – The declinations of the sources, in degrees.

  • redshift (ndarray) – The redshifts of the sources, optional. Default is None

  • name (ndarray) – The names of the sources, optional. Default is None, in which case the names will be constructed from the coordinates.

  • cosmology (Cosmology) – An astropy cosmology object to be used in distance calculations and analyses.

  • load_products (bool) – Whether existing products should be loaded from disk.

  • load_fits (bool) – Whether existing fits should be loaded from disk.

  • no_prog_bar (bool) – Whether a progress bar should be shown as sources are declared.

property names

Property getter for the list of source names in this sample.

Returns

List of source names.

Return type

list

property ra_decs

Property getter for the list of RA-DEC positions of the sources in this sample.

Returns

List of source RA-DEC positions as supplied at sample initialisation.

Return type

Quantity

property peaks

This property getter will fetch peak coordinates for the sources in this sample. An exception will be raised if the source objects do not have a peak attribute, and a warning will be presented if all user supplied ra-dec values are the same as all peak values.

Returns

A quantity containing the peak coordinates measured for the sources in the sample.

Return type

Quantity

property redshifts

Property getter for the list of redshifts of the sources in this sample (if available). If no redshifts were supplied, None will be returned.

Returns

List of redshifts.

Return type

ndarray

property nHs

Property getter for the list of nH values of the sources in this sample.

Returns

List of nH values.

Return type

Quantity

property cosmo

Property getter for the cosmology defined at initialisation of the sample. This cosmology is what is used for all analyses performed on the sample.

Returns

The chosen cosmology.

property obs_ids

Property meant to inform the user about the number (and identities) of ObsIDs associated with the sources in a given sample.

Returns

A dictionary (where the top level keys are the source names) of the ObsIDs associated with the

individual sources in this sample. :rtype: dict

property instruments

Property meant to inform the user about the number (and identities) of instruments associated with ObsIDs associated with the sources in a given sample.

Returns

A dictionary (where the top level keys are the source names) of the instruments associated with

ObsIDs associated with the individual sources in this sample. :rtype: dict

property failed_names

Yields the names of those sources that could not be declared for some reason.

Returns

A list of source names that could not be declared.

Return type

List[str]

property failed_reasons

Returns a dictionary containing sources that failed to be declared successfully, and a simple reason why they couldn’t be.

Returns

A dictionary of source names as keys, and reasons as values.

Return type

Dict[str, str]

property suppressed_warnings

A property getter for a dictionary of the suppressed warnings that occurred during the declaration of sources for this sample.

Returns

A dictionary with source name as keys, and lists of warning text as values. Sources are only included if they have had suppressed warnings.

Return type

Dict[str, List[str]]

Lx(outer_radius, model, inner_radius=<Quantity 0. arcsec>, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, group_spec=True, min_counts=5, min_sn=None, over_sample=None, quality_checks=True)[source]

A get method for luminosities measured for the constituent sources of this sample. An error will be thrown if luminosities haven’t been measured for the given region and model, no default model has been set, unlike the Tx method of ClusterSample. An extra condition that aims to only return ‘good’ data has been included, so that any Lx measurement with an uncertainty greater than value will be set to NaN, and a warning will be issued.

Parameters
  • model (str) – The name of the fitted model that you’re requesting the luminosities from (e.g. constant*tbabs*apec).

  • outer_radius (str/Quantity) – The name or value of the outer radius that was used for the generation of the spectra which were fitted to produce the desired result (for instance ‘r200’ would be acceptable for a GalaxyCluster, or Quantity(1000, ‘kpc’)). You may also pass a quantity containing radius values, with one value for each source in this sample.

  • inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectra which were fitted to produce the desired result (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum. You may also pass a quantity containing radius values, with one value for each source in this sample.

  • lo_en (Quantity) – The lower energy limit for the desired luminosity measurement.

  • hi_en (Quantity) – The upper energy limit for the desired luminosity measurement.

  • group_spec (bool) – Whether the spectra that were fitted for the desired result were grouped.

  • min_counts (float) – The minimum counts per channel, if the spectra that were fitted for the desired result were grouped by minimum counts.

  • min_sn (float) – The minimum signal to noise per channel, if the spectra that were fitted for the desired result were grouped by minimum signal to noise.

  • over_sample (float) – The level of oversampling applied on the spectra that were fitted.

  • quality_checks (bool) – Whether the quality checks to make sure a returned value is good enough to use should be performed.

Returns

An Nx3 array Quantity where N is the number of sources. First column is the luminosity, second column is the -err, and 3rd column is the +err. If a fit failed then that entry will be NaN

Return type

Quantity

check_spectra()[source]

This method checks through the spectra associated with each source in the sample, printing a summary of which aren’t usable and the reasons.

offsets(off_unit=Unit('arcmin'))[source]

Uses the offset method built into the sources to fetch the offsets between ra_dec and peak for all sources in the sample.

Parameters

off_unit (Unit/str) – The desired unit for the offsets to be in.

Returns

The offsets.

Return type

Quantity

view_offset_dist(off_unit=Unit('arcmin'), figsize=(6, 6), bins='auto', x_lims=None, x_scale='log', y_scale='log', colour='cadetblue', alpha=0.5, title='', font_size=13, data_label='', y_label='N', save_path=None)[source]

A method to create a histogram of the offsets of user from peak coordinates for the objects in this sample. A range of options to customise the plot are supplied.

Parameters
  • off_unit (Unit/str) – The desired output unit of separation, default is arcmin.

  • figsize (tuple) – The size of the figure produced.

  • bins (str/np.ndarray/int) – This is passed directly through to the plt.hist bins argument, default is auto.

  • x_lims (Quantity) – Set the limits for the x-axis, first element should be lower, second element upper. Default is None in which case matplotlib decides.

  • x_scale (str) – The scale for the x-axis, default is log.

  • y_scale (str) – The scale for the y-axis, default is log.

  • colour (str) – The colour of the bars, default is cadetblue.

  • alpha (float) – The alpha (transparency) value of the the bars, default is 0.5.

  • title (str) – A title to be added to the plot. Default is empty, which means no title will be added. Fontsize will be 1.2 times the font_size argument.

  • font_size (int) – The font_size argument sets the font_size of the axis labels. Default is 13.

  • data_label (str) – Whether the data should be labelled, default is empty. If this is set a legend will be added.

  • y_label (str) – The y-axis label, default is N.

  • save_path (str) – A path to save the figure on, optional. Default is None in which case the figure is not saved to disk.

info()[source]

Simple function to show basic information about the sample.

samples.general module

class xga.samples.general.ExtendedSample(ra, dec, redshift=None, name=None, custom_region_radius=None, use_peak=True, peak_lo_en=<Quantity 0.5 keV>, peak_hi_en=<Quantity 2. keV>, back_inn_rad_factor=1.05, back_out_rad_factor=1.5, cosmology=LambdaCDM(name=None, H0=<Quantity 70. km / (Mpc s)>, Om0=0.3, Ode0=0.7, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=None, Ob0=None), load_fits=False, no_prog_bar=False, psf_corr=False, peak_find_method='hierarchical')[source]

Bases: BaseSample

The sample class for exploring general extended sources without the extra information required to analyse more specific X-ray extended sources (like galaxy clusters).

Parameters
  • ra (np.ndarray) – The right-ascensions of the extended sources, in degrees.

  • dec (np.ndarray) – The declinations of the extended sources, in degrees.

  • redshift (np.ndarray) – The redshifts of the extended sources, optional. Default is None.

  • name (np.ndarray) – The names of the extended sources, optional. If no names are supplied then they will be constructed from the supplied coordinates.

  • custom_region_radius (Quantity) – Custom analysis region radius(ii) for these sources, optional. Either pass a scalar astropy quantity, or a non-scalar astropy quantity with length equal to the number of sources.

  • use_peak (bool) – Whether peak positions should be found and used.

  • peak_lo_en (Quantity) – The lower energy bound for the RateMap to calculate peak position from. Default is 0.5keV.

  • peak_hi_en (Quantity) – The upper energy bound for the RateMap to calculate peak position from. Default is 2.0keV.

  • back_inn_rad_factor (float) – This factor is multiplied by an analysis region radius, and gives the inner radius for the background region. Default is 1.05.

  • back_out_rad_factor (float) – This factor is multiplied by an analysis region radius, and gives the outer radius for the background region. Default is 1.5.

  • cosmology (Cosmology) – An astropy cosmology object for use throughout analysis of the source.

  • load_fits (bool) – Whether existing fits should be loaded from disk.

  • no_prog_bar (bool) – Should a source declaration progress bar be shown during setup.

  • psf_corr (bool) – Should images be PSF corrected with default settings during sample setup.

  • peak_find_method (str) – Which peak finding method should be used (if use_peak is True). Default is hierarchical, simple may also be passed.

property custom_radii

Property getter for the radii of the custom analysis regions that can be used for analysis of the extended sources in this sample. Users are not required to pass a custom analysis region so this may be NaN.

Returns

A non-scalar Quantity of the custom source radii passed in by the user.

Return type

Quantity

property custom_radii_unit

Property getter for the unit which the custom analysis radii values are stored in.

Returns

The unit that the custom radii are stored in.

Return type

Unit

class xga.samples.general.PointSample(ra, dec, redshift=None, name=None, point_radius=<Quantity 30. arcsec>, use_peak=False, peak_lo_en=<Quantity 0.5 keV>, peak_hi_en=<Quantity 2. keV>, back_inn_rad_factor=1.05, back_out_rad_factor=1.5, cosmology=LambdaCDM(name=None, H0=<Quantity 70. km / (Mpc s)>, Om0=0.3, Ode0=0.7, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=None, Ob0=None), load_fits=False, no_prog_bar=False, psf_corr=False)[source]

Bases: BaseSample

The sample class for general point sources, without the extra information required to analyse more specific X-ray point sources.

Parameters
  • ra (np.ndarray) – The right-ascensions of the point sources, in degrees.

  • dec (np.ndarray) – The declinations of the point sources, in degrees.

  • redshift (np.ndarray) – The redshifts of the point sources, optional. Default is None.

  • name (np.ndarray) – The names of the point sources, optional. If no names are supplied then they will be constructed from the supplied coordinates.

  • point_radius (Quantity) – The point source analysis region radius(ii) for this sample. Either pass a scalar astropy quantity, or a non-scalar astropy quantity with length equal to the number of sources.

  • use_peak (bool) – Whether peak positions should be found and used. For PointSample the ‘simple’ peak finding method is the only one available.

  • peak_lo_en (Quantity) – The lower energy bound for the RateMap to calculate peak position from. Default is 0.5keV.

  • peak_hi_en (Quantity) – The upper energy bound for the RateMap to calculate peak position from. Default is 2.0keV.

  • back_inn_rad_factor (float) – This factor is multiplied by an analysis region radius, and gives the inner radius for the background region. Default is 1.05.

  • back_out_rad_factor (float) – This factor is multiplied by an analysis region radius, and gives the outer radius for the background region. Default is 1.5.

  • cosmology (Cosmology) – An astropy cosmology object for use throughout analysis of the source.

  • load_fits (bool) – Whether existing fits should be loaded from disk.

  • no_prog_bar (bool) – Should a source declaration progress bar be shown during setup.

  • psf_corr (bool) – Should images be PSF corrected with default settings during sample setup.

property point_radii

Property getter for the radii of the regions used for analysis of the point sources in this sample.

Returns

A non-scalar Quantity of the point source radii used for analysis of the point sources in this sample.

Return type

Quantity

property point_radii_unit

Property getter for the unit which the point radii values are stored in.

Returns

The unit that the point radii are stored in.

Return type

Unit

samples.extended module

class xga.samples.extended.ClusterSample(ra, dec, redshift, name, r200=None, r500=None, r2500=None, richness=None, richness_err=None, wl_mass=None, wl_mass_err=None, custom_region_radius=None, use_peak=True, peak_lo_en=<Quantity 0.5 keV>, peak_hi_en=<Quantity 2. keV>, back_inn_rad_factor=1.05, back_out_rad_factor=1.5, cosmology=LambdaCDM(name=None, H0=<Quantity 70. km / (Mpc s)>, Om0=0.3, Ode0=0.7, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=None, Ob0=None), load_fits=False, clean_obs=True, clean_obs_reg='r200', clean_obs_threshold=0.3, no_prog_bar=False, psf_corr=False, peak_find_method='hierarchical')[source]

Bases: BaseSample

A sample class to be used for declaring and analysing populations of galaxy clusters, with many cluster-science specific functions, such as the ability to create common scaling relations.

Parameters
  • ra (np.ndarray) – The right-ascensions of the clusters, in degrees.

  • dec (np.ndarray) – The declinations of the clusters, in degrees.

  • redshift (np.ndarray) – The redshifts of the clusters, required for cluster analysis.

  • name (np.ndarray) – The names of the clusters.

  • r200 (Quantity) – Values for the R200s of the clusters. At least one overdensity radius must be passed.

  • r500 (Quantity) – Values for the R500s of the clusters. At least one overdensity radius must be passed.

  • r2500 (Quantity) – Values for the R2500s of the clusters. At least one overdensity radius must be passed.

  • richness (np.ndarray) – Optical richnesses of the clusters, optional.

  • richness_err (np.ndarray) – Uncertainties on the optical richnesses of the clusters, optional.

  • wl_mass (Quantity) – Weak lensing masses of the clusters, optional.

  • wl_mass_err (Quantity) – Uncertainties on the weak lensing masses of the clusters, optional.

  • custom_region_radius (Quantity) – A custom analysis region radius for this cluster, optional.

  • use_peak (bool) – Whether peak position should be found and used.

  • peak_lo_en (Quantity) – The lower energy bound for the RateMap to calculate peak position from. Default is 0.5keV

  • peak_hi_en (Quantity) – The upper energy bound for the RateMap to calculate peak position from. Default is 2.0keV.

  • back_inn_rad_factor (float) – This factor is multiplied by an analysis region radius, and gives the inner radius for the background region. Default is 1.05.

  • back_out_rad_factor (float) – This factor is multiplied by an analysis region radius, and gives the outer radius for the background region. Default is 1.5.

  • cosmology (Cosmology) – An astropy cosmology object for use throughout analysis of the source.

  • load_fits (bool) – Whether existing fits should be loaded from disk.

  • peak_find_method (str) – Which peak finding method should be used (if use_peak is True). Default is hierarchical, simple may also be passed.

  • clean_obs (bool) – Should the observations be subjected to a minimum coverage check, i.e. whether a certain fraction of a certain region is covered by an ObsID. Default is True.

  • clean_obs_reg (str) – The region to use for the cleaning step, default is R200.

  • clean_obs_threshold (float) – The minimum coverage fraction for an observation to be kept for analysis.

  • peak_find_method – Which peak finding method should be used (if use_peak is True). Default is ‘hierarchical’ (uses XGA’s hierarchical clustering peak finder), ‘simple’ may also be passed in which case the brightest unmasked pixel within the source region will be selected.

property r200_snr

Fetches and returns the R200 signal to noises from the constituent sources.

Returns

The signal to noise ration calculated at the R200.

Return type

np.ndarray

property r500_snr

Fetches and returns the R500 signal to noises from the constituent sources.

Returns

The signal to noise ration calculated at the R500.

Return type

np.ndarray

property r2500_snr

Fetches and returns the R2500 signal to noises from the constituent sources.

Returns

The signal to noise ration calculated at the R2500.

Return type

np.ndarray

property richness

Provides the richnesses of the clusters in this sample, if they were passed in on definition.

Returns

A unitless Quantity object of the richnesses and their error(s).

Return type

Quantity

property wl_mass

Provides the weak lensing masses of the clusters in this sample, if they were passed in on definition.

Returns

A Quantity object of the WL masses and their error(s), in whatever units they were when

they were passed in originally. :rtype: Quantity

property r200

Returns all the R200 values passed in on declaration, but in units of kpc.

Returns

A quantity of R200 values.

Return type

Quantity

property r500

Returns all the R500 values passed in on declaration, but in units of kpc.

Returns

A quantity of R500 values.

Return type

Quantity

property r2500

Returns all the R2500 values passed in on declaration, but in units of kpc.

Returns

A quantity of R2500 values.

Return type

Quantity

get_radius(rad_name)[source]

Similar to the BaseSource get_radius method, but more limited in that it cannot convert radii to the desired unit, this method will retrieve named overdensity radii in kpc.

Parameters

rad_name (str) – The name of the overdensity radii to retrieve; i.e. ‘r2500’, ‘r500’, or ‘r200’.

Returns

A quantity containing the overdensity radii in kpc.

Return type

Quantity

Lx(outer_radius, model='constant*tbabs*apec', inner_radius=<Quantity 0. arcsec>, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, group_spec=True, min_counts=5, min_sn=None, over_sample=None, quality_checks=True)[source]

A get method for luminosities measured for the constituent sources of this sample. An error will be thrown if luminosities haven’t been measured for the given region and model, no default model has been set, unlike the Tx method of ClusterSample. An extra condition that aims to only return ‘good’ data has been included, so that any Lx measurement with an uncertainty greater than value will be set to NaN, and a warning will be issued.

This overrides the BaseSample method, but the only difference is that this has a default model, which is what single_temp_apec fits (constant*tbabs*apec).

Parameters
  • model (str) – The name of the fitted model that you’re requesting the luminosities from (e.g. constant*tbabs*apec).

  • outer_radius (str/Quantity) – The name or value of the outer radius that was used for the generation of the spectra which were fitted to produce the desired result (for instance ‘r200’ would be acceptable for a GalaxyCluster, or Quantity(1000, ‘kpc’)). You may also pass a quantity containing radius values, with one value for each source in this sample.

  • inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectra which were fitted to produce the desired result (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum. You may also pass a quantity containing radius values, with one value for each source in this sample.

  • lo_en (Quantity) – The lower energy limit for the desired luminosity measurement.

  • hi_en (Quantity) – The upper energy limit for the desired luminosity measurement.

  • group_spec (bool) – Whether the spectra that were fitted for the desired result were grouped.

  • min_counts (float) – The minimum counts per channel, if the spectra that were fitted for the desired result were grouped by minimum counts.

  • min_sn (float) – The minimum signal to noise per channel, if the spectra that were fitted for the desired result were grouped by minimum signal to noise.

  • over_sample (float) – The level of oversampling applied on the spectra that were fitted.

  • quality_checks (bool) – Whether the quality checks to make sure a returned value is good enough to use should be performed.

Returns

An Nx3 array Quantity where N is the number of sources. First column is the luminosity, second column is the -err, and 3rd column is the +err. If a fit failed then that entry will be NaN

Return type

Quantity

Tx(outer_radius='r500', model='constant*tbabs*apec', inner_radius=<Quantity 0. arcsec>, group_spec=True, min_counts=5, min_sn=None, over_sample=None, quality_checks=True)[source]

A get method for temperatures measured for the constituent clusters of this sample. An error will be thrown if temperatures haven’t been measured for the given region (the default is R_500) and model (default is the constant*tbabs*apec model which single_temp_apec fits to cluster spectra). Any clusters for which temperature fits failed will return NaN temperatures, and with temperature greater than 25keV is considered failed, any temperature with a negative error value is considered failed, any temperature where the Tx-low err is less than zero isn’t returned, and any temperature where one of the errors is more than three times larger than the other is considered failed (if quality checks are on).

Parameters
  • model (str) – The name of the fitted model that you’re requesting the results from (e.g. constant*tbabs*apec).

  • outer_radius (str/Quantity) – The name or value of the outer radius that was used for the generation of the spectra which were fitted to produce the desired result (for instance ‘r200’ would be acceptable for a GalaxyCluster, or Quantity(1000, ‘kpc’)). If ‘region’ is chosen (to use the regions in region files), then any inner radius will be ignored. You may also pass a quantity containing radius values, with one value for each source in this sample. The default for this method is r500.

  • inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectra which were fitted to produce the desired result (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum. You may also pass a quantity containing radius values, with one value for each source in this sample.

  • group_spec (bool) – Whether the spectra that were fitted for the desired result were grouped.

  • min_counts (float) – The minimum counts per channel, if the spectra that were fitted for the desired result were grouped by minimum counts.

  • min_sn (float) – The minimum signal to noise per channel, if the spectra that were fitted for the desired result were grouped by minimum signal to noise.

  • over_sample (float) – The level of oversampling applied on the spectra that were fitted.

  • quality_checks (bool) – Whether the quality checks to make sure a returned value is good enough to use should be performed.

Returns

An Nx3 array Quantity where N is the number of clusters. First column is the temperature, second column is the -err, and 3rd column is the +err. If a fit failed then that entry will be NaN.

Return type

Quantity

gas_mass(rad_name, dens_model, method, prof_outer_rad=None, pix_step=1, min_snr=0.0, psf_corr=True, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, set_ids=None, quality_checks=True)[source]

A convenient get method for gas masses measured for the constituent clusters of this sample, though the arguments that can be passed to retrieve gas density profiles are limited to tone-down the complexity. Largely this method assumes you have measured density profiles from combined surface brightness profiles, though if you have generated density profiles from annular spectra and know their set ids you may pass them. Any more nuanced access to density profiles will have to be done yourself.

If the specified density model hasn’t been fitted to the density profile, this method will run a fit using the default settings of the fit method of XGA profiles.

A gas mass will be set to NaN if either of the uncertainties are larger than the gas mass value, if the gas mass value is less than 1e+9 solar masses, if the gas mass value is greater than 1e+16 solar masses, if quality checks are on.

Parameters
  • rad_name (str) – The name of the radius (e.g. r500) to calculate the gas mass within.

  • dens_model (str) – The model fit to the density profiles to be used to calculate gas mass. If a fit doesn’t already exist then one will be performed with default settings.

  • method (str) – The method used to generate the density profile. For a profile created by fitting a model to a surface brightness profile this should be the name of the model, for a profile from annular spectra this should be ‘spec’, and for a profile generated directly from the data of a surface brightness profile this should be ‘onion’.

  • prof_outer_rad (Quantity/str) – The outer radii of the density profiles, either a single radius name or a Quantity containing an outer radius for each cluster. For instance if you defined a ClusterSample called srcs you could pass srcs.r500 here.

  • pix_step (int) – The width of each annulus in pixels used to generate the profile, for profiles based on surface brightness.

  • min_snr (float) – The minimum signal to noise imposed upon the profile, for profiles based on surface brightness.

  • psf_corr (bool) – Is the brightness profile corrected for PSF effects, for profiles based on surface brightness.

  • psf_model (str) – If PSF corrected, the PSF model used, for profiles based on surface brightness.

  • psf_bins (int) – If PSF corrected, the number of bins per side, for profiles based on surface brightness.

  • psf_algo (str) – If PSF corrected, the algorithm used, for profiles based on surface brightness.

  • psf_iter (int) – If PSF corrected, the number of algorithm iterations, for profiles based on surface brightness.

  • set_ids (List[int]) – A list of AnnularSpectra set IDs used to generate the density profiles, if you wish to use spectrum based density profiles here.

  • quality_checks (bool) – Whether the quality checks to make sure a returned value is good enough to use should be performed.

Returns

An Nx3 array Quantity where N is the number of clusters. First column is the gas mass, second column is the -err, and 3rd column is the +err. If a fit failed then that entry will be NaN.

Return type

Quantity

hydrostatic_mass(rad_name, temp_model_name=None, dens_model_name=None, quality_checks=True)[source]

A simple method for fetching hydrostatic masses of this sample of clusters. This function is limited, and if you have generated multiple hydrostatic mass profiles you may have to use the get_hydrostatic_mass_profiles function of each source directly, or use the returned profiles from the function that generated them.

If only one hydrostatic mass profile has been generated for each source, then you do not need to specify model names, but if the same temperature and density profiles have been used to make a hydrostatic mass profile but with different models then you may use them.

A mass will be set to NaN if either of the uncertainties are larger than the mass value, if the mass value is less than 1e+12 solar masses, if the mass value is greater than 1e+16 solar masses (if quality checks are on), or if no hydrostatic mass profile is available.

Parameters
  • rad_name (str) – The name of the radius (e.g. r500) to calculate the hydrostatic mass within.

  • temp_model_name (str) – The name of the model used to fit the temperature profile used to generate the required hydrostatic mass profile, default is None.

  • dens_model_name (str) – The name of the model used to fit the density profile used to generate the required hydrostatic mass profile, default is None.

  • quality_checks (bool) – Whether the quality checks to make sure a returned value is good enough to use should be performed.

Returns

An Nx3 array Quantity where N is the number of clusters. First column is the hydrostatic mass, second column is the -err, and 3rd column is the +err. If a fit failed then that entry will be NaN.

Return type

Quantity

calc_overdensity_radii(delta, temp_model_name=None, dens_model_name=None)[source]

A convenience method that allows for the calculation of overdensity radii from hydrostatic mass profiles measured for sources in this sample. This method uses the ‘overdensity_radius’ method of each mass profile to find the radius that corresponds to the user-supplied overdensity - common choices for cluster analysis are Δ=2500, 500, and 200. Overdensity radii are defined as the radius at which the density is Δ times the critical density of the Universe at the cluster redshift.

This function is limited, and if you have generated multiple hydrostatic mass profiles you may have to use the get_hydrostatic_mass_profiles function of each source directly, or use the returned profiles from the function that generated them, then use ‘overdensity_radius’ yourself.

If only one hydrostatic mass profile has been generated for each source, then you do not need to specify model names, but if the same temperature and density profiles have been used to make a hydrostatic mass profile but with different models then you may use them.

Parameters
  • delta (int) – The overdensity factor for which a radius is to be calculated.

  • temp_model_name (str) – The name of the model used to fit the temperature profile used to generate the hydrostatic mass profile required for measuring overdensity radii, default is None.

  • dens_model_name (str) – The name of the model used to fit the density profile used to generate the hydrostatic mass profile required for measuring overdensity radii, default is None.

Returns

An astropy quantity array of the calculated radii, in kpc.

Return type

Quantity

gm_richness(rad_name, dens_model, prof_outer_rad, dens_method, x_norm=<Quantity 60.>, y_norm=<Quantity 1.e+12 solMass>, fit_method='odr', start_pars=None, pix_step=1, min_snr=0.0, psf_corr=True, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, set_ids=None, inv_efunc=False)[source]

This generates a Gas Mass vs Richness scaling relation for this sample of Galaxy Clusters.

Parameters
  • rad_name (str) – The name of the radius (e.g. r500) to measure gas mass within.

  • dens_model (str) – The model fit to the density profiles to be used to calculate gas mass. If a fit doesn’t already exist then one will be performed with default settings.

  • prof_outer_rad (Quantity/str) – The outer radii of the density profiles, either a single radius name or a Quantity containing an outer radius for each cluster. For instance if you defined a ClusterSample called srcs you could pas srcs.r500 here.

  • dens_method (str) – The method used to generate the density profile. For a profile created by fitting a model to a surface brightness profile this should be the name of the model, for a profile from annular spectra this should be ‘spec’, and for a profile generated directly from the data of a surface brightness profile this should be ‘onion’.

  • x_norm (Quantity) – Quantity to normalise the x data by.

  • y_norm (Quantity) – Quantity to normalise the y data by.

  • fit_method (str) – The name of the fit method to use to generate the scaling relation.

  • start_pars (list) – The start parameters for the fit run.

  • pix_step (int) – The width of each annulus in pixels used to generate the profile, for profiles based on surface brightness.

  • min_snr (float) – The minimum signal to noise imposed upon the profile, for profiles based on surface brightness.

  • psf_corr (bool) – Is the brightness profile corrected for PSF effects, for profiles based on surface brightness.

  • psf_model (str) – If PSF corrected, the PSF model used, for profiles based on surface brightness.

  • psf_bins (int) – If PSF corrected, the number of bins per side, for profiles based on surface brightness.

  • psf_algo (str) – If PSF corrected, the algorithm used, for profiles based on surface brightness.

  • psf_iter (int) – If PSF corrected, the number of algorithm iterations, for profiles based on surface brightness.

  • set_ids (List[int]) – A list of AnnularSpectra set IDs used to generate the density profiles, if you wish to use spectrum based density profiles here.

  • inv_efunc (bool) – Should the inverse E(z) function be applied to the y-axis, if False then the non-inverse will be applied.

Returns

The XGA ScalingRelation object generated for this sample.

Return type

ScalingRelation

gm_Tx(rad_name, dens_model, prof_outer_rad, dens_method, x_norm=<Quantity 4. keV>, y_norm=<Quantity 1.e+12 solMass>, fit_method='odr', start_pars=None, model='constant*tbabs*apec', group_spec=True, min_counts=5, min_sn=None, over_sample=None, pix_step=1, min_snr=0.0, psf_corr=True, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, set_ids=None, inv_efunc=False)[source]

This generates a Gas Mass vs Tx scaling relation for this sample of Galaxy Clusters.

Parameters
  • rad_name (str) – The name of the radius (e.g. r500) to get values for.

  • dens_model (str) – The model fit to the density profiles to be used to calculate gas mass. If a fit doesn’t already exist then one will be performed with default settings.

  • prof_outer_rad (Quantity/str) – The outer radii of the density profiles, either a single radius name or a Quantity containing an outer radius for each cluster. For instance if you defined a ClusterSample called srcs you could pas srcs.r500 here.

  • dens_method (str) – The method used to generate the density profile. For a profile created by fitting a model to a surface brightness profile this should be the name of the model, for a profile from annular spectra this should be ‘spec’, and for a profile generated directly from the data of a surface brightness profile this should be ‘onion’.

  • x_norm (Quantity) – Quantity to normalise the x data by.

  • y_norm (Quantity) – Quantity to normalise the y data by.

  • fit_method (str) – The name of the fit method to use to generate the scaling relation.

  • start_pars (list) – The start parameters for the fit run.

  • model (str) – The name of the model that the temperatures were measured with.

  • group_spec (bool) – Whether the spectra that were fitted for the Tx values were grouped.

  • min_counts (float) – The minimum counts per channel, if the spectra that were fitted for the Tx values were grouped by minimum counts.

  • min_sn (float) – The minimum signal to noise per channel, if the spectra that were fitted for the Tx values were grouped by minimum signal to noise.

  • over_sample (float) – The level of oversampling applied on the spectra that were fitted.

  • pix_step (int) – The width of each annulus in pixels used to generate the profile, for profiles based on surface brightness.

  • min_snr (float) – The minimum signal to noise imposed upon the profile, for profiles based on surface brightness.

  • psf_corr (bool) – Is the brightness profile corrected for PSF effects, for profiles based on surface brightness.

  • psf_model (str) – If PSF corrected, the PSF model used, for profiles based on surface brightness.

  • psf_bins (int) – If PSF corrected, the number of bins per side, for profiles based on surface brightness.

  • psf_algo (str) – If PSF corrected, the algorithm used, for profiles based on surface brightness.

  • psf_iter (int) – If PSF corrected, the number of algorithm iterations, for profiles based on surface brightness.

  • set_ids (List[int]) – A list of AnnularSpectra set IDs used to generate the density profiles, if you wish to use spectrum based density profiles here.

  • inv_efunc (bool) – Should the inverse E(z) function be applied to the y-axis, if False then the non-inverse will be applied.

Returns

The XGA ScalingRelation object generated for this sample.

Return type

ScalingRelation

Lx_richness(outer_radius='r500', x_norm=<Quantity 60.>, y_norm=<Quantity 1.e+44 erg / s>, fit_method='odr', start_pars=None, model='constant*tbabs*apec', lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, inner_radius=<Quantity 0. arcsec>, group_spec=True, min_counts=5, min_sn=None, over_sample=None, inv_efunc=True)[source]

This generates a Lx vs richness scaling relation for this sample of Galaxy Clusters. If you have run fits to find core excised luminosity, and wish to use it in this scaling relation, then please don’t forget to supply an inner_radius to the method call.

Parameters
  • outer_radius (str) – The name of the radius (e.g. r500) to get values for.

  • x_norm (Quantity) – Quantity to normalise the x data by.

  • y_norm (Quantity) – Quantity to normalise the y data by.

  • fit_method (str) – The name of the fit method to use to generate the scaling relation.

  • start_pars (list) – The start parameters for the fit run.

  • model (str) – The name of the model that the luminosities were measured with.

  • lo_en (Quantity) – The lower energy limit for the desired luminosity measurement.

  • hi_en (Quantity) – The upper energy limit for the desired luminosity measurement.

  • inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectra which were fitted to produce the desired result (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum. You may also pass a quantity containing radius values, with one value for each source in this sample.

  • group_spec (bool) – Whether the spectra that were fitted for the desired result were grouped.

  • min_counts (float) – The minimum counts per channel, if the spectra that were fitted for the desired result were grouped by minimum counts.

  • min_sn (float) – The minimum signal to noise per channel, if the spectra that were fitted for the desired result were grouped by minimum signal to noise.

  • over_sample (float) – The level of oversampling applied on the spectra that were fitted.

  • inv_efunc (bool) – Should the inverse E(z) function be applied to the y-axis, if False then the non-inverse will be applied.

Returns

The XGA ScalingRelation object generated for this sample.

Return type

ScalingRelation

Lx_Tx(outer_radius='r500', x_norm=<Quantity 4. keV>, y_norm=<Quantity 1.e+44 erg / s>, fit_method='odr', start_pars=None, model='constant*tbabs*apec', lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, tx_inner_radius=<Quantity 0. arcsec>, lx_inner_radius=<Quantity 0. arcsec>, group_spec=True, min_counts=5, min_sn=None, over_sample=None, inv_efunc=True)[source]

This generates a Lx vs Tx scaling relation for this sample of Galaxy Clusters. If you have run fits to find core excised luminosity, and wish to use it in this scaling relation, then you can specify the inner radius of those spectra using lx_inner_radius, as well as ensuring that you use the temperature fit you want by setting tx_inner_radius.

Parameters
  • outer_radius (str) – The name of the radius (e.g. r500) to get values for.

  • x_norm (Quantity) – Quantity to normalise the x data by.

  • y_norm (Quantity) – Quantity to normalise the y data by.

  • fit_method (str) – The name of the fit method to use to generate the scaling relation.

  • start_pars (list) – The start parameters for the fit run.

  • model (str) – The name of the model that the luminosities and temperatures were measured with.

  • lo_en (Quantity) – The lower energy limit for the desired luminosity measurement.

  • hi_en (Quantity) – The upper energy limit for the desired luminosity measurement.

  • tx_inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectra which were fitted to produce the temperature (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum. You may also pass a quantity containing radius values, with one value for each source in this sample.

  • lx_inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectra which were fitted to produce the Lx. The same rules as tx_inner_radius apply, and this option is particularly useful if you have measured core-excised luminosity an wish to use it in a scaling relation.

  • group_spec (bool) – Whether the spectra that were fitted for the desired result were grouped.

  • min_counts (float) – The minimum counts per channel, if the spectra that were fitted for the desired result were grouped by minimum counts.

  • min_sn (float) – The minimum signal to noise per channel, if the spectra that were fitted for the desired result were grouped by minimum signal to noise.

  • over_sample (float) – The level of oversampling applied on the spectra that were fitted.

  • inv_efunc (bool) – Should the inverse E(z) function be applied to the y-axis, if False then the non-inverse will be applied.

Returns

The XGA ScalingRelation object generated for this sample.

Return type

ScalingRelation

mass_Tx(outer_radius='r500', x_norm=<Quantity 4. keV>, y_norm=<Quantity 5.e+14 solMass>, fit_method='odr', start_pars=None, model='constant*tbabs*apec', tx_inner_radius=<Quantity 0. arcsec>, group_spec=True, min_counts=5, min_sn=None, over_sample=None, temp_model_name=None, dens_model_name=None, inv_efunc=False)[source]

A convenience function to generate a hydrostatic mass-temperature relation for this sample of galaxy clusters.

Parameters
  • outer_radius (str) – The outer radius of the region used to measure temperature and the radius out to which you wish to measure mass.

  • x_norm (Quantity) – Quantity to normalise the x data by.

  • y_norm (Quantity) – Quantity to normalise the y data by.

  • fit_method (str) – The name of the fit method to use to generate the scaling relation.

  • start_pars (list) – The start parameters for the fit run.

  • model (str) – The name of the model that the luminosities and temperatures were measured with.

  • tx_inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectra which were fitted to produce the temperature (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum. You may also pass a quantity containing radius values, with one value for each source in this sample.

  • group_spec (bool) – Whether the spectra that were fitted for the desired result were grouped.

  • min_counts (float) – The minimum counts per channel, if the spectra that were fitted for the desired result were grouped by minimum counts.

  • min_sn (float) – The minimum signal to noise per channel, if the spectra that were fitted for the desired result were grouped by minimum signal to noise.

  • over_sample (float) – The level of oversampling applied on the spectra that were fitted.

  • temp_model_name (str) – The name of the model used to fit the temperature profile used to generate the required hydrostatic mass profile, default is None.

  • dens_model_name (str) – The name of the model used to fit the density profile used to generate the required hydrostatic mass profile, default is None.

  • inv_efunc (bool) – Should the inverse E(z) function be applied to the y-axis, if False then the non-inverse will be applied.

Returns

The XGA ScalingRelation object generated for this sample.

Return type

ScalingRelation

mass_richness(outer_radius='r500', x_norm=<Quantity 60.>, y_norm=<Quantity 5.e+14 solMass>, fit_method='odr', start_pars=None, temp_model_name=None, dens_model_name=None, inv_efunc=False)[source]

A convenience function to generate a hydrostatic mass-richness relation for this sample of galaxy clusters.

Parameters
  • outer_radius (str) – The name of the radius (e.g. r500) to get values for.

  • x_norm (Quantity) – Quantity to normalise the x data by.

  • y_norm (Quantity) – Quantity to normalise the y data by.

  • fit_method (str) – The name of the fit method to use to generate the scaling relation.

  • start_pars (list) – The start parameters for the fit run.

  • temp_model_name (str) – The name of the model used to fit the temperature profile used to generate the required hydrostatic mass profile, default is None.

  • dens_model_name (str) – The name of the model used to fit the density profile used to generate the required hydrostatic mass profile, default is None.

  • inv_efunc (bool) – Should the inverse E(z) function be applied to the y-axis, if False then the non-inverse will be applied.

Returns

The XGA ScalingRelation object generated for this sample.

Return type

ScalingRelation

mass_Lx(outer_radius='r500', x_norm=<Quantity 1.e+44 erg / s>, y_norm=<Quantity 5.e+14 solMass>, fit_method='odr', start_pars=None, model='constant*tbabs*apec', lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, lx_inner_radius=<Quantity 0. arcsec>, group_spec=True, min_counts=5, min_sn=None, over_sample=None, temp_model_name=None, dens_model_name=None, inv_efunc=False)[source]

This generates a mass vs Lx scaling relation for this sample of Galaxy Clusters. If you have run fits to find core excised luminosity, and wish to use it in this scaling relation, then you can specify the inner radius of those spectra using lx_inner_radius.

Parameters
  • outer_radius (str) – The name of the radius (e.g. r500) to get values for.

  • x_norm (Quantity) – Quantity to normalise the x data by.

  • y_norm (Quantity) – Quantity to normalise the y data by.

  • fit_method (str) – The name of the fit method to use to generate the scaling relation.

  • start_pars (list) – The start parameters for the fit run.

  • model (str) – The name of the model that the luminosities and temperatures were measured with.

  • lo_en (Quantity) – The lower energy limit for the desired luminosity measurement.

  • hi_en (Quantity) – The upper energy limit for the desired luminosity measurement.

  • lx_inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectra which were fitted to produce the Lx. The same rules as tx_inner_radius apply, and this option is particularly useful if you have measured core-excised luminosity an wish to use it in a scaling relation.

  • group_spec (bool) – Whether the spectra that were fitted for the desired result were grouped.

  • min_counts (float) – The minimum counts per channel, if the spectra that were fitted for the desired result were grouped by minimum counts.

  • min_sn (float) – The minimum signal to noise per channel, if the spectra that were fitted for the desired result were grouped by minimum signal to noise.

  • over_sample (float) – The level of oversampling applied on the spectra that were fitted.

  • temp_model_name (str) – The name of the model used to fit the temperature profile used to generate the required hydrostatic mass profile, default is None.

  • dens_model_name (str) – The name of the model used to fit the density profile used to generate the required hydrostatic mass profile, default is None.

  • inv_efunc (bool) – Should the inverse E(z) function be applied to the y-axis, if False then the non-inverse will be applied.

Returns

The XGA ScalingRelation object generated for this sample.

Return type

ScalingRelation

samples.point module

class xga.samples.point.StarSample(ra, dec, distance=None, name=None, proper_motion=None, point_radius=<Quantity 30. arcsec>, match_radius=<Quantity 10. arcsec>, use_peak=False, peak_lo_en=<Quantity 0.5 keV>, peak_hi_en=<Quantity 2. keV>, back_inn_rad_factor=1.05, back_out_rad_factor=1.5, cosmology=LambdaCDM(name=None, H0=<Quantity 70. km / (Mpc s)>, Om0=0.3, Ode0=0.7, Tcmb0=<Quantity 0. K>, Neff=3.04, m_nu=None, Ob0=None), load_fits=False, no_prog_bar=False, psf_corr=False)[source]

Bases: BaseSample

An XGA class for the analysis of a large sample of local X-ray emitting stars. Takes information on stars to enable analysis.

Parameters
  • ra (np.ndarray) – The right-ascensions of the stars, in degrees.

  • dec (np.ndarray) – The declinations of the stars, in degrees.

  • distance (np.ndarray) – The distances to the stars in units convertible to parsecs, optional. Default is None.

  • name (np.ndarray) – The names of the stars, optional. If no names are supplied then they will be constructed from the supplied coordinates.

  • proper_motion (Quantity) – The proper motion of the stars, optional. This should be passed as a non-scalar astropy quantity; if magnitudes are passed it should be in the form Quantity([4, 5, 2, 7,…], ‘arcsec/yr’), and if vectors are passed it should be in the form Quantity([[4, 2.3], [5, 4.3], [2, 2.5], [7.2, 6.9],…], ‘arcsec/yr’), where the first is in RA and the second in Dec. Units should be convertible to arcseconds per year. Default is None

  • point_radius (Quantity) – The point source analysis region radius(ii) for this sample. Either pass a scalar astropy quantity, or a non-scalar astropy quantity with length equal to the number of sources.

  • match_radius (Quantity) – The radius within which point source regions are accepted as a match to the RAs and Dec passed by the user. The default value is 10 arcseconds.

  • use_peak (bool) – Whether peak positions should be found and used. For StarSample the ‘simple’ peak finding method is the only one available.

  • peak_lo_en (Quantity) – The lower energy bound for the RateMap to calculate peak position from. Default is 0.5keV.

  • peak_hi_en (Quantity) – The upper energy bound for the RateMap to calculate peak position from. Default is 2.0keV.

  • back_inn_rad_factor (float) – This factor is multiplied by an analysis region radius, and gives the inner radius for the background region. Default is 1.05.

  • back_out_rad_factor (float) – This factor is multiplied by an analysis region radius, and gives the outer radius for the background region. Default is 1.5.

  • cosmology (Cosmology) – An astropy cosmology object for use throughout analysis of the source.

  • load_fits (bool) – Whether existing fits should be loaded from disk.

  • no_prog_bar (bool) – Should a source declaration progress bar be shown during setup.

  • psf_corr (bool) – Should images be PSF corrected with default settings during sample setup.

property point_radii

Property getter for the radii of the regions used for analysis of the stars in this sample.

Returns

A non-scalar Quantity of the point source radii used for analysis of the stars in this sample.

Return type

Quantity

property point_radii_unit

Property getter for the unit which the point radii values are stored in.

Returns

The unit that the point radii are stored in.

Return type

Unit

property match_radius

This tells you the matching radius used during the setup of this StarSample instance.

Returns

Matching radius defined at instantiation.

Return type

Quantity

property distances

Property returning the distance to the star, as was passed in on creation of this source object.

Returns

The distance to the star.

Return type

Quantity

property proper_motions

Property returning the proper motion (absolute value or vector) of the star.

Returns

A proper motion magnitude or vector.

Return type

Quantity