sources

sources.base module

class xga.sources.base.BaseSource(ra, dec, redshift=None, name=None, cosmology=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), load_products=True, load_fits=False)[source]

Bases: object

The overlord of all XGA classes, the superclass for all source classes. This contains a huge amount of functionality upon which the rest of XGA is built, includes selecting observations, reading in data products, and storing newly created data products.

property ra_dec

A getter for the original ra and dec entered by the user.

Returns

The ra-dec coordinates entered by the user when the source was first defined

Return type

Quantity

property default_coord

A getter for the default analysis coordinate of this source. :return: An Astropy quantity containing the default analysis coordinate. :rtype: Quantity

update_products(prod_obj)[source]

Setter method for the products attribute of source objects. Cannot delete existing products, but will overwrite existing products. Raises errors if the ObsID is not associated with this source or the instrument is not associated with the ObsID. Lists of products can also be passed and will be added to the source storage structure, these lists may also contain None values, as typically XGA will return None if a profile fails to generate (for instance), in which case that entry will simply be ignored.

Parameters

prod_obj (BaseProduct/BaseAggregateProduct/BaseProfile1D/List[BaseProduct]/List[BaseProfile1D]) – The new product object(s) to be added to the source object.

get_products(p_type, obs_id=None, inst=None, extra_key=None, just_obj=True)[source]

This is the getter for the products data structure of Source objects. Passing a ‘product type’ such as ‘events’ or ‘images’ will return every matching entry in the products data structure.

Parameters
  • p_type (str) – Product type identifier. e.g. image or expmap.

  • obs_id (str) – Optionally, a specific obs_id to search can be supplied.

  • inst (str) – Optionally, a specific instrument to search can be supplied.

  • extra_key (str) – Optionally, an extra key (like an energy bound) can be supplied.

  • just_obj (bool) – A boolean flag that controls whether this method returns just the product objects, or the other information that goes with it like ObsID and instrument.

Returns

List of matching products.

Return type

List[BaseProduct]

update_queue(cmd_arr, p_type_arr, p_path_arr, extra_info, stack=False)[source]

Small function to update the numpy array that makes up the queue of products to be generated.

Parameters
  • cmd_arr (np.ndarray) – Array containing SAS commands.

  • p_type_arr (np.ndarray) – Array of product type identifiers for the products generated by the cmd array. e.g. image or expmap.

  • p_path_arr (np.ndarray) – Array of final product paths if cmd is successful

  • extra_info (np.ndarray) – Array of extra information dictionaries

  • stack – Should these commands be executed after a preceding line of commands, or at the same time.

Returns

get_queue()[source]

Calling this indicates that the queue is about to be processed, so this function combines SAS commands along columns (command stacks), and returns N SAS commands to be run concurrently, where N is the number of columns.

Returns

List of strings, where the strings are bash commands to run SAS procedures, another list of strings, where the strings are expected output types for the commands, a list of lists of strings, where the strings are expected output paths for products of the SAS commands.

Return type

Tuple[List[str], List[str], List[List[str]]]

get_att_file(obs_id)[source]

Fetches the path to the attitude file for an XMM observation.

Parameters

obs_id – The ObsID to fetch the attitude file for.

Returns

The path to the attitude file.

Return type

str

property obs_ids

Property getter for ObsIDs associated with this source that are confirmed to have events files.

Returns

A list of the associated XMM ObsIDs.

Return type

List[str]

property detected

A property getter to return if a match of the correct type has been found.

Returns

The detected boolean attribute.

Return type

bool

source_back_regions(reg_type, obs_id=None, central_coord=None)[source]

A method to retrieve source region and background region objects for a given source type with a given central coordinate.

Parameters
  • reg_type (str) – The type of region which we wish to get from the source.

  • obs_id (str) – The ObsID that the region is associated with (if appropriate).

  • central_coord (Quantity) – The central coordinate of the region.

Returns

The method returns both the source region and the associated background region.

Return type

within_region(region)[source]

This method finds interloper sources that lie within the user supplied region.

Parameters

region (SkyRegion) – The region in which we wish to search for interloper sources (for instance a source region or background region).

Returns

A list of regions that lie within the user supplied region.

Return type

List[SkyRegion]

get_source_mask(reg_type, obs_id=None, central_coord=None)[source]

Method to retrieve source and background masks for the given region type.

Parameters
  • reg_type (str) – The type of region for which to retrieve the mask.

  • obs_id (str) – The ObsID that the mask is associated with (if appropriate).

  • central_coord (Quantity) – The central coordinate of the region.

Returns

The source and background masks for the requested ObsID (or the combined image if no ObsID).

Return type

Tuple[np.ndarray, np.ndarray]

get_interloper_mask(obs_id=None)[source]

Returns a mask for a given ObsID (or combined data if no ObsID given) that will remove any sources that have not been identified as the source of interest.

Parameters

obs_id (str) – The ObsID that the mask is associated with (if appropriate).

Returns

A numpy array of 0s and 1s which acts as a mask to remove interloper sources.

Return type

ndarray

get_mask(reg_type, obs_id=None, central_coord=None)[source]

Method to retrieve source and background masks for the given region type, WITH INTERLOPERS REMOVED.

Parameters
  • reg_type (str) – The type of region for which to retrieve the interloper corrected mask.

  • obs_id (str) – The ObsID that the mask is associated with (if appropriate).

  • central_coord (Quantity) – The central coordinate of the region.

Returns

The source and background masks for the requested ObsID (or the combined image if no ObsID).

Return type

Tuple[np.ndarray, np.ndarray]

get_custom_mask(outer_rad, inner_rad=<Quantity 0. arcsec>, obs_id=None, central_coord=None, remove_interlopers=True)[source]

A simple, but powerful method, to generate mask a mask within a custom radius for a given ObsID.

Parameters
  • outer_rad (Quantity) – The outer radius of the mask.

  • inner_rad (Quantity) – The inner radius of the mask, the default is zero arcseconds.

  • obs_id (str) – The ObsID for which to generate the mask, default is None which will return a mask generated from a combined image.

  • central_coord (Quantity) – The central coordinates of the mask, the default is None which will use the default coordinates of the source.

  • remove_interlopers (bool) – Whether an interloper mask should be combined with the custom mask to remove interloper point sources.

Returns

A numpy array containing the desired mask.

Return type

np.ndarray

get_snr(outer_radius, central_coord=None, lo_en=None, hi_en=None, obs_id=None, inst=None, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, allow_negative=False, exp_corr=True)[source]

This takes a region type and central coordinate and calculates the signal to noise ratio. The background region is constructed using the back_inn_rad_factor and back_out_rad_factor values, the defaults of which are 1.05*radius and 1.5*radius respectively.

Parameters
  • outer_radius (Quantity/str) – The radius that SNR should be calculated within, this can either be a named radius such as r500, or an astropy Quantity.

  • central_coord (Quantity) – The central coordinate of the region.

  • lo_en (Quantity) – The lower energy bound of the ratemap to use to calculate the SNR. Default is None, in which case the lower energy bound for peak finding will be used (default is 0.5keV).

  • hi_en (Quantity) – The upper energy bound of the ratemap to use to calculate the SNR. Default is None, in which case the upper energy bound for peak finding will be used (default is 2.0keV).

  • obs_id (str) – An ObsID of a specific ratemap to use for the SNR calculation. Default is None, which means the combined ratemap will be used. Please note that inst must also be set to use this option.

  • inst (str) – The instrument of a specific ratemap to use for the SNR calculation. Default is None, which means the combined ratemap will be used.

  • 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.

Returns

The signal to noise ratio.

Return type

float

regions_within_radii(inner_radius, outer_radius, deg_central_coord, interloper_regions=None)[source]

This function finds and returns any interloper regions that have any part of their boundary within the specified radii, centered on the specified central coordinate.

Parameters
  • inner_radius (Quantity) – The inner radius of the area to search for interlopers in.

  • outer_radius (Quantity) – The outer radius of the area to search for interlopers in.

  • deg_central_coord (Quantity) – The central coordinate (IN DEGREES) of the area to search for interlopers in.

  • interloper_regions (np.ndarray) – An optional parameter that allows the user to pass a specific list of regions to check. Default is None, in which case the interloper_regions internal list will be used.

Returns

A numpy array of the interloper regions within the specified area.

Return type

np.ndarray

get_annular_sas_region(inner_radius, outer_radius, obs_id, inst, output_unit=Unit("xmm_sky"), rot_angle=<Quantity 0. deg>, interloper_regions=None, central_coord=None)[source]

A method to generate a SAS region string for an arbitrary circular or elliptical annular region, with interloper sources removed.

Parameters
  • inner_radius (Quantity) – The inner radius/radii of the region you wish to generate in SAS, if the quantity has multiple elements then an elliptical region will be generated, with the first element being the inner radius on the semi-major axis, and the second on the semi-minor axis.

  • outer_radius (Quantity) – The inner outer_radius/radii of the region you wish to generate in SAS, if the quantity has multiple elements then an elliptical region will be generated, with the first element being the outer radius on the semi-major axis, and the second on the semi-minor axis.

  • obs_id (str) – The ObsID of the observation you wish to generate the SAS region for.

  • inst (str) – The instrument of the observation you to generate the SAS region for.

  • output_unit (UnitBase/str) – The output unit for this SAS region, either xmm_sky or xmm_det.

  • interloper_regions (np.ndarray) – The interloper regions to remove from the source region, default is None, in which case the function will run self.regions_within_radii.

  • rot_angle (Quantity) – The rotation angle of the source region, default is zero degrees.

  • central_coord (Quantity) – The coordinate on which to centre the source region, default is None in which case the function will use the default_coord of the source object.

Returns

A string for use in a SAS routine that describes the source region, and the regions to cut out of it.

Return type

str

property nH

Property getter for neutral hydrogen column attribute.

Returns

Neutral hydrogen column surface density.

Return type

Quantity

property redshift

Property getter for the redshift of this source object.

Returns

Redshift value

Return type

float

property on_axis_obs_ids

This method returns an array of ObsIDs that this source is approximately on axis in.

Returns

ObsIDs for which the source is approximately on axis.

Return type

list

property cosmo

This method returns whatever cosmology object is associated with this source object.

Returns

An astropy cosmology object specified for this source on initialization.

Return type

Cosmology

property name

The name of the source, either given at initialisation or generated from the user-supplied coordinates.

Returns

The name of the source.

Return type

str

add_fit_data(model, tab_line, lums, spec_storage_key)[source]

A method that stores fit results and global information about a the set of spectra in a source object. Any variable parameters in the fit are stored in an internal dictionary structure, as are any luminosities calculated. Other parameters of interest are store in other internal attributes. This probably shouldn’t ever be used by the user, just other parts of XGA, hence why I’ve asked for a spec_storage_key to be passed in rather than all the spectrum configuration options individually.

Parameters
  • model (str) – The XSPEC definition of the model used to perform the fit. e.g. constant*tbabs*apec

  • tab_line – The table line with the fit data.

  • lums (dict) – The various luminosities measured during the fit.

  • spec_storage_key (str) – The storage key of any spectrum that was used in this particular fit. The ObsID and instrument used don’t matter, as the storage key will be the same and is based off of the settings when the spectra were generated.

get_results(outer_radius, model, inner_radius=<Quantity 0. arcsec>, par=None, group_spec=True, min_counts=5, min_sn=None, over_sample=None)[source]

Important method that will retrieve fit results from the source object. Either for a specific parameter of a given region-model combination, or for all of them. If a specific parameter is requested, all matching values from the fit will be returned in an N row, 3 column numpy array (column 0 is the value, column 1 is err-, and column 2 is err+). If no parameter is specified, the return will be a dictionary of such numpy arrays, with the keys corresponding to parameter names.

Parameters
  • 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.

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

  • 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.

  • par (str) – The name of the parameter you want a result for.

  • 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.

Returns

The requested result value, and uncertainties.

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

Get method for luminosities calculated from model fits to spectra associated with this source. Either for given energy limits (that must have been specified when the fit was first performed), or for all luminosities associated with that model. Luminosities are returned as a 3 column numpy array; the 0th column is the value, the 1st column is the err-, and the 2nd is err+.

Parameters
  • 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.

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

  • 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.

  • 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.

Returns

The requested luminosity value, and uncertainties.

convert_radius(radius, out_unit='deg')[source]

A simple method to convert radii between different distance units, it automatically checks whether the requested conversion is possible, given available information. For instance it would fail if you requested a conversion from arcseconds to a proper distance if no redshift information were available.

Parameters
  • radius (Quantity) – The radius to convert to a new unit.

  • out_unit (Unit/str) – The unit to convert the input radius to.

Returns

The converted radius

Return type

Quantity

get_radius(rad_name, out_unit='deg')[source]

Allows a radius associated with this source to be retrieved in specified distance units. Note that physical distance units such as kiloparsecs may only be used if the source has redshift information.

Parameters
  • rad_name (str) – The name of the desired radius, r200 for instance.

  • out_unit (Unit/str) – An astropy unit, either a Unit instance or a string representation. Default is degrees.

Returns

The desired radius in the desired units.

Return type

Quantity

property num_pn_obs

Getter method that gives the number of PN observations.

Returns

Integer number of PN observations associated with this source

Return type

int

property num_mos1_obs

Getter method that gives the number of MOS1 observations.

Returns

Integer number of MOS1 observations associated with this source

Return type

int

property num_mos2_obs

Getter method that gives the number of MOS2 observations.

Returns

Integer number of MOS2 observations associated with this source

Return type

int

property instruments

A property of a source that details which instruments have valid data for which observations.

Returns

A dictionary of ObsIDs and their associated valid instruments.

Return type

Dict

property disassociated

Property that describes whether this source has had ObsIDs disassociated from it.

Returns

A boolean flag, True means that ObsIDs/instruments have been removed, False means they haven’t.

Return type

bool

property disassociated_obs

Property that details exactly what data has been disassociated from this source, if any.

Returns

Dictionary describing which instruments of which ObsIDs have been disassociated from this source.

Return type

dict

disassociate_obs(to_remove)[source]

Method that uses the supplied dictionary to safely remove data from the source. This data will no longer be used in any analyses, and would typically be removed because it is of poor quality, or doesn’t contribute enough to justify its presence.

Parameters

to_remove (dict/str) – A dictionary of observations to remove, either in the style of the source.instruments dictionary (with the top level keys being ObsIDs, and the lower levels being instrument names), or a string containing an ObsID.

property luminosity_distance

Tells the user the luminosity distance to the source if a redshift was supplied, if not returns None.

Returns

The luminosity distance to the source, calculated using the cosmology associated with this source.

Return type

Quantity

property angular_diameter_distance

Tells the user the angular diameter distance to the source if a redshift was supplied, if not returns None.

Returns

The angular diameter distance to the source, calculated using the cosmology associated with this source.

Return type

Quantity

property background_radius_factors

The factors by which to multiply outer radius by to get inner and outer radii for background regions.

Returns

An array of the two factors.

Return type

ndarray

obs_check(reg_type, threshold_fraction=0.5)[source]

This method uses exposure maps and region masks to determine which ObsID/instrument combinations are not contributing to the analysis. It calculates the area intersection of the mask and exposure maps, and if (for a given ObsID-Instrument) the ratio of that area to the full area of the region calculated is less than the threshold fraction, that ObsID-instrument will be included in the returned rejection dictionary.

Parameters
  • reg_type (str) – The region type for which to calculate the area intersection.

  • threshold_fraction (float) – Intersection area/ full region area ratios below this value will mean an ObsID-Instrument is rejected.

Returns

A dictionary of ObsID keys on the top level, then instruments a level down, that should be rejected according to the criteria supplied to this method.

Return type

Dict

get_spectra(outer_radius, obs_id=None, inst=None, inner_radius=<Quantity 0. arcsec>, group_spec=True, min_counts=5, min_sn=None, over_sample=None)[source]

A useful method that wraps the get_products function to allow you to easily retrieve XGA Spectrum objects. Simply pass the desired ObsID/instrument, and the same settings you used to generate the spectrum in evselect_spectrum, and the spectra(um) will be provided to you. If no match is found then a NoProductAvailableError will be raised.

Parameters
  • outer_radius (str/Quantity) – The name or value of the outer radius that was used 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.

  • obs_id (str) – Optionally, a specific obs_id to search for can be supplied. The default is None, which means all spectra matching the other criteria will be returned.

  • inst (str) – Optionally, a specific instrument to search for can be supplied. The default is None, which means all spectra matching the other criteria will be returned.

  • inner_radius (str/Quantity) – The name or value of the inner radius that was used for the generation of the spectrum (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum.

  • group_spec (bool) – Was the spectrum you wish to retrieve grouped?

  • min_counts (float) – If the spectrum you wish to retrieve was grouped on minimum counts, what was the minimum number of counts?

  • min_sn (float) – If the spectrum you wish to retrieve was grouped on minimum signal to noise, what was the minimum signal to noise.

  • over_sample (float) – If the spectrum you wish to retrieve was over sampled, what was the level of over sampling used?

Returns

An XGA Spectrum object (if there is an exact match), or a list of XGA Spectrum objects (if there were multiple matching products).

Return type

Union[Spectrum, List[Spectrum]]

get_annular_spectra(radii=None, group_spec=True, min_counts=5, min_sn=None, over_sample=None, set_id=None)[source]

Another useful method that wraps the get_products function, though this one gets you AnnularSpectra. Pass the radii used to generate the annuli, and the same settings you used to generate the spectrum in spectrum_set, and the AnnularSpectra will be returned (if it exists). If no match is found then a NoProductAvailableError will be raised. This method has an additional way of looking for a matching spectrum, if the set ID is known then that can be passed by the user and used to find an exact match.

Parameters
  • radii (Quantity) – The annulus boundary radii that were used to generate the annular spectra set that you wish to retrieve. By default this is None, which means the method will return annular spectra with any radii.

  • group_spec (bool) – Was the spectrum set you wish to retrieve grouped?

  • min_counts (float) – If the spectrum set you wish to retrieve was grouped on minimum counts, what was the minimum number of counts?

  • min_sn (float) – If the spectrum set you wish to retrieve was grouped on minimum signal to noise, what was the minimum signal to noise.

  • over_sample (float) – If the spectrum set you wish to retrieve was over sampled, what was the level of over sampling used?

  • set_id (int) – The unique identifier of the annular spectrum set. Passing a value for this parameter will override any other information that you have given this method.

Returns

An XGA AnnularSpectra object if there is an exact match.

Return type

AnnularSpectra

get_images(obs_id=None, inst=None, lo_en=None, hi_en=None, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15)[source]

A method to retrieve XGA Image objects. This supports the retrieval of both PSF corrected and non-PSF corrected images, as well as setting the energy limits of the specific image you would like. A NoProductAvailableError error will be raised if no matches are found.

Parameters
  • obs_id (str) – Optionally, a specific obs_id to search for can be supplied. The default is None, which means all images matching the other criteria will be returned.

  • inst (str) – Optionally, a specific instrument to search for can be supplied. The default is None, which means all images matching the other criteria will be returned.

  • lo_en (Quantity) – The lower energy limit of the image you wish to retrieve, the default is None (which will retrieve all images regardless of energy limit).

  • hi_en (Quantity) – The upper energy limit of the image you wish to retrieve, the default is None (which will retrieve all images regardless of energy limit).

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

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

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

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

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

Returns

An XGA Image object (if there is an exact match), or a list of XGA Image objects (if there were multiple matching products).

Return type

Union[Image, List[Image]]

get_expmaps(obs_id=None, inst=None, lo_en=None, hi_en=None)[source]

A method to retrieve XGA ExpMap objects. This supports setting the energy limits of the specific exposure maps you would like. A NoProductAvailableError error will be raised if no matches are found.

Parameters
  • obs_id (str) – Optionally, a specific obs_id to search for can be supplied. The default is None, which means all exposure maps matching the other criteria will be returned.

  • inst (str) – Optionally, a specific instrument to search for can be supplied. The default is None, which means all exposure maps matching the other criteria will be returned.

  • lo_en (Quantity) – The lower energy limit of the exposure maps you wish to retrieve, the default is None (which will retrieve all images regardless of energy limit).

  • hi_en (Quantity) – The upper energy limit of the exposure maps you wish to retrieve, the default is None (which will retrieve all images regardless of energy limit).

Returns

An XGA ExpMap object (if there is an exact match), or a list of XGA ExpMap objects (if there were multiple matching products).

Return type

Union[ExpMap, List[ExpMap]]

get_ratemaps(obs_id=None, inst=None, lo_en=None, hi_en=None, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15)[source]

A method to retrieve XGA RateMap objects. This supports the retrieval of both PSF corrected and non-PSF corrected ratemaps, as well as setting the energy limits of the specific ratemap you would like. A NoProductAvailableError error will be raised if no matches are found.

Parameters
  • obs_id (str) – Optionally, a specific obs_id to search for can be supplied. The default is None, which means all ratemaps matching the other criteria will be returned.

  • inst (str) – Optionally, a specific instrument to search for can be supplied. The default is None, which means all ratemaps matching the other criteria will be returned.

  • lo_en (Quantity) – The lower energy limit of the ratemaps you wish to retrieve, the default is None (which will retrieve all ratemaps regardless of energy limit).

  • hi_en (Quantity) – The upper energy limit of the ratemaps you wish to retrieve, the default is None (which will retrieve all ratemaps regardless of energy limit).

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

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

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

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

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

Returns

An XGA RateMap object (if there is an exact match), or a list of XGA RateMap objects (if there were multiple matching products).

Return type

Union[RateMap, List[RateMap]]

get_combined_images(lo_en=None, hi_en=None, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15)[source]

A method to retrieve combined XGA Image objects, as in those images that have been created by merging all available data for this source. This supports the retrieval of both PSF corrected and non-PSF corrected images, as well as setting the energy limits of the specific image you would like. A NoProductAvailableError error will be raised if no matches are found.

Parameters
  • lo_en (Quantity) – The lower energy limit of the image you wish to retrieve, the default is None (which will retrieve all images regardless of energy limit).

  • hi_en (Quantity) – The upper energy limit of the image you wish to retrieve, the default is None (which will retrieve all images regardless of energy limit).

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

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

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

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

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

Returns

An XGA Image object (if there is an exact match), or a list of XGA Image objects (if there were multiple matching products).

Return type

Union[Image, List[Image]]

get_combined_expmaps(lo_en=None, hi_en=None)[source]

A method to retrieve combined XGA ExpMap objects, as in those exposure maps that have been created by merging all available data for this source. This supports setting the energy limits of the specific exposure maps you would like. A NoProductAvailableError error will be raised if no matches are found.

Parameters
  • lo_en (Quantity) – The lower energy limit of the exposure maps you wish to retrieve, the default is None (which will retrieve all images regardless of energy limit).

  • hi_en (Quantity) – The upper energy limit of the exposure maps you wish to retrieve, the default is None (which will retrieve all images regardless of energy limit).

Returns

An XGA ExpMap object (if there is an exact match), or a list of XGA Image objects (if there were multiple matching products).

Return type

Union[ExpMap, List[ExpMap]]

get_combined_ratemaps(lo_en=None, hi_en=None, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15)[source]

A method to retrieve combined XGA RateMap objects, as in those ratemap that have been created by merging all available data for this source. This supports the retrieval of both PSF corrected and non-PSF corrected ratemaps, as well as setting the energy limits of the specific ratemap you would like. A NoProductAvailableError error will be raised if no matches are found.

Parameters
  • lo_en (Quantity) – The lower energy limit of the ratemaps you wish to retrieve, the default is None (which will retrieve all ratemaps regardless of energy limit).

  • hi_en (Quantity) – The upper energy limit of the ratemaps you wish to retrieve, the default is None (which will retrieve all ratemaps regardless of energy limit).

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

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

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

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

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

Returns

An XGA RateMap object (if there is an exact match), or a list of XGA RateMap objects (if there were multiple matching products).

Return type

Union[RateMap, List[RateMap]]

get_profiles(profile_type, obs_id=None, inst=None, central_coord=None, radii=None, lo_en=None, hi_en=None)[source]

This is the generic get method for XGA profile objects stored in this source. You still must remember the profile type value to use it, but once entered it will return a list of all matching profiles (or a single object if only one match is found).

Parameters
  • profile_type (str) – The string profile type of the profile(s) you wish to retrieve.

  • obs_id (str) – Optionally, a specific obs_id to search for can be supplied. The default is None, which means all profiles matching the other criteria will be returned.

  • inst (str) – Optionally, a specific instrument to search for can be supplied. The default is None, which means all profiles matching the other criteria will be returned.

  • central_coord (Quantity) – The central coordinate of the profile you wish to retrieve, the default is None which means the method will use the default coordinate of this source.

  • radii (Quantity) – The central radii of the profile points, it is not likely that this option will be used often as you likely won’t know the radial values a priori.

  • lo_en (Quantity) – The lower energy bound of the profile you wish to retrieve (if applicable), default is None, and if this argument is passed hi_en must be too.

  • hi_en (Quantity) – The higher energy bound of the profile you wish to retrieve (if applicable), default is None, and if this argument is passed lo_en must be too.

Returns

An XGA profile object (if there is an exact match), or a list of XGA profile objects (if there were multiple matching products).

Return type

Union[BaseProfile1D, List[BaseProfile1D]]

get_combined_profiles(profile_type, central_coord=None, radii=None, lo_en=None, hi_en=None)[source]

The generic get method for XGA profiles made using all available data which are stored in this source. You still must remember the profile type value to use it, but once entered it will return a list of all matching profiles (or a single object if only one match is found).

Parameters
  • profile_type (str) – The string profile type of the profile(s) you wish to retrieve.

  • central_coord (Quantity) – The central coordinate of the profile you wish to retrieve, the default is None which means the method will use the default coordinate of this source.

  • radii (Quantity) – The central radii of the profile points, it is not likely that this option will be used often as you likely won’t know the radial values a priori.

  • lo_en (Quantity) – The lower energy bound of the profile you wish to retrieve (if applicable), default is None, and if this argument is passed hi_en must be too.

  • hi_en (Quantity) – The higher energy bound of the profile you wish to retrieve (if applicable), default is None, and if this argument is passed lo_en must be too.

Returns

An XGA profile object (if there is an exact match), or a list of XGA profile objects (if there were multiple matching products).

Return type

Union[BaseProfile1D, List[BaseProfile1D]]

property fitted_models

This property cycles through all the available fit results, and finds the unique names of XSPEC models that have been fitted to this source.

Returns

A list of model names.

Return type

List[str]

snr_ranking(outer_radius, lo_en=None, hi_en=None, allow_negative=False)[source]

This method generates a list of ObsID-Instrument pairs, ordered by the signal to noise measured for the given region, with element zero being the lowest SNR, and element N being the highest.

Parameters
  • outer_radius (Quantity/str) – The radius that SNR should be calculated within, this can either be a named radius such as r500, or an astropy Quantity.

  • lo_en (Quantity) – The lower energy bound of the ratemap to use to calculate the SNR. Default is None, in which case the lower energy bound for peak finding will be used (default is 0.5keV).

  • hi_en (Quantity) – The upper energy bound of the ratemap to use to calculate the SNR. Default is None, in which case the upper energy bound for peak finding will be used (default is 2.0keV).

  • 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).

