Fitting routines¶
- GOAL:
Step through bins (spectra) and calculate the temperature value of each bin using XSPEC
- OUTPUTS:
A file which contains the bin number and associated temperature and reduced chi-squared
- ADDITIONAL NOTES:
Be sure to run heainit first
-
TemperatureMapPipeline.Fits.FitXSPEC(spectrum_files, background_files, redshift, n_H, temp_guess, grouping, spec_count, plot_dir, errors=False)¶ Fit observations simultaneously using models defined in obsid_set().
- Parameters
spectrum_files (list) – List of spectrum files (i.e. [‘obs1.pi’, ‘obs2.pi’])
background_files (list) – List of background files (i.e. [‘obs1_bkg.pi’, ‘obs2_bkg.pi’])
redshift (float) – Cosmological Redshift of Object
n_H (float) – Column Density in direction of object – units of 10^{-22} cm^{-2}
Temp_guess (float) – Estimate of Temperature Value
grouping (int) – Number of counts per bin (i.e. 5)
spec_count (int) – Local number of spectra with reference to the total number of spectra being fitted
plot_dir (str) – Path to directory containing plots
- Kwargs:
errors (bool): Boolean to calculate 1-sigma errors (default=False)
- Returns
Fitted Temperature Value in keV Temp_min: Minimum Fitted Temperature Value at 1-sigma in keV Temp_max: Maximum Fitted Temperature Value at 1-sigma in keV Abundance: Fitted Abundance Value in Z_{solar} Ab_min: Minimum Fitted Abundance Value at 1-sigma in Z_{solar} Ab_max: Maximum Fitted Abundance Value at 1-sigma in Z_{solar} Norm: Fitted Normalization Value Norm_min: Minimum Fitted Normalization Value at 1-sigma norm_max: Maximum Fitted Normalization Value at 1-sigma reduced_chi_sq: Reduced Chi Square Value for the Fit Flux: Fitted Flux Value in ergs/s/cm^{-2} Flux_min: Minimum Flux Value in ergs/s/cm^{-2} Flux_max: Maximum Flux Value in ergs/s/cm^{-2}
- Return type
Temperature
Note
If the fits are taking too long, set errors=False. The min and max value will just be copies of the fitted value.
Flux errors are always calculated
-
TemperatureMapPipeline.Fits.Fitting(base_directory, dir, file_name, num_files, redshift, n_H, temp_guess, output_file, bin_spec_dir)¶ Fit each region’s spectra and create a text file containing the spectral fit information for each bin :param base_directory: Path to main Directory :param dir: ObsID :param file_name: Root name of PI/PHA file :param num_files: Number of spatial bins :param redshift: Redshift of cluster :param n_H: Column density :param temp_guess: Initial temperature guess :param output_file: Text file containing each bin’s spectral fit information :param bin_spec_dir: Path to extracted spectra for each bin within an ObsID
- Returns
None
-
TemperatureMapPipeline.Fits.concat_temp_data(num_spec, output_file)¶ Concatenate temperature information. Used if running on several processors :param num_spec: Number of spectra (or bins) :param output_file: File name of final concatenated temperature data
-
TemperatureMapPipeline.Fits.fit_loop(dir, bin_spec_dir, file_name, redshift, n_H, temp_guess, grouping, plot_dir, base_directory, i)¶ Loop for fitting spectra. This will simply call the FitXSPEC function and write out the results to a temporary file
- Parameters
bin_spec_dir – Path to extracted spectra for each bin within an ObsID
dir (str) – ObsID
file_name (str) – Root name of PI/PHA file
redshift (float) – Cosmological Redshift of Object
n_H (float) – Column Density in direction of object – units of 10^{-22} cm^{-2}
Temp_guess (float) – Estimate of Temperature Value
grouping (int) – Number of counts per bin (i.e. 5)
plot_dir (str) – Path to plots
base_directory (str) – Path to main Directory
i (int) – Relative spectrum number
- Returns
None
-
TemperatureMapPipeline.Fits.obsid_set(src_model_dict, bkg_model_dict, obsid, bkg_spec, obs_count, redshift, nH_val, Temp_guess)¶ Set the observations’ model using an absorbed apec model. Each observation will be tied with the other to allow simultaneous fitting.
We additionally apply a background model.
- It contains two (frozen) thermal emission pieces:
unabsorbed apec model with kT=0.18 keV
absorbed bremmstrahlung emission with kT=40 keV
- Parameters
src_model_dict (dict) – Dictionary of source models – Created in FitXSPEC()
bkg_model_dict (dict) – Dictionary of background models – Created in FitXSPEC()
obsid (str) – Current Chandra ObsID
bkg_spec (str) – Background file corresponding to ObsID
obs_ct (int) – Relative ObsID number
redshift (float) – Cosmological Redshift of Object
nH_val (float) – Column Density in direction of object – units of 10^{-22} cm^{-2}
Temp_guess (float) – Estimate of Temperature Value
- Returns
Updated src_model_dict and bkg_model_dict