sourcetools

sourcetools.density module

xga.sourcetools.density.inv_abel_fitted_model(sources, model, fit_method='mcmc', outer_radius='r500', num_dens=True, use_peak=True, pix_step=1, min_snr=0.0, abund_table='angr', lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, psf_corr=True, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, num_walkers=20, num_steps=20000, num_samples=10000, group_spec=True, min_counts=5, min_sn=None, over_sample=None, obs_id=None, inst=None, conv_temp=None, conv_outer_radius='r500', inv_abel_method=None, num_cores=1, show_warn=True)[source]

A photometric galaxy cluster gas density calculation method where a surface brightness profile is fit with a model and an inverse abel transform is used to infer the 3D count-rate/volume profile. Then a conversion factor calculated from simulated spectra is used to infer the number density profile.

Depending on the chosen surface brightness model, the inverse abel transform may be performed using an analytical solution, or numerical methods.

Parameters
  • sources (GalaxyCluster/ClusterSample) – A GalaxyCluster or ClusterSample object to measure density profiles for.

  • model (str/List[str]/BaseModel1D/List[BaseModel1D]) – The model(s) to be fit to the cluster surface profile(s). You may pass the string name of a model (for single or multiple clusters), a single instance of an XGA model class (for single or multiple clusters), a list of string names (one entry for each cluster being analysed), or a list of XGA model instances (one entry for each cluster being analysed).

  • fit_method (str) – The method for the profile object to use to fit the model, default is mcmc.

  • outer_radius (str/Quantity) –

  • num_dens (bool) – If True then a number density profile will be generated, otherwise a mass density profile will be generated.

  • use_peak (bool) – If true the measured peak will be used as the central coordinate of the profile.

  • pix_step (int) – The width (in pixels) of each annular bin for the profiles, default is 1.

  • min_snr (int/float) – The minimum allowed signal to noise for the surface brightness profiles. Default is 0, which disables automatic re-binning.

  • abund_table (str) – Which abundance table should be used for the XSPEC fit, FakeIt run, and for the electron/hydrogen number density ratio.

  • lo_en (Quantity) – The lower energy limit of the combined ratemap used to calculate density.

  • hi_en (Quantity) – The upper energy limit of the combined ratemap used to calculate density.

  • psf_corr (bool) – Default True, whether PSF corrected ratemaps will be used to make the surface brightness profile, and thus the density (if False density results could be incorrect).

  • psf_model (str) – If PSF corrected, the PSF model used.

  • psf_bins (int) – If PSF corrected, the number of bins per side.

  • psf_algo (str) – If PSF corrected, the algorithm used.

  • psf_iter (int) – If PSF corrected, the number of algorithm iterations.

  • num_walkers (int) – If using mcmc fitting, the number of walkers to use. Default is 20.

  • num_steps (int) – If using mcmc fitting, the number of steps each walker should take. Default is 20000.

  • num_samples (int) – The number of samples drawn from the posterior distributions of model parameters after the fitting process is complete.

  • group_spec (bool) – Whether the spectra that were used for fakeit were grouped.

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

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

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

  • obs_id (str/list) – A specific ObsID(s) to measure the density from. This should be a string if a single source is being analysed, and a list of ObsIDs the same length as the number of sources otherwise. The default is None, in which case the combined data will be used to measure the density profile.

  • inst (str/list) – A specific instrument(s) to measure the density from. This can either be passed as a single string (e.g. ‘pn’) if only one source is being analysed, or the same instrument should be used for every source in a sample, or a list of strings if different instruments are required for each source. The default is None, in which case the combined data will be used to measure the density profile.

  • conv_temp (Quantity) –

    If set this will override XGA measured temperatures within the conv_outer_radius, and the fakeit run to calculate the normalisation conversion factor will use these temperatures. The quantity

    should have an entry for each cluster being analysed. Default is None.

  • conv_outer_radius (str/Quantity) – The outer radius within which to generate spectra and measure temperatures for the conversion factor calculation, default is ‘r500’. An astropy quantity may also be passed, with either a single value or an entry for each cluster being analysed.

  • inv_abel_method (str) – The method which should be used for the inverse abel transform of model which is fitted to the surface brightness profile. This overrides the default method for the model, which is either ‘analytical’ for models with an analytical solution to the inverse abel transform, or ‘direct’ for models which don’t have an analytical solution. Default is None.

  • num_cores (int) – The number of cores that the evselect call and XSPEC functions are allowed to use.

  • show_warn (bool) – Should fit warnings be shown on screen.

Returns

A list of the 3D gas density profiles measured by this function, though if the measurement was not successful an entry of None will be added to the list.

Return type

List[GasDensity3D]

xga.sourcetools.density.ann_spectra_apec_norm(sources, outer_radii, num_dens=True, annulus_method='min_snr', min_snr=20, min_width=<Quantity 20. arcsec>, use_combined=True, use_worst=False, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, allow_negative=False, exp_corr=True, group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, abund_table='angr', num_data_real=10000, sigma=1, num_cores=1)[source]

A method of measuring density profiles using XSPEC fits of a set of Annular Spectra. First checks whether the required annular spectra already exist and have been fit using XSPEC, if not then they are generated and fitted, and APEC normalisation profiles will be produced (with projected temperature profiles also being made as a useful extra). Then the apec normalisation profile will be used, with knowledge of the source’s redshift and chosen analysis cosmology, to produce a density profile from the APEC normalisation.