Returns

Two arrays, the first an N by 2 array, with the ObsID, Instrument combinations in order of ascending signal to noise, then an array containing the order SNR ratios.

Return type

Tuple[np.ndarray, np.ndarray]

info()[source]

Very simple function that just prints a summary of important information related to the source object..

class xga.sources.base.NullSource(obs=None)[source]

Bases: object

A useful, but very limited, source class. By default this source class will include all ObsIDs present in the XGA census, and as such can be used for bulk generation of SAS products. It can also be made to only include certain ObsIDs.

get_att_file(obs_id)[source]

Fetches the path to the attitude file for an XMM observation.

Parameters

obs_id – The ObsID to fetch the attitude file for.

Returns

The path to the attitude file.

Return type

str

property obs_ids

Property getter for ObsIDs associated with this source that are confirmed to have events files.

Returns

A list of the associated XMM ObsIDs.

Return type

List[str]

property instruments

A property of a source that details which instruments have valid data for which observations.

Returns

A dictionary of ObsIDs and their associated valid instruments.

Return type

Dict

update_queue(cmd_arr, p_type_arr, p_path_arr, extra_info, stack=False)[source]

Small function to update the numpy array that makes up the queue of products to be generated.

Parameters
  • cmd_arr (np.ndarray) – Array containing SAS commands.

  • p_type_arr (np.ndarray) – Array of product type identifiers for the products generated by the cmd array. e.g. image or expmap.

  • p_path_arr (np.ndarray) – Array of final product paths if cmd is successful

  • extra_info (np.ndarray) – Array of extra information dictionaries

  • stack – Should these commands be executed after a preceding line of commands, or at the same time.

Returns

get_queue()[source]

Calling this indicates that the queue is about to be processed, so this function combines SAS commands along columns (command stacks), and returns N SAS commands to be run concurrently, where N is the number of columns.

Returns

List of strings, where the strings are bash commands to run SAS procedures, another list of strings, where the strings are expected output types for the commands, a list of lists of strings, where the strings are expected output paths for products of the SAS commands.

Return type

Tuple[List[str], List[str], List[List[str]]]

update_products(prod_obj)[source]

This method will ONLY store images and exposure maps. Ideally I wouldn’t store them as product objects at all, but unfortunately exposure maps require an image to be generated. Unlike all other source classes, ratemaps will not be generated when matching images and exposure maps are added.

Parameters

prod_obj (BaseProduct) – The new product object to be added to the source object.

