Last active
June 15, 2022 18:51
-
-
Save ZGainsforth/fa2600e92898f3d9234a48590a101be1 to your computer and use it in GitHub Desktop.
Combine RGS1 and RGS2 spectra from two different Newton/XMM observations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Filenames are: RxxxxxxxxxxRyS00zAAAAAA1001.FTZ | |
# xxxxxxxxxx is the observation ID. | |
# Ry = R1 or R2 depending on whether it is RGS instrument 1 or 2. | |
# S00z can be s004 or 5 depending on which RGS. | |
# AAAAAA is SRSPEC for the spectrum, RSPMAT for the response matrix, BGSPEC for the background spectrum. | |
# Also need fluxedto2col.py to do the conversion of the fluxed file into a two column output. | |
# For each ObsID, combine the RGS 1 and RGS 2 first order spectrum, produce a fluxed output, and convert that into a 2 column file. | |
for OBSID in 0693490201 0090340201 | |
do | |
rgscombine pha="$OBSID/pps/P${OBSID}R1S004SRSPEC1001.FTZ $OBSID/pps/P${OBSID}R2S005SRSPEC1001.FTZ" rmf="$OBSID/pps/P${OBSID}R1S004RSPMAT1001.FTZ $OBSID/pps/P${OBSID}R2S005RSPMAT1001.FTZ" bkg="$OBSID/pps/P${OBSID}R1S004BGSPEC1001.FTZ $OBSID/pps/P${OBSID}R2S005BGSPEC1001.FTZ" filepha="${OBSID}.pha" filermf="${OBSID}.rsp" filebkg="${OBSID}.bkg" rmfgrid=4000 | |
rgsfluxer pha=${OBSID}.pha rmf=${OBSID}.rsp bkg=${OBSID}.bkg file=${OBSID}.fluxed | |
python fluxedto2col.py ${OBSID} | |
done | |
# For some reason DATE_OBS and DATE_END are not pulled over correctly by rgscombine, so we have to fudge those to combine again. | |
sed -i 's/DATE_OBS/DATE-OBS/' *.bkg | |
sed -i 's/DATE_OBS/DATE-OBS/' *.pha | |
sed -i 's/DATE_OBS/DATE-OBS/' *.rsp | |
sed -i 's/DATE_END/DATE-END/' *.bkg | |
sed -i 's/DATE_END/DATE-END/' *.pha | |
sed -i 's/DATE_END/DATE-END/' *.rsp | |
# Combine the spectra from all ObsIDs into one spectrum. | |
rgscombine pha='0693490201.pha 0090340201.pha' rmf='0693490201.rsp 0090340201.rsp' bkg='0693490201.bkg 0090340201.bkg' filepha='combined.pha' filermf='combined.rsp' filebkg='combined.bkg' rmfgrid=4000 | |
rgsfluxer pha=combined.pha rmf=combined.rsp bkg=combined.bkg file=combined.fluxed | |
python fluxedto2col.py combined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment