forked from xmm/arches
esas
This commit is contained in:
@@ -5,9 +5,10 @@ good=['0862470801','0862470701','0862470601']
|
||||
""" The angular size of an XMM DETXY physical coordinate system is 0.05 arcseconds """
|
||||
det_pix_as=0.05
|
||||
|
||||
arches_ra=266.4604208
|
||||
arches_dec=-28.8244444
|
||||
arches_Rmax_as=40
|
||||
""" Arches core R=15 arcsec """
|
||||
arches_ra=266.4595833
|
||||
arches_dec=-28.8219444
|
||||
arches_Rmax_as=15
|
||||
|
||||
pn_threshold = 0.2
|
||||
mos_threshold=[0.2,0.3]
|
||||
|
@@ -33,6 +33,24 @@ import shutil
|
||||
|
||||
from arches.config import *
|
||||
|
||||
def test_exe(program):
|
||||
""" Tests if executable exists in PATH """
|
||||
import os
|
||||
def is_exe(fpath):
|
||||
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
||||
|
||||
fpath, fname = os.path.split(program)
|
||||
if fpath:
|
||||
if is_exe(program):
|
||||
return program
|
||||
else:
|
||||
for path in os.environ["PATH"].split(os.pathsep):
|
||||
exe_file = os.path.join(path, program)
|
||||
if is_exe(exe_file):
|
||||
return exe_file
|
||||
|
||||
print("\n*** Command {} not found ***\n".format(program))
|
||||
sys.exit()
|
||||
|
||||
def create_folder(folder):
|
||||
if not (os.path.exists(folder)):
|
||||
@@ -157,7 +175,7 @@ def get_det_coords(ra,dec,image,key):
|
||||
dety=float(dy)
|
||||
return detx,dety
|
||||
|
||||
def run_mosspectra(key,ccds,check=False):
|
||||
def run_mosspectra(key,ccds,check=True):
|
||||
|
||||
eventfile = f'{key}-allevc.fits'
|
||||
|
||||
@@ -182,10 +200,11 @@ def run_mosspectra(key,ccds,check=False):
|
||||
'ximagemax=19500','yimagemax=19500', 'ximagemin=-19499', 'yimagemin=-19499',]
|
||||
w('evselect', inargs).run()
|
||||
|
||||
d = pyds9.DS9()
|
||||
d.set("file "+unfilt_image)
|
||||
d.set('cmap bb')
|
||||
d.set('scale log')
|
||||
#d = pyds9.DS9()
|
||||
#d.set("file "+unfilt_image)
|
||||
#d.set('cmap bb')
|
||||
#d.set('scale log')
|
||||
#return
|
||||
|
||||
|
||||
inargs = [f'eventfile={eventfile}',
|
||||
@@ -204,7 +223,7 @@ def run_mosspectra(key,ccds,check=False):
|
||||
|
||||
w('mosspectra', inargs).run()
|
||||
|
||||
def run_pnspectra(key,quads,check=False):
|
||||
def run_pnspectra(key,quads,check=True):
|
||||
eventfile = f'{key}-allevc.fits'
|
||||
|
||||
(detx,dety)=get_det_coords(arches_ra,arches_dec,f'{key}-fovimt.fits',key)
|
||||
@@ -228,10 +247,11 @@ def run_pnspectra(key,quads,check=False):
|
||||
'ximagemax=19500','yimagemax=19500', 'ximagemin=-19499', 'yimagemin=-19499',]
|
||||
w('evselect', inargs).run()
|
||||
|
||||
d = pyds9.DS9()
|
||||
d.set("file "+unfilt_image)
|
||||
d.set('cmap bb')
|
||||
d.set('scale log')
|
||||
#d = pyds9.DS9()
|
||||
#d.set("file "+unfilt_image)
|
||||
#d.set('cmap bb')
|
||||
#d.set('scale log')
|
||||
#return
|
||||
|
||||
inargs = [f'eventfile={key}-allevc.fits',
|
||||
'withsrcrem=yes',
|
||||
@@ -268,3 +288,37 @@ def run_pnback(key,quads):
|
||||
f'quads="{quads}"',]
|
||||
|
||||
w('pnback', inargs).run()
|
||||
|
||||
def group_spectrum(key=None, group_min=25, oot=False):
|
||||
if not (key):
|
||||
print("Provide key= parameter, e.g. mos1S001")
|
||||
return
|
||||
|
||||
test_exe('grppha')
|
||||
specfile=f'{key}-fovt.pi' if not (oot) else f'{key}-fovtootsub.pi'
|
||||
backfile=f'{key}-bkg.pi'
|
||||
respfile=f'{key}.rmf'
|
||||
ancrfile=f'{key}.arf'
|
||||
fout=f'{specfile}.grp'
|
||||
|
||||
cmd=["grppha",
|
||||
"infile={}".format(specfile),
|
||||
"outfile={}".format(fout),
|
||||
f"comm=\'chkey BACKFILE {backfile} & chkey RESPFILE {respfile} & chkey ANCRFILE {ancrfile} & GROUP MIN {group_min}\'",
|
||||
"tempc=EXIT",
|
||||
"clobber=yes",
|
||||
"chatter=0", # with chatter <= 5 being very quite and chatter >= 20 very verbose.
|
||||
]
|
||||
print((" ").join(cmd))
|
||||
os.system((" ").join(cmd))
|
||||
|
||||
fxcm = open(fout.replace("grp","xcm"), "w")
|
||||
fxcm.write(f'data {fout}\n')
|
||||
fxcm.write('ign **-2.\n')
|
||||
fxcm.write('ign 11.-**\n')
|
||||
fxcm.write('ign bad\n')
|
||||
fxcm.write('cpd /xs\n')
|
||||
fxcm.write('setpl en\n')
|
||||
fxcm.write('@../../data/xspec/wabs_apec_cflux.xcm\n')
|
||||
fxcm.write('pl lda delchi\n')
|
||||
fxcm.close()
|
||||
|
Reference in New Issue
Block a user