get_products(p_type, obs_id=None, inst=None, extra_key=None, just_obj=True)[source]

This is the getter for the products data structure of Source objects. Passing a ‘product type’ such as ‘events’ or ‘images’ will return every matching entry in the products data structure.

Parameters
  • p_type (str) – Product type identifier. e.g. image or expmap.

  • obs_id (str) – Optionally, a specific obs_id to search can be supplied.

  • inst (str) – Optionally, a specific instrument to search can be supplied.

  • extra_key (str) – Optionally, an extra key (like an energy bound) can be supplied.

  • just_obj (bool) – A boolean flag that controls whether this method returns just the product objects, or the other information that goes with it like ObsID and instrument.

Returns

List of matching products.

Return type

List[BaseProduct]

property name

The name of the source, either given at initialisation or generated from the user-supplied coordinates.

Returns

The name of the source.

Return type

str

property num_pn_obs

Getter method that gives the number of PN observations.

Returns

Integer number of PN observations associated with this source

Return type

int

property num_mos1_obs

Getter method that gives the number of MOS1 observations.

Returns

Integer number of MOS1 observations associated with this source

Return type

int

property num_mos2_obs

Getter method that gives the number of MOS2 observations.

Returns

Integer number of MOS2 observations associated with this source

Return type

int

info()[source]

Just prints a couple of pieces of information about the NullSource

sources.general module

class xga.sources.general.ExtendedSource(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=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), load_products=True, load_fits=False)[source]

Bases: xga.sources.base.BaseSource

The general extended source XGA class, for extended X-ray sources that do not have a specific source for their astrophysical class. This class is subclassed by GalaxyCluster, which then adds more specific analyses, for instance.

find_peak(rt, method='hierarchical', num_iter=20, peak_unit=Unit('deg'))[source]

A method that will find the X-ray centroid for the RateMap that has been passed in. It takes the user supplied coordinates from source initialisation as a starting point, finds the peak within a 500kpc radius, re-centres the region, and iterates until the centroid converges to within 15kpc, or until 20 20 iterations has been reached.

Parameters
  • rt (RateMap) – The ratemap which we want to find the peak (local to our user supplied coordinates) of.

  • method (str) – Which peak finding method to use. Currently either hierarchical or simple can be chosen.

  • num_iter (int) – How many iterations should be allowed before the peak is declared as not converged.

  • peak_unit (UnitBase) – The unit the peak coordinate is returned in.

Returns

The peak coordinate, a boolean flag as to whether the returned coordinates are near a chip gap/edge, and a boolean flag as to whether the peak converged. It also returns the coordinates of the points within the chosen point cluster, and a list of all point clusters that were not chosen.

Return type

Tuple[Quantity, bool, bool, ndarray, List]

get_peaks(obs_id=None, inst=None)[source]

A get method to return the peak of the X-ray emission of this GalaxyCluster.

Parameters
  • obs_id (str) – The ObsID to return the X-ray peak coordinates for.

  • inst (str) – The instrument to return the X-ray peak coordinates for.

Returns

The X-ray peak coordinates for the input parameters.

Return type

Quantity

get_1d_brightness_profile(outer_rad, obs_id='combined', inst='combined', central_coord=None, radii=None, lo_en=None, hi_en=None, pix_step=1, min_snr=0.0, psf_corr=False, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15)[source]

A specific get method for 1D brightness profiles. Should provide a relatively simple way of retrieving specific brightness profiles from XGA’s storage system. Please note that there is not a separate get method for brightness profiles made from combined data, instead this method will search for combined profiles if either obs_id or inst is set to ‘combined’. - Retrieving combined profiles is the default behaviour.

Parameters
  • outer_rad (Quantity/str) – The outermost radius of the profile, either as a Quantity or a name (e.g. r500).

  • obs_id (str) – The ObsID used to generate the profile in question, default is None. If this is set to combined then this method will search for profiles based on combined data.

  • inst (str) – The instrument used to generate the profile in question, default is None. If this is set to combined then this method will search for profiles based on combined data.

  • central_coord (Quantity) – The central coordinate from which the profile was generated. Default is None, which means we shall use the default coordinate of this source.

  • radii (Quantity) – Specific radii to check for in the profiles.

  • lo_en (Quantity) – The lower energy bound of the RateMap used to generate the profile.

  • hi_en (Quantity) – The upper energy bound of the RateMap used to generate the profile.

  • pix_step (int) – The width of each annulus in pixels used to generate the profile.

  • min_snr (float) – The minimum signal to noise imposed upon the profile.

  • psf_corr (bool) – Is the brightness profile corrected for PSF effects?

  • 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.

Returns

property peak

A property getter for the combined X-ray peak coordinates. Most analysis will be centered on these coordinates.

Returns

The X-ray peak coordinates for the combined ratemap.

Return type

Quantity

property custom_radius

A getter for the custom region that can be defined on initialisation.

Returns

The radius (in kpc) of the user defined custom region.

Return type

Quantity

property point_clusters

This allows you to retrieve the point cluster positions from the hierarchical clustering peak finding method run on the combined ratemap. This includes both the chosen cluster and all others that were found.

Returns

A numpy array of the positions of points of the chosen cluster (not galaxy cluster, a cluster of points). A list of numpy arrays with the same information for all the other clusters that were found

Return type

Tuple[ndarray, List[ndarray]]

class xga.sources.general.PointSource(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=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), load_products=True, load_fits=False, regen_merged=True)[source]

Bases: xga.sources.base.BaseSource

The general point source XGA class, for point X-ray sources that do not have a specific source for their astrophysical class.

property point_radius

Property getter to access the point_radius declared on initialisation of the source, the radius of the region that is used for point source analysis.

Returns

The radius of the point source analysis region.

Return type

Quantity

find_peak(rt, peak_unit=Unit('deg'))[source]

Uses a simple ‘brightest pixel’ method to measure a peak coordinate for the point source.

Parameters
  • rt (RateMap) – The RateMap to measure the peak from.

  • peak_unit (UnitBase) – The desired output unit of the peak.

Returns

The peak, and a boolean flag as to whether the peak is near an edge.

Return type

Tuple[Quantity, bool]

property peak

A property getter for the combined X-ray peak coordinates.

Returns

The X-ray peak coordinates for the combined ratemap.

Return type

Quantity

sources.extended module

class xga.sources.extended.GalaxyCluster(ra, dec, redshift, name=None, 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=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), load_products=True, load_fits=False, clean_obs=True, clean_obs_reg='r200', clean_obs_threshold=0.3, regen_merged=True)[source]

Bases: xga.sources.general.ExtendedSource

This class is for the declaration and analysis of GalaxyCluster sources, and is a subclass of ExtendedSource.

property r200

Getter for the radius at which the average density is 200 times the critical density.

Returns

The R200 in kpc.

Return type

Quantity

property r500

Getter for the radius at which the average density is 500 times the critical density.

Returns

The R500 in kpc.

Return type

Quantity

property r2500

Getter for the radius at which the average density is 2500 times the critical density.

Returns

The R2500 in kpc.

Return type

Quantity

property weak_lensing_mass

Gets the weak lensing mass passed in at initialisation of the source.

Returns

Two quantities, the weak lensing mass, and the weak lensing mass error in Msun. If the values were not passed in at initialisation, the returned values will be None.

Return type

Quantity

property richness

Gets the richness passed in at initialisation of the source.

Returns

Two floats, the richness, and the richness error. If the values were not passed in at initialisation, the returned values will be None.

Return type

Quantity

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

Important method that will retrieve fit results from the source object. Either for a specific parameter of a given region-model combination, or for all of them. If a specific parameter is requested, all matching values from the fit will be returned in an N row, 3 column numpy array (column 0 is the value, column 1 is err-, and column 2 is err+). If no parameter is specified, the return will be a dictionary of such numpy arrays, with the keys corresponding to parameter names.

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

Parameters
  • 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.

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

  • 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.

  • par (str) – The name of the parameter you want a result for.

  • 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.

Returns

The requested result value, and uncertainties.

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

Get method for luminosities calculated from model fits to spectra associated with this source. Either for given energy limits (that must have been specified when the fit was first performed), or for all luminosities associated with that model. Luminosities are returned as a 3 column numpy array; the 0th column is the value, the 1st column is the err-, and the 2nd is err+.

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

Parameters
  • 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.

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

  • 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.

  • 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.

Returns

The requested luminosity value, and uncertainties.

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

Convenience method that calls get_results to retrieve temperature measurements. All matching values from the fit will be returned in an N row, 3 column numpy array (column 0 is the value, column 1 is err-, and column 2 is err+).

Parameters
  • 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.

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

  • 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.

  • 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.

Returns

The temperature value, and uncertainties.

get_proj_temp_profiles(radii=None, group_spec=True, min_counts=5, min_sn=None, over_sample=None, set_id=None)[source]

A get method for projected temperature profiles generated by XGA’s XSPEC interface. This works identically to the get_annular_spectra method, because projected temperature profiles are generated from annular spectra, and as such can be described by the same parameters.

Parameters
  • radii (Quantity) – The annulus boundary radii that were used to generate the annular spectra set from which the projected temperature profile was measured.

  • group_spec (bool) – Was the spectrum set used to generate the profile grouped

  • min_counts (float) – If the spectrum set used to generate the profile was grouped on minimum counts, what was the minimum number of counts?

  • min_sn (float) – If the spectrum set used to generate the profile was grouped on minimum signal to noise, what was the minimum signal to noise.

  • over_sample (float) – If the spectrum set used to generate the profile was over sampled, what was the level of over sampling used?

  • set_id (int) – The unique identifier of the annular spectrum set used to generate the profile. Passing a value for this parameter will override any other information that you have given this method.

Returns

An XGA ProjectedGasTemperature1D object if there is an exact match, a list of such objects if there are multiple matches.

Return type

Union[ProjectedGasTemperature1D, List[ProjectedGasTemperature1D]]

get_3d_temp_profiles(radii=None, group_spec=True, min_counts=5, min_sn=None, over_sample=None, set_id=None)[source]

A get method for 3D temperature profiles generated by XGA’s de-projection routines.

Parameters
  • radii (Quantity) – The annulus boundary radii that were used to generate the annular spectra set from which the projected temperature profile was measured.

  • group_spec (bool) – Was the spectrum set used to generate the profile grouped

  • min_counts (float) – If the spectrum set used to generate the profile was grouped on minimum counts, what was the minimum number of counts?

  • min_sn (float) – If the spectrum set used to generate the profile was grouped on minimum signal to noise, what was the minimum signal to noise.

  • over_sample (float) – If the spectrum set used to generate the profile was over sampled, what was the level of over sampling used?

  • set_id (int) – The unique identifier of the annular spectrum set used to generate the profile. Passing a value for this parameter will override any other information that you have given this method.

Returns

An XGA ProjectedGasTemperature1D object if there is an exact match, a list of such objects if there are multiple matches.

Return type

Union[ProjectedGasTemperature1D, List[ProjectedGasTemperature1D]]

get_apec_norm_profiles(radii=None, group_spec=True, min_counts=5, min_sn=None, over_sample=None, set_id=None)[source]

A get method for APEC normalisation profiles generated by XGA’s XSPEC interface.

Parameters
  • radii (Quantity) – The annulus boundary radii that were used to generate the annular spectra set from which the normalisation profile was measured.

  • group_spec (bool) – Was the spectrum set used to generate the profile grouped

  • min_counts (float) – If the spectrum set used to generate the profile was grouped on minimum counts, what was the minimum number of counts?

  • min_sn (float) – If the spectrum set used to generate the profile was grouped on minimum signal to noise, what was the minimum signal to noise.

  • over_sample (float) – If the spectrum set used to generate the profile was over sampled, what was the level of over sampling used?

  • set_id (int) – The unique identifier of the annular spectrum set used to generate the profile. Passing a value for this parameter will override any other information that you have given this method.

Returns

An XGA APECNormalisation1D object if there is an exact match, a list of such objects if there are multiple matches.

Return type

Union[ProjectedGasTemperature1D, List[ProjectedGasTemperature1D]]

get_density_profiles(outer_rad=None, method=None, obs_id=None, inst=None, central_coord=None, radii=None, pix_step=1, min_snr=0.0, psf_corr=True, psf_model='ELLBETA', psf_bins=4, psf_algo='rl', psf_iter=15, group_spec=True, min_counts=5, min_sn=None, over_sample=None, set_id=None)[source]

This is a get method for density profiles generated by XGA, both using surface brightness profiles and spectra. Having to account for two different methods is why this get method has so many arguments that can be passed. If multiple matches for the passed variables are found, then a list of density profiles will be returned, otherwise only a single profile will be returned.

Parameters
  • outer_rad (Quantity/str) – The outer radius of the density profile, either as a name (‘r500’ for instance) or an astropy Quantity.

  • 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’.

  • obs_id (str) – The ObsID used to generate the profile in question, default is None (which will search for profiles generated from combined data).

  • inst (str) – The instrument used to generate the profile in question, default is None (which will search for profiles generated from combined data).

  • central_coord (Quantity) – The central coordinate of the density profile. Default is None, which means we shall use the default coordinate of this source.

  • radii (Quantity) – If known, the radii that were used to measure the density profile.

  • 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.

  • group_spec (bool) – Was the spectrum set used to generate the profile grouped.

  • min_counts (float) – If the spectrum set used to generate the profile was grouped on minimum counts, what was the minimum number of counts?

  • min_sn (float) – If the spectrum set used to generate the profile was grouped on minimum signal to noise, what was the minimum signal to noise.

  • over_sample (float) – If the spectrum set used to generate the profile was over sampled, what was the level of over sampling used?

  • set_id (int) – The unique identifier of the annular spectrum set used to generate the profile. Passing a value for this parameter will override any other information that you have given this method.

Returns

Return type

Union[GasDensity3D, List[GasDensity3D]]

get_hydrostatic_mass_profiles(temp_prof=None, temp_model_name=None, dens_prof=None, dens_model_name=None, radii=None)[source]

A get method for hydrostatic mass profiles associated with this galaxy cluster. This works in a slightly different way to the temperature and density profile get methods, as you can pass the gas temperature and density profiles used to generate a hydrostatic mass profile to find it. If none of the optional arguments are passed then all hydrostatic mass profiles associated with this source will be returned, if only some are passed then mass profiles which match the limited information will be found.

Parameters
  • temp_prof (GasTemperature3D) – The temperature profile used to generate the required hydrostatic mass profile, default is None.

  • 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_prof (GasDensity3D) – The density 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.

  • radii (Quantity) – The radii at which the hydrostatic mass profile was measured, default is None.

Returns

Either a single hydrostatic mass profile, when there is a unique match, or a list of hydrostatic mass profiles if there is not.

Return type

Union[HydrostaticMass, List[HydrostaticMass]]

view_brightness_profile(reg_type, central_coord=None, pix_step=1, min_snr=0.0, figsize=(10, 7), xscale='log', yscale='log', back_sub=True, lo_en=<Quantity 0.5 keV>, hi_en=<Quantity 2. keV>)[source]

A method that generates and displays brightness profile objects for this galaxy cluster. Interloper sources are excluded, and any fits performed to pre-existing brightness profiles which are being viewed will also be displayed. The profile will be generated using a RateMap between the energy bounds specified by lo_en and hi_en.

Parameters
  • reg_type (str) – The region in which to view the radial brightness profile.

  • central_coord (Quantity) – The central coordinate of the brightness profile.

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

  • min_snr (float/int) – The minimum signal to noise allowed for each radial bin. This is 0 by default, which disables any automatic re-binning.

  • figsize (tuple) – The desired size of the figure, the default is (10, 7)

  • xscale (str) – The scaling to be applied to the x axis, default is log.

  • yscale (str) – The scaling to be applied to the y axis, default is log.

  • back_sub (bool) – Should the plotted data be background subtracted, default is True.

  • lo_en (Quantity) – The lower energy bound of the RateMap to generate the profile from.

  • hi_en (Quantity) – The upper energy bound of the RateMap to generate the profile from.

combined_lum_conv_factor(outer_radius, lo_en, hi_en, inner_radius=<Quantity 0. arcsec>, group_spec=True, min_counts=5, min_sn=None, over_sample=None)[source]

Combines conversion factors calculated for this source with individual instrument-observation spectra, into one overall conversion factor.

Parameters
  • outer_radius (str/Quantity) – The name or value of the outer radius of the spectra that should be used to calculate conversion factors (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.

  • inner_radius (str/Quantity) – The name or value of the inner radius of the spectra that should be used to calculate conversion factors (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum.

  • lo_en (Quantity) – The lower energy limit of the conversion factors.

  • hi_en (Quantity) – The upper energy limit of the conversion factors.

  • 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.

Returns

A combined conversion factor that can be applied to a combined ratemap to calculate luminosity.

Return type

Quantity

norm_conv_factor(outer_radius, lo_en, hi_en, inner_radius=<Quantity 0. arcsec>, group_spec=True, min_counts=5, min_sn=None, over_sample=None, obs_id=None, inst=None)[source]

Combines count-rate to normalisation conversion factors associated with this source.

Parameters
  • outer_radius (str/Quantity) – The name or value of the outer radius of the spectra that should be used to calculate conversion factors (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.

  • inner_radius (str/Quantity) – The name or value of the inner radius of the spectra that should be used to calculate conversion factors (for instance ‘r500’ would be acceptable for a GalaxyCluster, or Quantity(300, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum.

  • lo_en (Quantity) – The lower energy limit of the conversion factors.

  • hi_en (Quantity) – The upper energy limit of the conversion factors.

  • 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) – The ObsID to fetch a conversion factor for, default is None which means the combined conversion factor will be returned.

  • inst (str) – The instrument to fetch a conversion factor for, default is None which means the combined conversion factor will be returned.

Returns

A combined conversion factor that can be applied to a combined ratemap to calculate luminosity.

Return type

Quantity

sources.point module