Binning routines¶
Goal: Create binned spectra from Chandra data given the WVT map of the pixels
- OUTPUTS:
A combined spectra for each bin as designated by the WVT.
This is to be used for spectral fitting (we’ll that’s why I made this program)
File put in /PathToChandraData/OBSID/repro/binned
- Additional Notes:
As mentioned, the program was designed to generate combinned-binned-spectra so that I could generate temperature maps… The program can easily be canabilized for other uses or specifications
-
TemperatureMapPipeline.binned_spectra.coord_trans(pixel_x, pixel_y, file_to_split)¶ Translate image (logical) coordinates into physical (sky) coordinates
- Parameters
pixel_x (float) – x coordinate in image coordinates
pixel_y (float) – y coordinate in image coordinates
file_to_split (str) – Name of event file
- Returns
x coordinate in physical coordinates y_center (float): y coordinate in physical coordinates ra (float): RA in degrees dec (float): DEC in degrees
- Return type
x_center (float)
-
TemperatureMapPipeline.binned_spectra.create_evt(file_to_split, bin_number, output_dir)¶ Create temporary event file
- Parameters
file_to_split (str) – Name of file to be split
bin_number (int) – Relative number of the bin wrt WVT numbering system
output_dir (str) – Path to output directory
- Returns
A copy of the temporary event file
-
TemperatureMapPipeline.binned_spectra.create_reg(output_dir, regions)¶ Create temporary region file in ds9 format
- Parameters
output_dir (str) – Output directory
reigons (str) – List of regions to add
-
TemperatureMapPipeline.binned_spectra.create_reg_comb(pix_in_bin, file_to_split, bin_number, output_dir)¶ Function to concatenate pixels in a bin together in order to reduce calculation time.
- Parameters
pix_in_bin (int) – List of pixels in bin
file_to_split (str) – Name of event file
bin_number (int) – Relative number of the bin wrt WVT numbering system
output_dir (str) – Path to output directory
- Returns
Temporary ds9 file with concatenated pixels in bin that will be used to extract spectrum rapidly
-
TemperatureMapPipeline.binned_spectra.create_spectra(base_directory, filename, OBSIDS, source_file, output_dir, wvt_output)¶ Wrapper function to create spectra for each bin in the WVT map
- Parameters
base_directory (str) – Directory containing Chandra data
filename (str) – Name of file to read in WVT bin data
dir (str) – Directory for Chandra OBSID
file_to_split (str) – Name of file to split in repro directory
output_dir (str) – Output path for binned files
- Returns
Individual spectrum files (.pi) for source and background in each WVT bin
Note
This is parallelized to run on 4 cores in order to speed up calculation time
-
TemperatureMapPipeline.binned_spectra.source_fits(filenames, source_file, obsid)¶ Create fits and image file for primary source region in reprocessed Directory Also create blanksky file
- Parameters
filenames (str) – dictionary containing evt2 file
source_file (str) – source region name without extension
obsid (str) – Chandra Observation ID
- Returns
Creates image file and blanksky file
-
TemperatureMapPipeline.binned_spectra.spec_loop(obsid, filenames, file_to_split, output_file, output_dir, directory_repro, bin_i)¶ Parallelized loop for creating spectra for bins
-
TemperatureMapPipeline.binned_spectra.specextract_run(obsid, filenames, file_to_convert, outfile_from_convert, output_dir, bin_number)¶ Execute specectract command with designated parameters. Grouping is set to 1 count per bin.
- Parameters
obsid (str) – ObsID
filenames (str) – List of relavent files for given ObsID – contains badpixel file, evt1, evt2, …
file_to_convert (str) – Initial Level 2 file
outfile_from_convert (str) – Name of extracted spectrum
output_dir (str) – Directory for extracted spectrum
bin_num (int) – Relative number of the bin wrt WVT numbering system
- Returns
Creates extracted spectrum from WVT bin region
-
TemperatureMapPipeline.binned_spectra.split_fits(obsid, filenames, file_to_split, output_file, output_dir, pix_in_bin_num, bin_number)¶ Create spectra from initial bin regions
- Parameters
obsid (str) – Current ObsID
filenames (str) – List of files necessary for specextract
file_to_split (str) – Fits file in string format
output_file (str) – Directory for output
output_dir (str) – Pha outroot in string format
pix_in_bin_num (int) – pixel number relative to bin (0-max(bin.pixels))
bin_number (int) – Relative number of the bin wrt WVT numbering system