Read in params set ccddef evselect expression based on ccds chosen by user set cornerdef evselect expression for corner-only selections set ccddef(7) evselect expression for chosen-ccds selections set fulldef evselect expression for full FOV selections if maskitsky, set maskitsky filename add bkg-reg to selections if maskitdet, set maskitdet filename add bkg-reg to selections if withregion open, read region selection from input reg text file run atthkgen to create atthk.fits unless it already exists create corner only event file with evselect from cleaned event file create FOV image file with evselect from cleaned event file create FOV exposure map with eexpmap from cleaned event file, atthk.fits, and FOV image create FOV mask with emask from FOV image if (withbands) then create FOV image in region in selected band (elow-ehigh) with evselect create FOV exposure map with eexpmap from cleaned event file create FOV mask with emask from FOV image end if (withbands) create spectrum from FOV region, run backscale, generate response create response from FOV spectrum with rmfgen create response from FOV spectrum with arfgen if (withbands) then create FOV image in region in selected band (elow-ehigh) with evselect create FOV exposure map with eexpmap from cleaned event file create FOV mask with emask from FOV image endif foreach ccd selected (1-7) create spectrum for FOV of region backscale spectrum create spectrum for corner-only data backscale spectrum create temp eventlist from corner-only data (temp_events.fits) extract cnts and livetimNN rm temp_events.fits rate = (cnts/livetime)* 100 rm temp_events.fits create temp eventlist from corner-only data (temp_events.fits) PI in 500-800 extract lowe rm temp_events.fits create temp eventlist from corner-only data (temp_events.fits) PI in 2500-5000 extract hige rm temp_events.fits rm temp_events.fits calculate hardness ratio: hard = hige/lowe create spectrum from the region from the FWC data backscale spectrum create spectrum from the corners from the FWC data backscale spectrum if (withbands) then create image of FWC data for the region and the band create FWC mask with emask from FWC image mask FWC image with farith rename FWC image: mv mos1S002-maskim2-350-1100-mask.fits mos1S002-im2-350-1100.fits create FWC mask with emask from FWC OOT image end withbands end foreach ccd rm intermediary files end mosspectra