generated from erosita/uds
esas
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,7 +16,7 @@ lib64/
|
|||||||
parts/
|
parts/
|
||||||
sdist/
|
sdist/
|
||||||
var/
|
var/
|
||||||
products/
|
products*/
|
||||||
data/archive
|
data/archive
|
||||||
data/processed
|
data/processed
|
||||||
wheels/
|
wheels/
|
||||||
|
@@ -5,9 +5,10 @@ good=['0862470801','0862470701','0862470601']
|
|||||||
""" The angular size of an XMM DETXY physical coordinate system is 0.05 arcseconds """
|
""" The angular size of an XMM DETXY physical coordinate system is 0.05 arcseconds """
|
||||||
det_pix_as=0.05
|
det_pix_as=0.05
|
||||||
|
|
||||||
arches_ra=266.4604208
|
""" Arches core R=15 arcsec """
|
||||||
arches_dec=-28.8244444
|
arches_ra=266.4595833
|
||||||
arches_Rmax_as=40
|
arches_dec=-28.8219444
|
||||||
|
arches_Rmax_as=15
|
||||||
|
|
||||||
pn_threshold = 0.2
|
pn_threshold = 0.2
|
||||||
mos_threshold=[0.2,0.3]
|
mos_threshold=[0.2,0.3]
|
||||||
|
@@ -33,6 +33,24 @@ import shutil
|
|||||||
|
|
||||||
from arches.config import *
|
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):
|
def create_folder(folder):
|
||||||
if not (os.path.exists(folder)):
|
if not (os.path.exists(folder)):
|
||||||
@@ -157,7 +175,7 @@ def get_det_coords(ra,dec,image,key):
|
|||||||
dety=float(dy)
|
dety=float(dy)
|
||||||
return detx,dety
|
return detx,dety
|
||||||
|
|
||||||
def run_mosspectra(key,ccds,check=False):
|
def run_mosspectra(key,ccds,check=True):
|
||||||
|
|
||||||
eventfile = f'{key}-allevc.fits'
|
eventfile = f'{key}-allevc.fits'
|
||||||
|
|
||||||
@@ -182,10 +200,11 @@ def run_mosspectra(key,ccds,check=False):
|
|||||||
'ximagemax=19500','yimagemax=19500', 'ximagemin=-19499', 'yimagemin=-19499',]
|
'ximagemax=19500','yimagemax=19500', 'ximagemin=-19499', 'yimagemin=-19499',]
|
||||||
w('evselect', inargs).run()
|
w('evselect', inargs).run()
|
||||||
|
|
||||||
d = pyds9.DS9()
|
#d = pyds9.DS9()
|
||||||
d.set("file "+unfilt_image)
|
#d.set("file "+unfilt_image)
|
||||||
d.set('cmap bb')
|
#d.set('cmap bb')
|
||||||
d.set('scale log')
|
#d.set('scale log')
|
||||||
|
#return
|
||||||
|
|
||||||
|
|
||||||
inargs = [f'eventfile={eventfile}',
|
inargs = [f'eventfile={eventfile}',
|
||||||
@@ -204,7 +223,7 @@ def run_mosspectra(key,ccds,check=False):
|
|||||||
|
|
||||||
w('mosspectra', inargs).run()
|
w('mosspectra', inargs).run()
|
||||||
|
|
||||||
def run_pnspectra(key,quads,check=False):
|
def run_pnspectra(key,quads,check=True):
|
||||||
eventfile = f'{key}-allevc.fits'
|
eventfile = f'{key}-allevc.fits'
|
||||||
|
|
||||||
(detx,dety)=get_det_coords(arches_ra,arches_dec,f'{key}-fovimt.fits',key)
|
(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',]
|
'ximagemax=19500','yimagemax=19500', 'ximagemin=-19499', 'yimagemin=-19499',]
|
||||||
w('evselect', inargs).run()
|
w('evselect', inargs).run()
|
||||||
|
|
||||||
d = pyds9.DS9()
|
#d = pyds9.DS9()
|
||||||
d.set("file "+unfilt_image)
|
#d.set("file "+unfilt_image)
|
||||||
d.set('cmap bb')
|
#d.set('cmap bb')
|
||||||
d.set('scale log')
|
#d.set('scale log')
|
||||||
|
#return
|
||||||
|
|
||||||
inargs = [f'eventfile={key}-allevc.fits',
|
inargs = [f'eventfile={key}-allevc.fits',
|
||||||
'withsrcrem=yes',
|
'withsrcrem=yes',
|
||||||
@@ -268,3 +288,37 @@ def run_pnback(key,quads):
|
|||||||
f'quads="{quads}"',]
|
f'quads="{quads}"',]
|
||||||
|
|
||||||
w('pnback', inargs).run()
|
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()
|
||||||
|
19
data/xspec/tbabs_apec_pow.xcm
Normal file
19
data/xspec/tbabs_apec_pow.xcm
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
method leven 10 0.01
|
||||||
|
abund wilm
|
||||||
|
xsect vern
|
||||||
|
cosmo 70 0 0.73
|
||||||
|
xset delta 0.01
|
||||||
|
systematic 0
|
||||||
|
model TBabs*constant(apec + gaussian + powerlaw)
|
||||||
|
8.43198 0.001 0 0 100000 1e+06
|
||||||
|
1 -1 0 0 1e+10 1e+10
|
||||||
|
3.02479 1 0.008 0.008 64 64
|
||||||
|
1.7 -1 0 0 5 5
|
||||||
|
0 -1 -0.999 -0.999 10 10
|
||||||
|
0.00132232 0.01 0 0 1e+20 1e+24
|
||||||
|
6.4 -1 0 0 1e+06 1e+06
|
||||||
|
0.1 -1 0 0 10 20
|
||||||
|
1.72861e-06 0.01 0 0 1e+20 1e+24
|
||||||
|
1.13 -1 -3 -2 9 10
|
||||||
|
3.35218e-05 0.01 0 0 1e+20 1e+24
|
||||||
|
bayes off
|
21
data/xspec/wabs_apec_cflux.xcm
Normal file
21
data/xspec/wabs_apec_cflux.xcm
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
method leven 10 0.01
|
||||||
|
abund wilm
|
||||||
|
xsect vern
|
||||||
|
cosmo 70 0 0.73
|
||||||
|
xset delta 0.01
|
||||||
|
systematic 0
|
||||||
|
model wabs(apec + cflux*powerlaw + gaussian)
|
||||||
|
5.87869 0.001 0 0 100000 1e+06
|
||||||
|
2.95206 0.01 0.008 0.008 64 64
|
||||||
|
1.7 -1 0 0 5 5
|
||||||
|
0 -1 -0.999 -0.999 10 10
|
||||||
|
0.00139339 0.01 0 0 1e+20 1e+24
|
||||||
|
2 -1 0 0 1e+06 1e+06
|
||||||
|
8 -1 0 0 1e+06 1e+06
|
||||||
|
-12.5886 0.01 -100 -100 100 100
|
||||||
|
1.13 -1 -3 -2 9 10
|
||||||
|
1 -1 0 0 1e+20 1e+24
|
||||||
|
6.4 -1 0 0 1e+06 1e+06
|
||||||
|
0.01 -1 0 0 10 20
|
||||||
|
1.45246e-06 0.01 0 0 1e+20 1e+24
|
||||||
|
bayes off
|
59
scripts/06_esas_group_spectra.py
Executable file
59
scripts/06_esas_group_spectra.py
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from pysas.wrapper import Wrapper as w
|
||||||
|
import os, sys
|
||||||
|
from os.path import dirname
|
||||||
|
import inspect
|
||||||
|
import glob
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
from os import path
|
||||||
|
import subprocess
|
||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from astropy.io import fits
|
||||||
|
from astropy.table import Table
|
||||||
|
from matplotlib.colors import LogNorm
|
||||||
|
|
||||||
|
import pyds9
|
||||||
|
|
||||||
|
import arches
|
||||||
|
from arches.utils import *
|
||||||
|
from arches.config import *
|
||||||
|
|
||||||
|
root_path=dirname(dirname(dirname(inspect.getfile(arches))))
|
||||||
|
print("Arches root path: {}".format(root_path))
|
||||||
|
|
||||||
|
archive_dir=root_path+'/data/archive'
|
||||||
|
events_dir=root_path+'/data/processed'
|
||||||
|
events_oot_dir=root_path+'/data/processed-oot'
|
||||||
|
products_dir=root_path+'/products'
|
||||||
|
ds9reg_dir=root_path+'/data/ds9reg'
|
||||||
|
|
||||||
|
create_folder(products_dir)
|
||||||
|
|
||||||
|
inargs = ['--version']
|
||||||
|
t = w('sasver', inargs)
|
||||||
|
t.run()
|
||||||
|
|
||||||
|
files = glob.glob(archive_dir+'/*')
|
||||||
|
|
||||||
|
for obsid in files:
|
||||||
|
obsid = os.path.basename(obsid)
|
||||||
|
|
||||||
|
if(obsid in skip):
|
||||||
|
continue
|
||||||
|
|
||||||
|
work_dir = init_work_dir(obsid)
|
||||||
|
print(f"\n*** jump to {work_dir} ***\n")
|
||||||
|
os.chdir(work_dir)
|
||||||
|
|
||||||
|
group_spectrum(key='mos1S001')
|
||||||
|
group_spectrum(key='mos2S002')
|
||||||
|
group_spectrum(key='pnS003')
|
||||||
|
group_spectrum(key='pnS003',oot=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1688
scripts/log
1688
scripts/log
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user