xspec

xspec.fakeit module

xga.xspec.fakeit.cluster_cr_conv(sources, outer_radius, inner_radius=<Quantity 0. arcsec>, sim_temp=<Quantity 3. keV>, sim_met=0.3, conv_en=<Quantity [[0.5, 2. ]] keV>, abund_table='angr', group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, num_cores=1)[source]

This function uses the xspec fakeit tool to calculate conversion factors between count rate and luminosity for ARFs and RMFs associated with spectra in the given sources. Once complete the conversion factors are stored within the relevant XGA spectrum object. If the requested spectra do not already exist then they will automatically be generated for you. Please be aware that this function does not support calculating conversion factors from AnnularSpectra.

Parameters
  • sources (GalaxyCluster) – The GalaxyCluster objects to calculate conversion factors for.

  • outer_radius (str/Quantity) – The name or value of the outer radius of the region that the desired spectrum covers (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 factors for multiple sources then you can also pass a Quantity with one entry per source.

  • inner_radius (str/Quantity) – The name or value of the outer radius of the region that the desired spectrum covers (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. By default this is zero arcseconds, resulting in a circular spectrum. If you are generating factors for multiple sources then you can also pass a Quantity with one entry per source.

  • sim_temp (Quantity) – The temperature(s) to use for the apec model.

  • sim_met (float/List) – The metallicity(s) (in solar met) to use for the apec model.

  • conv_en (Quantity) – The energy limit pairs to calculate conversion factors for.

  • abund_table (str) – The name of the XSPEC abundance table to use.

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

xspec.run module

xga.xspec.run.execute_cmd(x_script, out_file, src, run_type, timeout)[source]

This function is called for the local compute option. It will run the supplied XSPEC script, then check parse the output for errors and check that the expected output file has been created.

Parameters
  • x_script (str) – The path to an XSPEC script to be run.

  • out_file (str) – The expected path for the output file of that XSPEC script.

  • src (str) – A string representation of the source object that this fit is associated with.

  • run_type (str) – A flag that tells this function what type of run this is; e.g. fit or conv_factors.

  • timeout (float) – The length of time (in seconds) which the XSPEC script is allowed to run for before being killed.

Returns

FITS object of the results, string repr of the source associated with this fit, boolean variable describing if this fit can be used, list of any errors found, list of any warnings found.

Return type

Tuple[Union[FITS, str], str, bool, list, list]

xga.xspec.run.xspec_call(xspec_func)[source]

This is used as a decorator for functions that produce XSPEC scripts. Depending on the system that XGA is running on (and whether the user requests parallel execution), the method of executing the XSPEC commands will change. This supports multi-threading. :return: