generated from erosita/uds
good night
This commit is contained in:
@@ -51,83 +51,24 @@ for obsid in files:
|
||||
# Create QPB
|
||||
# https://www.cosmos.esa.int/web/xmm-newton/sas-thread-background
|
||||
#
|
||||
|
||||
attfiles = glob.glob(events_dir+f'/{obsid}/*{obsid}_AttHk.ds')
|
||||
if(attfiles):
|
||||
print(f"*** {attfiles} ***")
|
||||
else:
|
||||
print("AttHk?")
|
||||
sys.exit()
|
||||
|
||||
attfile = attfiles[0]
|
||||
if not os.path.isfile(attfile):
|
||||
print ("File "+attfile+" does not exist, please check. \n")
|
||||
sys.exit()
|
||||
attfile = get_first_file(events_dir+f'/{obsid}/*{obsid}_AttHk.ds')
|
||||
|
||||
spec=[]
|
||||
bkg=[]
|
||||
resp=[]
|
||||
arf=[]
|
||||
#for imos in [1,2]:
|
||||
for key in ['MOS1','MOS2','PN']:
|
||||
evtfile = get_first_file(events_dir+f'/{obsid}/*{obsid}_E{key}*_ImagingEvts.ds')
|
||||
|
||||
# Run the SAS task evqpb over each one of these event files.
|
||||
evqpb_outset=work_dir+f'/EPIC_{key}_QPB.fits' # Name of the output file
|
||||
inargs = [f'table={evtfile}', f'attfile={attfile}',
|
||||
f'outset={evqpb_outset}',
|
||||
f'exposurefactor=2.0',]
|
||||
w("evqpb", inargs).run()
|
||||
|
||||
gti=f'EPIC_{key}_gti.fit'
|
||||
expression=f'gti({gti},TIME)'
|
||||
# filter the EPIC event files to create cleaned and filtered for
|
||||
# flaring particle background event files for your observation
|
||||
sci_clean=work_dir+f'/EPIC_{key}_filtered.fits' # Name of the output file
|
||||
inargs = [f'table={evtfile}', 'withfilteredset=yes',
|
||||
f'filteredset={sci_clean}',
|
||||
'destruct=yes','keepfilteroutput=true',
|
||||
f'expression={expression}']
|
||||
w("evselect", inargs).run()
|
||||
|
||||
# Use the same expression to filter the FWC event files:
|
||||
qpb_clean=work_dir+f'/EPIC_{key}_QPB_clean.fits' # Name of the output file
|
||||
inargs = [f'table={evqpb_outset}', 'withfilteredset=yes',
|
||||
f'filteredset={qpb_clean}',
|
||||
'destruct=yes','keepfilteroutput=true',
|
||||
f'expression={expression}']
|
||||
w("evselect", inargs).run()
|
||||
# first element contains all energies
|
||||
label=['',]
|
||||
pimin=[200,]
|
||||
pimax=[12000,]
|
||||
for idx,e1 in enumerate(emin):
|
||||
label.append(f"_{idx}")
|
||||
pimin.append(emin[idx])
|
||||
pimax.append(emax[idx])
|
||||
|
||||
run_evqpb(key, work_dir=work_dir, evtfile=evtfile, attfile=attfile, label=label, pimin=pimin, pimax=pimax)
|
||||
|
||||
if(key=='PN'):
|
||||
expression='(#XMMEA_EP)&&(PATTERN<=4)&&(PI>=200)&&(PI<=12000)'
|
||||
else:
|
||||
expression='(#XMMEA_EM)&&(PATTERN<=12)&&(PI>=200)&&(PI<=12000)'
|
||||
|
||||
sci_image=work_dir+f'/EPIC_{key}_sci_image.fits' # Name of the output file
|
||||
# Extract an image for the science exposure
|
||||
inargs = [f'table={sci_clean}', f'expression={expression}',
|
||||
'imagebinning=binSize', f'imageset={sci_image}',
|
||||
'withimageset=yes','xcolumn=X', 'ycolumn=Y',
|
||||
'ximagebinsize=80', 'yimagebinsize=80',
|
||||
]
|
||||
w("evselect", inargs).run()
|
||||
|
||||
qpb_image=work_dir+f'/EPIC_{key}_qpb_image.fits' # Name of the output file
|
||||
# Extract an image for the FWC exposure
|
||||
inargs = [f'table={qpb_clean}', f'expression={expression}',
|
||||
'imagebinning=binSize', f'imageset={qpb_image}',
|
||||
'withimageset=yes','xcolumn=X', 'ycolumn=Y',
|
||||
'ximagebinsize=80', 'yimagebinsize=80','zcolumn=EWEIGHT',
|
||||
]
|
||||
w("evselect", inargs).run()
|
||||
|
||||
# Subtract background
|
||||
cor_image=work_dir+f'/EPIC_{key}_cor_image.fits' # Name of the output file
|
||||
cmd = ['farith', f'{sci_image}', f'{qpb_image}', f'{cor_image}', 'SUB',
|
||||
'copyprime=yes',
|
||||
'clobber=yes']
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
||||
|
||||
continue
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user