# xspec.fit package¶

## xspec.fit.general module¶

xga.xspec.fit.general.single_temp_apec(sources, outer_radius, inner_radius=<Quantity 0. arcsec>, start_temp=<Quantity 3. keV>, start_met=0.3, lum_en=<Quantity [[5.e-01, 2.e+00], [1.e-02, 1.e+02]] keV>, freeze_nh=True, freeze_met=True, lo_en=<Quantity 0.3 keV>, hi_en=<Quantity 7.9 keV>, par_fit_stat=1.0, lum_conf=68.0, abund_table='angr', fit_method='leven', group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, num_cores=1, spectrum_checking=True, timeout=<Quantity 1. h>)[source]

This is a convenience function for fitting an absorbed single temperature apec model(constant*tbabs*apec) to an object. It would be possible to do the exact same fit using the custom_model function, but as it will be a very common fit a dedicated function is in order. If there are no existing spectra with the passed settings, then they will be generated automatically.

If the spectrum checking step of the XSPEC fit is enabled (using the boolean flag spectrum_checking), then each individual spectrum available for a given source will be fitted, and if the measured temperature is less than or equal to 0.01keV, or greater than 20keV, or the temperature uncertainty is greater than 15keV, then that spectrum will be rejected and not included in the final fit. Spectrum checking also involves rejecting any spectra with fewer than 10 noticed channels.

Parameters
• sources (List[BaseSource]) – A single source object, or a sample of sources.

• 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 value passed for inner_radius is ignored, and the fit performed on spectra for the entire region. If you are fitting 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 inner radius of the region that the desired spectrum covers (for instance ‘r200’ would be acceptable for a GalaxyCluster, or Quantity(1000, ‘kpc’)). By default this is zero arcseconds, resulting in a circular spectrum. If you are fitting for multiple sources then you can also pass a Quantity with one entry per source.

• start_temp (Quantity) – The initial temperature for the fit.

• start_met – The initial metallicity for the fit (in ZSun).

• lum_en (Quantity) – Energy bands in which to measure luminosity.

• freeze_nh (bool) – Whether the hydrogen column density should be frozen.

• freeze_met (bool) – Whether the metallicity parameter in the fit should be frozen.

• lo_en (Quantity) – The lower energy limit for the data to be fitted.

• hi_en (Quantity) – The upper energy limit for the data to be fitted.