Parameters
  • sources (GalaxyCluster/ClusterSample) – An individual or sample of sources to calculate 3D gas density profiles for.

  • outer_radii (str/Quantity) – The name or value of the outer radius to use for the generation of the spectrum (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. If you are generating for multiple sources then you can also pass a Quantity with one entry per source.

  • num_dens (bool) – If True then a number density profile will be generated, otherwise a mass density profile will be generated.

  • annulus_method (str) – The method by which the annuli are designated, this can be ‘min_snr’ (which will use the min_snr_proj_temp_prof function), or ‘growth’ (which will use the grow_ann_proj_temp_prof function).

  • min_snr (float) – The minimum signal to noise which is allowable in a given annulus.

  • min_width (Quantity) – The minimum allowable width of an annulus. The default is set to 20 arcseconds to try and avoid PSF effects.

  • use_combined (bool) – If True then the combined RateMap will be used for signal to noise annulus calculations, this is overridden by use_worst.

  • use_worst (bool) – If True then the worst observation of the cluster (ranked by global signal to noise) will be used for signal to noise annulus calculations.

  • lo_en (Quantity) – The lower energy bound of the ratemap to use for the signal to noise calculations.

  • hi_en (Quantity) – The upper energy bound of the ratemap to use for the signal to noise calculations.

  • psf_corr (bool) – Sets whether you wish to use a PSF corrected ratemap or not.

  • psf_model (str) – If the ratemap you want to use is PSF corrected, this is the PSF model used.

  • psf_bins (int) – If the ratemap you want to use is PSF corrected, this is the number of PSFs per side in the PSF grid.

  • psf_algo (str) – If the ratemap you want to use is PSF corrected, this is the algorithm used.

  • psf_iter (int) – If the ratemap you want to use is PSF corrected, this is the number of iterations.

  • allow_negative (bool) – Should pixels in the background subtracted count map be allowed to go below zero, which results in a lower signal to noise (and can result in a negative signal to noise).

  • exp_corr (bool) – Should signal to noises be measured with exposure time correction, default is True. I recommend that this be true for combined observations, as exposure time could change quite dramatically across the combined product.

  • group_spec (bool) – A boolean flag that sets whether generated spectra are grouped or not.

  • min_counts (float) – If generating a grouped spectrum, this is the minimum number of counts per channel. To disable minimum counts set this parameter to None.

  • min_sn (float) – If generating a grouped spectrum, this is the minimum signal to noise in each channel. To disable minimum signal to noise set this parameter to None.

  • over_sample (float) – The minimum energy resolution for each group, set to None to disable. e.g. if over_sample=3 then the minimum width of a group is 1/3 of the resolution FWHM at that energy.

  • one_rmf (bool) – This flag tells the method whether it should only generate one RMF for a particular ObsID-instrument combination - this is much faster in some circumstances, however the RMF does depend slightly on position on the detector.

  • abund_table (str) – The abundance table to use both for the conversion from n_exn_p to n_e^2 during density calculation, and the XSPEC fit.

  • num_data_real (int) – The number of random realisations to generate when propagating profile uncertainties.

  • sigma (int) – What sigma uncertainties should newly created profiles have, the default is 2σ.

  • num_cores (int) – The number of cores to use (if running locally), default is set to 90% of available.

Returns

A list of the 3D gas density profiles measured by this function, though if the measurement was not successful an entry of None will be added to the list.

Return type

List[GasDensity3D]

sourcetools.temperature module

xga.sourcetools.temperature.min_snr_proj_temp_prof(sources, outer_radii, min_snr=20, min_width=<Quantity 20. arcsec>, use_combined=True, use_worst=False, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, allow_negative=False, exp_corr=True, group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, abund_table='angr', num_cores=1)[source]

This is a convenience function that allows you to quickly and easily start measuring projected temperature profiles of galaxy clusters, deciding on the annular bins using signal to noise measurements from photometric products. This function calls single_temp_apec_profile, but doesn’t expose all of the more in depth variables, so if you want more control then use single_temp_apec_profile directly. The projected temperature profiles which are generated are added to their source’s storage structure.

Parameters
  • sources (GalaxyCluster/ClusterSample) – An individual or sample of sources to measure projected temperature profiles for.

  • outer_radii (str/Quantity) – The name or value of the outer radius to use for the generation of the spectra (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. If you are generating for multiple sources then you can also pass a Quantity with one entry per source.

  • min_snr (float) – The minimum signal to noise which is allowable in a given annulus.

  • min_width (Quantity) – The minimum allowable width of an annulus. The default is set to 20 arcseconds to try and avoid PSF effects.

  • use_combined (bool) – If True then the combined RateMap will be used for signal to noise annulus calculations, this is overridden by use_worst.

  • use_worst (bool) – If True then the worst observation of the cluster (ranked by global signal to noise) will be used for signal to noise annulus calculations.

  • lo_en (Quantity) – The lower energy bound of the ratemap to use for the signal to noise calculations.

  • hi_en (Quantity) – The upper energy bound of the ratemap to use for the signal to noise calculations.

  • psf_corr (bool) – Sets whether you wish to use a PSF corrected ratemap or not.

  • psf_model (str) – If the ratemap you want to use is PSF corrected, this is the PSF model used.

  • psf_bins (int) – If the ratemap you want to use is PSF corrected, this is the number of PSFs per side in the PSF grid.

  • psf_algo (str) – If the ratemap you want to use is PSF corrected, this is the algorithm used.

  • psf_iter (int) – If the ratemap you want to use is PSF corrected, this is the number of iterations.

  • allow_negative (bool) – Should pixels in the background subtracted count map be allowed to go below zero, which results in a lower signal to noise (and can result in a negative signal to noise).

  • exp_corr (bool) – Should signal to noises be measured with exposure time correction, default is True. I recommend that this be true for combined observations, as exposure time could change quite dramatically across the combined product.

  • group_spec (bool) – A boolean flag that sets whether generated spectra are grouped or not.

  • min_counts (float) – If generating a grouped spectrum, this is the minimum number of counts per channel. To disable minimum counts set this parameter to None.

  • min_sn (float) – If generating a grouped spectrum, this is the minimum signal to noise in each channel. To disable minimum signal to noise set this parameter to None.

  • over_sample (float) – The minimum energy resolution for each group, set to None to disable. e.g. if over_sample=3 then the minimum width of a group is 1/3 of the resolution FWHM at that energy.

  • one_rmf (bool) – This flag tells the method whether it should only generate one RMF for a particular ObsID-instrument combination - this is much faster in some circumstances, however the RMF does depend slightly on position on the detector.

  • abund_table (str) – The abundance table to use during the XSPEC fits.

  • num_cores (int) – The number of cores to use (if running locally), default is set to 90% of available.

Returns

A list of non-scalar astropy quantities containing the annular radii used to generate the projected temperature profiles created by this function. Each Quantity element of the list corresponds to a source.

Return type

List[Quantity]

xga.sourcetools.temperature.grow_ann_proj_temp_prof(sources, outer_radii, growth_factor=1.3, start_radius=<Quantity 20. arcsec>, num_ann=None, group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, num_cores=1)[source]

This is a convenience function that allows you to quickly and easily start measuring projected temperature profiles of galaxy clusters where the outer radius of each annulus is some factor larger than that of the last annulus:

\[R_{i+1} = R_{i}F\]

If a growth factor is passed then the start radius and outer radius of a particular source will be used to solve for the number of annuli which should be generated. However if a number of annuli is passed (through num_ann), then this function will again use the start and outer radii and solve for the growth factor instead, over-riding any growth factor that may have been passed in.

This function calls single_temp_apec_profile, but doesn’t expose all of the more in depth variables, so if you want more control then use single_temp_apec_profile directly. The projected temperature profiles which are generated are added to their source’s storage structure.

Parameters
  • sources (GalaxyCluster/ClusterSample) – An individual or sample of sources to measure projected temperature profiles for.

  • outer_radii (str/Quantity) – The name or value of the outer radius to use for the generation of the spectra (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. If you are generating for multiple sources then you can also pass a Quantity with one entry per source.

  • growth_factor (float) – The factor by which the outer radius of the Nth annulus should be larger than the outer radius of the N-1th annulus. This will be over-ridden by a re-calculated value if a value is passed to num_ann.

  • start_radius (Quantity) – The radius of the innermost circular annulus, the default is 20 arcseconds, which was chosen to try and avoid PSF effects.

  • num_ann (int) – The number of annuli which should be used, default is None, in which case the value will be calculated using the growth factor, outer radius, and start radius. If this parameter is passed then growth_factor will be overridden by a recalculated value.

  • group_spec (bool) – A boolean flag that sets whether generated spectra are grouped or not.

  • min_counts (float) – If generating a grouped spectrum, this is the minimum number of counts per channel. To disable minimum counts set this parameter to None.

  • min_sn (float) – If generating a grouped spectrum, this is the minimum signal to noise in each channel. To disable minimum signal to noise set this parameter to None.

  • over_sample (float) – The minimum energy resolution for each group, set to None to disable. e.g. if over_sample=3 then the minimum width of a group is 1/3 of the resolution FWHM at that energy.

  • one_rmf (bool) – This flag tells the method whether it should only generate one RMF for a particular ObsID-instrument combination - this is much faster in some circumstances, however the RMF does depend slightly on position on the detector.

  • num_cores (int) – The number of cores to use (if running locally), default is set to 90% of available.

xga.sourcetools.temperature.onion_deproj_temp_prof(sources, outer_radii, annulus_method='min_snr', min_snr=30, min_width=<Quantity 20. arcsec>, use_combined=True, use_worst=False, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, allow_negative=False, exp_corr=True, group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, abund_table='angr', num_data_real=300, sigma=1, num_cores=1)[source]

This function will generate de-projected, three-dimensional, gas temperature profiles of galaxy clusters using the ‘onion peeling’ deprojection method. It will also generate any projected temperature profiles that may be necessary, using the method specified in the function call (the default is the minimum signal to noise annuli method). As a side effect of that process APEC normalisation profiles will also be created, as well as Emission Measure profiles. The function is an implementation of a fairly old technique, though it has been used recently in https://doi.org/10.1051/0004-6361/201731748. For a more in depth discussion of this technique and its uses I would currently recommend https://doi.org/10.1051/0004-6361:20020905.

Parameters
  • sources (GalaxyCluster/ClusterSample) – An individual or sample of sources to calculate 3D temperature profiles for.

  • outer_radii (str/Quantity) – The name or value of the outer radius to use for the generation of the spectra (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. If you are generating for multiple sources then you can also pass a Quantity with one entry per source.

  • annulus_method (str) – The method by which the annuli are designated, this can be ‘min_snr’ (which will use the min_snr_proj_temp_prof function), or ‘growth’ (which will use the grow_ann_proj_temp_prof function).

  • min_snr (float) – The minimum signal to noise which is allowable in a given annulus.

  • min_width (Quantity) – The minimum allowable width of an annulus. The default is set to 20 arcseconds to try and avoid PSF effects.

  • use_combined (bool) – If True then the combined RateMap will be used for signal to noise annulus calculations, this is overridden by use_worst.

  • use_worst (bool) – If True then the worst observation of the cluster (ranked by global signal to noise) will be used for signal to noise annulus calculations.

  • lo_en (Quantity) – The lower energy bound of the ratemap to use for the signal to noise calculations.

  • hi_en (Quantity) – The upper energy bound of the ratemap to use for the signal to noise calculations.

  • psf_corr (bool) – Sets whether you wish to use a PSF corrected ratemap or not.

  • psf_model (str) – If the ratemap you want to use is PSF corrected, this is the PSF model used.

  • psf_bins (int) – If the ratemap you want to use is PSF corrected, this is the number of PSFs per side in the PSF grid.

  • psf_algo (str) – If the ratemap you want to use is PSF corrected, this is the algorithm used.

  • psf_iter (int) – If the ratemap you want to use is PSF corrected, this is the number of iterations.

  • allow_negative (bool) – Should pixels in the background subtracted count map be allowed to go below zero, which results in a lower signal to noise (and can result in a negative signal to noise).

  • exp_corr (bool) – Should signal to noises be measured with exposure time correction, default is True. I recommend that this be true for combined observations, as exposure time could change quite dramatically across the combined product.

  • group_spec (bool) – A boolean flag that sets whether generated spectra are grouped or not.

  • min_counts (float) – If generating a grouped spectrum, this is the minimum number of counts per channel. To disable minimum counts set this parameter to None.

  • min_sn (float) – If generating a grouped spectrum, this is the minimum signal to noise in each channel. To disable minimum signal to noise set this parameter to None.

  • over_sample (float) – The minimum energy resolution for each group, set to None to disable. e.g. if over_sample=3 then the minimum width of a group is 1/3 of the resolution FWHM at that energy.

  • one_rmf (bool) – This flag tells the method whether it should only generate one RMF for a particular ObsID-instrument combination - this is much faster in some circumstances, however the RMF does depend slightly on position on the detector.

  • abund_table (str) – The abundance table to use both for the conversion from n_exn_p to n_e^2 during density calculation, and the XSPEC fit.

  • num_data_real (int) – The number of random realisations to generate when propagating profile uncertainties.

  • sigma (int) – What sigma uncertainties should newly created profiles have, the default is 1σ.

  • num_cores (int) – The number of cores to use (if running locally), default is set to 90% of available.

Returns

A list of the 3D temperature profiles measured by this function, though if the measurement was not successful an entry of None will be added to the list.

Return type

List[GasTemperature3D]

sourcetools.mass module

xga.sourcetools.mass.inv_abel_dens_onion_temp(sources, outer_radius, sb_model, dens_model, temp_model, global_radius, fit_method='mcmc', num_walkers=20, num_steps=20000, sb_pix_step=1, sb_min_snr=0.0, inv_abel_method=None, temp_min_snr=20, abund_table='angr', group_spec=True, spec_min_counts=5, spec_min_sn=None, over_sample=None, num_cores=1, show_warn=True)[source]

A convenience function that should allow the user to easily measure hydrostatic masses of a sample of galaxy clusters, elegantly dealing with any sources that have inadequate data or aren’t fit properly. For the sake of convenience, I have taken away a lot of choices that can be passed into the density and temperature measurement routines, and if you would like more control then please manually define a hydrostatic mass profile object.

This function uses the inv_abel_fitted_model density measurement function, and the onion_deproj_temp_prof temperature measurement function (with the minimum signal to noise criteria for deciding on the annular spectra sizes).

Parameters
  • sources (GalaxyCluster/ClusterSample) – The galaxy cluster, or sample of galaxy clusters, that you wish to measure hydrostatic masses for.

  • outer_radius (str/Quantity) – The radius out to which you wish to measure gas density and temperature profiles. This can either be a string radius name (like ‘r500’) or an astropy quantity. That quantity should have as many entries as there are sources.

  • sb_model (str/List[str]/BaseModel1D/List[BaseModel1D]) – The model(s) to be fit to the cluster surface profile(s). You may pass the string name of a model (for single or multiple clusters), a single instance of an XGA model class (for single or multiple clusters), a list of string names (one entry for each cluster being analysed), or a list of XGA model instances (one entry for each cluster being analysed).

  • dens_model (str/List[str]/BaseModel1D/List[BaseModel1D]) – The model(s) to be fit to the cluster density profile(s). You may pass the string name of a model (for single or multiple clusters), a single instance of an XGA model class (for single or multiple clusters), a list of string names (one entry for each cluster being analysed), or a list of XGA model instances (one entry for each cluster being analysed).

  • temp_model (str/List[str]/BaseModel1D/List[BaseModel1D]) – The model(s) to be fit to the cluster temperature profile(s). You may pass the string name of a model (for single or multiple clusters), a single instance of an XGA model class (for single or multiple clusters), a list of string names (one entry for each cluster being analysed), or a list of XGA model instances (one entry for each cluster being analysed).

  • global_radius (str/Quantity) – This is a radius for a ‘global’ temperature measurement, which is both used as an initial check of data quality, and feeds into the conversion factor required for density measurements. This may also be passed as either a named radius or a quantity.

  • fit_method (str) – The method to use for fitting profiles within this function, default is ‘mcmc’.

  • num_walkers (int) – If fit_method is ‘mcmc’ this is the number of walkers to initialise for the ensemble sampler.

  • num_steps (int) – If fit_method is ‘mcmc’ this is the number steps for each walker to take.

  • sb_pix_step (int) – The width (in pixels) of each annular bin for the surface brightness profiles, default is 1.

  • sb_min_snr (int/float) – The minimum allowed signal to noise for the surface brightness profiles. Default is 0, which disables automatic re-binning.

  • inv_abel_method (str) – The method which should be used for the inverse abel transform of the model which is fitted to the surface brightness profile. This overrides the default method for the model, which is either ‘analytical’ for models with an analytical solution to the inverse abel transform, or ‘direct’ for models which don’t have an analytical solution. Default is None.

  • temp_min_snr (int/float) – The minimum signal to noise for a temperature measurement annulus, default is 30.

  • abund_table (str) – The abundance table to use for fitting, and the conversion factor required during density calculations.

  • group_spec (bool) – A boolean flag that sets whether generated spectra are grouped or not.

  • spec_min_counts (int) – If generating a grouped spectrum, this is the minimum number of counts per channel. To disable minimum counts set this parameter to None.

  • spec_min_sn (float) – If generating a grouped spectrum, this is the minimum signal to noise in each channel. To disable minimum signal to noise set this parameter to None.

  • over_sample (bool) – The minimum energy resolution for each group, set to None to disable. e.g. if over_sample=3 then the minimum width of a group is 1/3 of the resolution FWHM at that energy.

  • num_cores (int) – The number of cores on your local machine which this function is allowed, default is 90% of the cores in your system.

  • show_warn (bool) – Should profile fit warnings be shown, or only stored in the profile models.

Returns

A list of the hydrostatic mass profiles measured by this function, though if the measurement was not successful an entry of None will be added to the list.

Return type

List[HydrostaticMass]

sourcetools.match module

xga.sourcetools.match.simple_xmm_match(src_ra, src_dec, distance=<Quantity 30. arcmin>)[source]

Returns ObsIDs within a given distance from the input ra and dec values.

Parameters
  • src_ra (float) – RA coordinate of the source, in degrees.

  • src_dec (float) – DEC coordinate of the source, in degrees.

  • distance (Quantity) – The distance to search for XMM observations within, default should be able to match a source on the edge of an observation to the centre of the observation.

Returns

The ObsID, RA_PNT, and DEC_PNT of matching XMM observations.

Return type

DataFrame

sourcetools.misc module

xga.sourcetools.misc.nh_lookup(coord_pair)[source]

Uses HEASOFT to lookup hydrogen column density for given coordinates.

Parameters

coord_pair (Quantity) – An astropy quantity with RA and DEC of interest.

Returns

Average and weighted average nH values (in units of cm$^{-2}$)

Return type

ndarray

xga.sourcetools.misc.rad_to_ang(rad, z, cosmo=FlatLambdaCDM(name="Planck15", H0=67.7 km / (Mpc s), Om0=0.307, Tcmb0=2.725 K, Neff=3.05, m_nu=[0. 0. 0.06] eV, Ob0=0.0486))[source]

Converts radius in length units to radius on sky in degrees.

Parameters
  • rad (Quantity) – Radius for conversion.

  • cosmo (Cosmology) – An instance of an astropy cosmology, the default is Planck15.

  • z (float) – The _redshift of the source.

Returns

The radius in degrees.

Return type

Quantity

xga.sourcetools.misc.ang_to_rad(ang, z, cosmo=FlatLambdaCDM(name="Planck15", H0=67.7 km / (Mpc s), Om0=0.307, Tcmb0=2.725 K, Neff=3.05, m_nu=[0. 0. 0.06] eV, Ob0=0.0486))[source]

The counterpart to rad_to_ang, this converts from an angle to a radius in kpc.

Parameters
  • ang (Quantity) – Angle to be converted to radius.

  • cosmo (Cosmology) – An instance of an astropy cosmology, the default is Planck15.

  • z (float) – The _redshift of the source.

Returns

The radius in kpc.

Return type

Quantity

xga.sourcetools.misc.name_to_coord(name)[source]

I’d like it to be known that I hate papers and resources that either only give the name of an object or its sexagesimal coordinates - however it happens upsettingly often so here we are. This function will take a standard format name (e.g. XMMXCS J041853.9+555333.7) and return RA and DEC in degrees.

Parameters

name

xga.sourcetools.misc.coord_to_name(coord_pair, survey=None)[source]

This was originally just written in the init of BaseSource, but I figured I should split it out into its own function really. This will take a coordinate pair, and optional survey name, and spit out an object name in the standard format.

Returns

Source name based on coordinates.

Return type

str

xga.sourcetools.misc.model_check(sources, model)[source]

Very simple function that checks if a passed set of models is appropriately structured for the number of sources that have been passed. I can’t imagine why a user would need this directly, its only here as these checks have to be performed in multiple places in sourcetools.

Parameters
  • sources (List[BaseSource]/BaseSample/BaseSource) – The source(s).

  • model (str/List[str]/BaseModel1D/List[BaseModel1D]) – The model(s).

Returns

A list of model instances, or names of models.

Return type

Union[List[BaseModel1D], List[str]]

sourcetools.stack module

xga.sourcetools.stack.radial_data_stack(sources, scale_radius='r200', use_peak=True, pix_step=1, radii=array([0.01, 0.06210526, 0.11421053, 0.16631579, 0.21842105, 0.27052632, 0.32263158, 0.37473684, 0.42684211, 0.47894737, 0.53105263, 0.58315789, 0.63526316, 0.68736842, 0.73947368, 0.79157895, 0.84368421, 0.89578947, 0.94789474, 1. ]), min_snr=0.0, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, custom_temps=None, sim_met=0.3, abund_table='angr', psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, num_cores=1)[source]

Creates and scales radial brightness profiles for a set of galaxy clusters so that they can be combined and compared, like for like. This particular function does not fit models, and outputs a mean brightness profile, as well as the scaled stack data and covariance matrices. This is based on the method in https://doi.org/10.1093/mnras/stv1366, though modified to work with profiles rather than 2D images.

Parameters
  • sources (ClusterSample) – The source objects that will contribute to the stacked brightness profile.

  • scale_radius (str) – The overdensity radius to scale the cluster radii by, all GalaxyCluster objects must have an entry for this radius.

  • use_peak (bool) – Controls whether the peak position is used as the centre of the brightness profile for each GalaxyCluster object.

  • pix_step (int) – The width (in pixels) of each annular bin for the individual profiles, default is 1.

  • radii (ndarray) – The radii (in units of scale_radius) at which to measure and stack surface brightness.

  • min_snr (int/float) – The minimum allowed signal to noise for individual cluster profiles. Default is 0, which disables automatic rebinning.

  • lo_en (Quantity) – The lower energy limit of the data that goes into the stacked profiles.

  • hi_en (Quantity) – The upper energy limit of the data that goes into the stacked profiles.

  • custom_temps (Quantity) – Temperatures at which to calculate conversion factors for each cluster in sources, they will overwrite any temperatures measured by XGA. A single temperature can be passed to be used for all clusters in sources. If None, appropriate temperatures will be retrieved from the source objects.

  • sim_met (float/List) – The metallicity(s) to use when calculating the conversion factor. Pass a single float to use the same value for all sources, or pass a list to use a different value for each.

  • abund_table (str) – The abundance table to use for the temperature fit and conversion factor calculation.

  • psf_corr (bool) – If True, PSF corrected ratemaps will be used to make the brightness profile stack.

  • psf_model (str) – If PSF corrected, the PSF model used.

  • psf_bins (int) – If PSF corrected, the number of bins per side.

  • psf_algo (str) – If PSF corrected, the algorithm used.

  • psf_iter (int) – If PSF corrected, the number of algorithm iterations.

  • num_cores (int) – The number of cores to use when calculating the brightness profiles, the default is 90% of available cores.

Returns

This function returns the average profile, the scaled brightness profiles with the cluster changing along the y direction and the bin changing along the x direction, an array of the radii at which the brightness was measured (in units of scale_radius), and finally the covariance matrix and normalised covariance matrix. I also return a list of source names that WERE included in the stack.

Return type

Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, list]

xga.sourcetools.stack.view_radial_data_stack(sources, scale_radius='r200', use_peak=True, pix_step=1, radii=array([0.01, 0.06210526, 0.11421053, 0.16631579, 0.21842105, 0.27052632, 0.32263158, 0.37473684, 0.42684211, 0.47894737, 0.53105263, 0.58315789, 0.63526316, 0.68736842, 0.73947368, 0.79157895, 0.84368421, 0.89578947, 0.94789474, 1. ]), min_snr=0.0, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, custom_temps=None, sim_met=0.3, abund_table='angr', psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, num_cores=1, show_images=False, figsize=(14, 14))[source]

A convenience function that calls radial_data_stack and makes plots of the average profile, individual profiles, covariance, and normalised covariance matrix.

Parameters
  • sources (ClusterSample) – The source objects that will contribute to the stacked brightness profile.

  • scale_radius (str) – The overdensity radius to scale the cluster radii by, all GalaxyCluster objects must have an entry for this radius.

  • use_peak (bool) – Controls whether the peak position is used as the centre of the brightness profile for each GalaxyCluster object.

  • pix_step (int) – The width (in pixels) of each annular bin for the individual profiles, default is 1.

  • radii (ndarray) – The radii (in units of scale_radius) at which to measure and stack surface brightness.

  • min_snr (int/float) – The minimum allowed signal to noise for individual cluster profiles. Default is 0, which disables automatic rebinning.

  • lo_en (Quantity) – The lower energy limit of the data that goes into the stacked profiles.

  • hi_en (Quantity) – The upper energy limit of the data that goes into the stacked profiles.

  • custom_temps (Quantity) – Temperatures at which to calculate conversion factors for each cluster in sources, they will overwrite any temperatures measured by XGA. A single temperature can be passed to be used for all clusters in sources. If None, appropriate temperatures will be retrieved from the source objects.

  • sim_met (float/List) – The metallicity(s) to use when calculating the conversion factor. Pass a single float to use the same value for all sources, or pass a list to use a different value for each.

  • abund_table (str) – The abundance table to use for the temperature fit and conversion factor calculation.

  • psf_corr (bool) – If True, PSF corrected ratemaps will be used to make the brightness profile stack.

  • psf_model (str) – If PSF corrected, the PSF model used.

  • psf_bins (int) – If PSF corrected, the number of bins per side.

  • psf_algo (str) – If PSF corrected, the algorithm used.

  • psf_iter (int) – If PSF corrected, the number of algorithm iterations.

  • num_cores (int) – The number of cores to use when calculating the brightness profiles, the default is 90% of available cores.

  • show_images (bool) – If true then for each source in the stack an image and profile will be displayed side by side, with annuli overlaid on the image.

  • figsize (tuple) – The desired figure size for the plot.

xga.sourcetools.stack.radial_model_stack(sources, model, scale_radius='r200', fit_method='mcmc', use_peak=True, model_priors=None, model_start_pars=None, pix_step=1, radii=array([0.01, 0.06210526, 0.11421053, 0.16631579, 0.21842105, 0.27052632, 0.32263158, 0.37473684, 0.42684211, 0.47894737, 0.53105263, 0.58315789, 0.63526316, 0.68736842, 0.73947368, 0.79157895, 0.84368421, 0.89578947, 0.94789474, 1. ]), min_snr=0.0, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, custom_temps=None, sim_met=0.3, abund_table='angr', psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, num_cores=1, model_realisations=500, conf_level=90, num_walkers=20, num_steps=20000)[source]

Creates, fits, and scales radial brightness profiles for a set of galaxy clusters so that they can be combined and compared, like for like. This function fits models of a user’s choice, and then uses the models to retrieve brightness values at user-defined radii as a fraction of the scale radius. From that point it functions much as radial_data_stack does.

Parameters
  • sources (ClusterSample) – The source objects that will contribute to the stacked brightness profile.

  • model (str) – The model to fit to the brightness profiles.

  • scale_radius (str) – The overdensity radius to scale the cluster radii by, all GalaxyCluster objects must have an entry for this radius.

  • fit_method (str) – The method to use when fitting the model to the profile.

  • use_peak (bool) – Controls whether the peak position is used as the centre of the brightness profile for each GalaxyCluster object.

  • model_priors (list) – A list of priors to use when fitting the model with MCMC, default is None in which case the default priors for the selected model are used.

  • model_start_pars (list) – A list of start parameters to use when fitting with methods like curve_fit, default is None in which case the default start parameters for the selected model are used.

  • pix_step (int) – The width (in pixels) of each annular bin for the individual profiles, default is 1.

  • radii (ndarray) – The radii (in units of scale_radius) at which to measure and stack surface brightness.

  • min_snr (int/float) – The minimum allowed signal to noise for individual cluster profiles. Default is 0, which disables automatic rebinning.

  • lo_en (Quantity) – The lower energy limit of the data that goes into the stacked profiles.

  • hi_en (Quantity) – The upper energy limit of the data that goes into the stacked profiles.

  • custom_temps (Quantity) – Temperatures at which to calculate conversion factors for each cluster in sources, they will overwrite any temperatures measured by XGA. A single temperature can be passed to be used for all clusters in sources. If None, appropriate temperatures will be retrieved from the source objects.

  • sim_met (float/List) – The metallicity(s) to use when calculating the conversion factor. Pass a single float to use the same value for all sources, or pass a list to use a different value for each.

  • abund_table (str) – The abundance table to use for the temperature fit and conversion factor calculation.

  • psf_corr (bool) – If True, PSF corrected ratemaps will be used to make the brightness profile stack.

  • psf_model (str) – If PSF corrected, the PSF model used.

  • psf_bins (int) – If PSF corrected, the number of bins per side.

  • psf_algo (str) – If PSF corrected, the algorithm used.

  • psf_iter (int) – If PSF corrected, the number of algorithm iterations.

  • num_cores (int) – The number of cores to use when calculating the brightness profiles, the default is 90% of available cores.

  • model_realisations (int) – The number of random realisations of a model to generate.

  • conf_level (int) – The confidence level at which to measure uncertainties of parameters and profiles.

  • num_walkers (int) – The number of walkers in the MCMC ensemble sampler.

  • num_steps (int) – The number of steps in the chain that each walker should take.

Returns

This function returns the average profile, the scaled brightness profiles with the cluster changing along the y direction and the bin changing along the x direction, an array of the radii at which the brightness was measured (in units of scale_radius), and finally the covariance matrix and normalised covariance matrix. I also return a list of source names that WERE included in the stack.

Return type

Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, list]

xga.sourcetools.stack.view_radial_model_stack(sources, model, scale_radius='r200', fit_method='mcmc', use_peak=True, model_priors=None, model_start_pars=None, pix_step=1, radii=array([0.01, 0.06210526, 0.11421053, 0.16631579, 0.21842105, 0.27052632, 0.32263158, 0.37473684, 0.42684211, 0.47894737, 0.53105263, 0.58315789, 0.63526316, 0.68736842, 0.73947368, 0.79157895, 0.84368421, 0.89578947, 0.94789474, 1. ]), min_snr=0.0, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>, custom_temps=None, sim_met=0.3, abund_table='angr', psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, num_cores=1, model_realisations=500, conf_level=90, ml_mcmc_start=True, ml_rand_dev=0.0001, num_walkers=30, num_steps=20000, show_images=False, figsize=(14, 14))[source]

A convenience function that calls radial_model_stack and makes plots of the average profile, individual profiles, covariance, and normalised covariance matrix.

Parameters
  • sources (ClusterSample) – The source objects that will contribute to the stacked brightness profile.

  • model (str) – The model to fit to the brightness profiles.

  • scale_radius (str) – The overdensity radius to scale the cluster radii by, all GalaxyCluster objects must have an entry for this radius.

  • fit_method (str) – The method to use when fitting the model to the profile.

  • use_peak (bool) – Controls whether the peak position is used as the centre of the brightness profile for each GalaxyCluster object.

  • model_priors (list) – A list of priors to use when fitting the model with MCMC, default is None in which case the default priors for the selected model are used.

  • model_start_pars (list) – A list of start parameters to use when fitting with methods like curve_fit, default is None in which case the default start parameters for the selected model are used.

  • pix_step (int) – The width (in pixels) of each annular bin for the individual profiles, default is 1.

  • radii (ndarray) – The radii (in units of scale_radius) at which to measure and stack surface brightness.

  • min_snr (int/float) – The minimum allowed signal to noise for individual cluster profiles. Default is 0, which disables automatic rebinning.

  • lo_en (Quantity) – The lower energy limit of the data that goes into the stacked profiles.

  • hi_en (Quantity) – The upper energy limit of the data that goes into the stacked profiles.

  • custom_temps (Quantity) – Temperatures at which to calculate conversion factors for each cluster in sources, they will overwrite any temperatures measured by XGA. A single temperature can be passed to be used for all clusters in sources. If None, appropriate temperatures will be retrieved from the source objects.

  • sim_met (float/List) – The metallicity(s) to use when calculating the conversion factor. Pass a single float to use the same value for all sources, or pass a list to use a different value for each.

  • abund_table (str) – The abundance table to use for the temperature fit and conversion factor calculation.

  • psf_corr (bool) – If True, PSF corrected ratemaps will be used to make the brightness profile stack.

  • psf_model (str) – If PSF corrected, the PSF model used.

  • psf_bins (int) – If PSF corrected, the number of bins per side.

  • psf_algo (str) – If PSF corrected, the algorithm used.

  • psf_iter (int) – If PSF corrected, the number of algorithm iterations.

  • num_cores (int) – The number of cores to use when calculating the brightness profiles, the default is 90% of available cores.

  • model_realisations (int) – The number of random realisations of a model to generate.

  • conf_level (int) – The confidence level at which to measure uncertainties of parameters and profiles.

  • ml_mcmc_start (bool) – If True then maximum likelihood estimation will be used to generate start parameters for MCMC fitting, otherwise they will be randomly drawn from parameter priors

  • ml_rand_dev (float) – The scale of the random deviation around start parameters used for starting the different walkers in the MCMC ensemble sampler.

  • num_walkers (int) – The number of walkers in the MCMC ensemble sampler.

  • num_steps (int) – The number of steps in the chain that each walker should take.

  • show_images (bool) – If true then for each source in the stack an image and profile will be displayed side by side, with annuli overlaid on the image.

  • figsize (tuple) – The desired figure size for the plot.

sourcetools.deproj module

xga.sourcetools.deproj.shell_ann_vol_intersect(shell_radii, ann_radii)[source]

This function calculates the volume intersection matrix of a set of circular annuli and a set of spherical shells. It is assumed that the annuli and shells have the same x and y origin. The intersection is derived using simple geometric considerations, have a look in the appendix of DOI 10.1086/300836.

Parameters
  • shell_radii (ndarray/Quantity) – The radii of the spherical shells.

  • ann_radii (ndarray/Quantity) – The radii of the circular annuli (DOES NOT need to be the same length as shell_radii).

Returns

A 2D array containing the volumes of intersections between the circular annuli defined by i_ann and o_ann, and the spherical shells defined by i_sph and o_sph. Annular radii are along the ‘x’ axis and shell radii are along the ‘y’ axis.

Return type

Union[np.ndarray, Quantity]

xga.sourcetools.deproj.shell_volume(inn_radius, out_radius)[source]

Silly little function that calculates the volume of a spherical shell with inner radius inn_radius and outer radius out_radius.

Parameters
  • inn_radius (Quantity/np.ndarray) – The inner radius of the spherical shell.

  • out_radius (Quantity/np.ndarray) – The outer radius of the spherical shell.

Returns

The volume of the specified shell

Return type

Union[Quantity, np.ndarray]