1
0
forked from xmm/sgrb2
This commit is contained in:
2025-09-29 16:02:01 +03:00
parent 507240ae56
commit ecf17c520d
7 changed files with 168 additions and 1702 deletions

2
.gitignore vendored
View File

@@ -16,7 +16,7 @@ lib64/
parts/
sdist/
var/
products/
products*/
data/archive
data/processed
wheels/

View File

@@ -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]

View File

@@ -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()

View 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

View 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

View 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)

File diff suppressed because it is too large Load Diff