• par_fit_stat (float) – The delta fit statistic for the XSPEC ‘error’ command, default is 1.0 which should be equivelant to 1σ errors if I’ve understood (https://heasarc.gsfc.nasa.gov/xanadu/xspec/manual/XSerror.html) correctly.

• lum_conf (float) – The confidence level for XSPEC luminosity measurements.

• abund_table (str) – The abundance table to use for the fit.

• fit_method (str) – The XSPEC fit method 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.

• spectrum_checking (bool) – Should the spectrum checking step of the XSPEC fit (where each spectrum is fit individually and tested to see whether it will contribute to the simultaneous fit) be activated?

• timeout (Quantity) – The amount of time each individual fit is allowed to run for, the default is one hour. Please note that this is not a timeout for the entire fitting process, but a timeout to individual source fits.

xga.xspec.fit.general.power_law(sources, outer_radius, inner_radius=<Quantity 0. arcsec>, redshifted=False, lum_en=<Quantity [[5.e-01, 2.e+00], [1.e-02, 1.e+02]] keV>, start_pho_index=1.0, lo_en=<Quantity 0.3 keV>, hi_en=<Quantity 7.9 keV>, freeze_nh=True, par_fit_stat=1.0, lum_conf=68.0, abund_table='angr', fit_method='leven', group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, num_cores=1, timeout=<Quantity 1. h>)[source]

This is a convenience function for fitting a tbabs absorbed powerlaw (or zpowerlw if redshifted is selected) to source spectra, with a multiplicative constant included to deal with different spectrum normalisations (constant*tbabs*powerlaw, or constant*tbabs*zpowerlw).

Parameters
• sources (List[BaseSource]) – A single source object, or a sample of sources.

• outer_radius (str/Quantity) – The name or value of the outer radius of the region that the desired spectrum covers (for instance ‘point’ would be acceptable for a PointSource, or Quantity(40, ‘arcsec’)). If ‘region’ is chosen (to use the regions in region files), then any value passed for inner_radius is ignored, and the fit performed on spectra for the entire region. If you are fitting 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 inner radius of the region that the desired spectrum covers (for instance ‘point’ would be acceptable for a PointSource, or Quantity(40, ‘arcsec’)). By default this is zero arcseconds, resulting in a circular spectrum. If you are fitting for multiple sources then you can also pass a Quantity with one entry per source.

• redshifted (bool) – Whether the powerlaw that includes redshift (zpowerlw) should be used.

• lum_en (Quantity) – Energy bands in which to measure luminosity.

• start_pho_index (float) – The starting value for the photon index of the powerlaw.

• lo_en (Quantity) – The lower energy limit for the data to be fitted.

• hi_en (Quantity) – The upper energy limit for the data to be fitted. :param bool freeze_nh: Whether the hydrogen column density should be frozen.

• par_fit_stat (float) – The delta fit statistic for the XSPEC ‘error’ command, default is 1.0 which should be equivelant to 1sigma errors if I’ve understood (https://heasarc.gsfc.nasa.gov/xanadu/xspec /manual/XSerror.html) correctly.

• lum_conf (float) – The confidence level for XSPEC luminosity measurements.

• abund_table (str) – The abundance table to use for the fit.

• fit_method (str) – The XSPEC fit method 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.

• timeout (Quantity) – The amount of time each individual fit is allowed to run for, the default is one hour. Please note that this is not a timeout for the entire fitting process, but a timeout to individual source fits.

xga.xspec.fit.general.blackbody(sources, outer_radius, inner_radius=<Quantity 0. arcsec>, redshifted=False, lum_en=<Quantity [[5.e-01, 2.e+00], [1.e-02, 1.e+02]] keV>, start_temp=<Quantity 1. keV>, lo_en=<Quantity 0.3 keV>, hi_en=<Quantity 7.9 keV>, freeze_nh=True, par_fit_stat=1.0, lum_conf=68.0, abund_table='angr', fit_method='leven', group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, num_cores=1, timeout=<Quantity 1. h>)[source]

This is a convenience function for fitting a tbabs absorbed blackbody (or zbbody if redshifted is selected) to source spectra, with a multiplicative constant included to deal with different spectrum normalisations (constant*tbabs*bbody, or constant*tbabs*zbbody).

Parameters
• sources (List[BaseSource]) – A single source object, or a sample of sources.

• outer_radius (str/Quantity) – The name or value of the outer radius of the region that the desired spectrum covers (for instance ‘point’ would be acceptable for a PointSource, or Quantity(40, ‘arcsec’)). If ‘region’ is chosen (to use the regions in region files), then any value passed for inner_radius is ignored, and the fit performed on spectra for the entire region. If you are fitting 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 inner radius of the region that the desired spectrum covers (for instance ‘point’ would be acceptable for a PointSource, or Quantity(40, ‘arcsec’)). By default this is zero arcseconds, resulting in a circular spectrum. If you are fitting for multiple sources then you can also pass a Quantity with one entry per source.

• redshifted (bool) – Whether the powerlaw that includes redshift (zpowerlw) should be used.

• lum_en (Quantity) – Energy bands in which to measure luminosity.

• start_temp (float) – The starting value for the temperature of the blackbody.

• lo_en (Quantity) – The lower energy limit for the data to be fitted.

• hi_en (Quantity) – The upper energy limit for the data to be fitted.

• freeze_nh (bool) – Whether the hydrogen column density should be frozen.

• par_fit_stat (float) – The delta fit statistic for the XSPEC ‘error’ command, default is 1.0 which should be equivelant to 1sigma errors if I’ve understood (https://heasarc.gsfc.nasa.gov/xanadu/xspec /manual/XSerror.html) correctly.

• lum_conf (float) – The confidence level for XSPEC luminosity measurements.

• abund_table (str) – The abundance table to use for the fit.

• fit_method (str) – The XSPEC fit method 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.

• timeout (Quantity) – The amount of time each individual fit is allowed to run for, the default is one hour. Please note that this is not a timeout for the entire fitting process, but a timeout to individual source fits.

## xspec.fit.profile module¶

xga.xspec.fit.profile.single_temp_apec_profile(sources, radii, start_temp=<Quantity 3. keV>, start_met=0.3, lum_en=<Quantity [[5.e-01, 2.e+00], [1.e-02, 1.e+02]] keV>, freeze_nh=True, freeze_met=True, lo_en=<Quantity 0.3 keV>, hi_en=<Quantity 7.9 keV>, par_fit_stat=1.0, lum_conf=68.0, abund_table='angr', fit_method='leven', group_spec=True, min_counts=5, min_sn=None, over_sample=None, one_rmf=True, num_cores=1, spectrum_checking=True, timeout=<Quantity 1. h>)[source]

A function that allows for the fitting of sets of annular spectra (generated from objects such as galaxy clusters) with an absorbed plasma emission model (tbabs*apec). This function fits the annuli completely independently of one another.

If the spectrum checking step of the XSPEC fit is enabled (using the boolean flag spectrum_checking), then each individual spectrum available for a given source will be fitted, and if the measured temperature is less than or equal to 0.01keV, or greater than 20keV, or the temperature uncertainty is greater than 15keV, then that spectrum will be rejected and not included in the final fit. Spectrum checking also involves rejecting any spectra with fewer than 10 noticed channels.

Parameters
• sources (BaseSource/BaseSample) – A single source object, or a sample of sources.

• radii (List[Quantity]/Quantity) – A list of non-scalar quantities containing the boundary radii of the annuli for the sources. A single quantity containing at least three radii may be passed if one source is being analysed, but for multiple sources there should be a quantity (with at least three radii), PER source.

• start_temp (Quantity) – The initial temperature for the fit.

• start_met – The initial metallicity for the fit (in ZSun).

• lum_en (Quantity) – Energy bands in which to measure luminosity.

• freeze_nh (bool) – Whether the hydrogen column density should be frozen.

• freeze_met (bool) – Whether the metallicity parameter in the fit should be frozen.

• lo_en (Quantity) – The lower energy limit for the data to be fitted.

• hi_en (Quantity) – The upper energy limit for the data to be fitted.

• par_fit_stat (float) – The delta fit statistic for the XSPEC ‘error’ command, default is 1.0 which should be equivalent to 1σ errors if I’ve understood (https://heasarc.gsfc.nasa.gov/xanadu/xspec/manual/XSerror.html) correctly.

• lum_conf (float) – The confidence level for XSPEC luminosity measurements.

• abund_table (str) – The abundance table to use for the fit.

• fit_method (str) – The XSPEC fit method 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.

• spectrum_checking (bool) – Should the spectrum checking step of the XSPEC fit (where each spectrum is fit individually and tested to see whether it will contribute to the simultaneous fit) be activated?

• timeout (Quantity) – The amount of time each individual fit is allowed to run for, the default is one hour. Please note that this is not a timeout for the entire fitting process, but a timeout to individual source fits.