forked from erosita/uds
upd
This commit is contained in:
98
scripts/00_print_ecf.py
Executable file
98
scripts/00_print_ecf.py
Executable file
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
НАЗВАНИЕ:
|
||||
|
||||
05_srctool.py
|
||||
|
||||
|
||||
НАЗНАЧЕНИЕ:
|
||||
|
||||
Запускает scrtool для самого широкого канала 0.2-10 кэВ, чтобы спектры имели самое полное покрытие по энергиям. Список источников берется из 0.3-2.3 кэВ.
|
||||
|
||||
ВЫЗОВ:
|
||||
|
||||
esass
|
||||
./05_srctool.py
|
||||
|
||||
|
||||
УПРАВЛЕНИЕ:
|
||||
|
||||
Требуется запуск предыдущего скрипта 04_mosaics.py
|
||||
|
||||
ПАРАМЕТРЫ:
|
||||
|
||||
index=4 : Выбранный энергетический диапазон
|
||||
|
||||
|
||||
ВЫВОД:
|
||||
|
||||
Выходные файлы записываются в директорию outfile_dir/srctool_dir
|
||||
|
||||
|
||||
ИСТОРИЯ:
|
||||
|
||||
Роман Кривонос, ИКИ РАН, krivonos@cosmos.ru
|
||||
Март 2023
|
||||
|
||||
"""
|
||||
|
||||
from astropy.wcs import WCS
|
||||
from astropy.io import fits
|
||||
import sys, os, os.path, time, subprocess
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import glob
|
||||
from os.path import dirname
|
||||
import inspect
|
||||
import coma
|
||||
from scipy.stats import norm
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from coma.utils import *
|
||||
from coma.config import *
|
||||
|
||||
|
||||
|
||||
""" find UDS root dir """
|
||||
#root_path=dirname(dirname(dirname(inspect.getfile(uds))))
|
||||
"""
|
||||
ftools does not like long file path names,
|
||||
for this reason, we use relative path here
|
||||
"""
|
||||
root_path='..'
|
||||
print("Coma root path: {}".format(root_path))
|
||||
|
||||
infile_dir=root_path+'/data/processed'
|
||||
outfile_dir=root_path+'/products'
|
||||
create_folder(outfile_dir)
|
||||
|
||||
outkey="tm0"
|
||||
|
||||
outfile_srctool="{}_SrcTool_".format(outkey)
|
||||
|
||||
do_print_ecf = True
|
||||
|
||||
if(do_print_ecf==True):
|
||||
filename='../data/ECF/ecf_tbabspow_g2nh0.02.pkl'
|
||||
with open(filename, 'rb') as f:
|
||||
ecf_table = pickle.load(f)
|
||||
"""
|
||||
for key in table.keys():
|
||||
print("{} --> {}".format(key,table[key]))
|
||||
"""
|
||||
|
||||
print(ecf_table[(0.3,2.3)])
|
||||
print(ecf_table[(0.3,0.6)])
|
||||
print(ecf_table[(0.6,2.3)])
|
||||
print(ecf_table[(2.3,5.0)])
|
||||
print(ecf_table[(5.0,8.0)])
|
||||
print()
|
||||
print(ecf_table[(0.5,1.0)]) # 4XMM-DR12 EP2 band
|
||||
print(ecf_table[(1.0,2.0)]) # 4XMM-DR12 EP3 band
|
||||
print()
|
||||
print(ecf_table[(0.2,2.3)]) #
|
||||
print(ecf_table[(0.2,0.6)]) #
|
||||
print()
|
||||
print(ecf_table[(0.2,10.0)]) #
|
@@ -25,10 +25,19 @@ region="box({},{},12d,12d,0)".format(ra_cen,de_cen) # Selection region
|
||||
|
||||
|
||||
|
||||
tm_list=[1,2,3,4,5,6,7]
|
||||
#tm_list=[1,]
|
||||
|
||||
for m in [1,2,3,4,5,6,7]:
|
||||
print("tm{}_".format(m))
|
||||
do_evtool_esass(evlist=el+'tm{}_partI.txt'.format(m), outfile=pr+'tm{}_partI.fits'.format(m), gti='628781744.631552 628981200.', emin=0.2, emax=10.0, region=region, rmlock=True)
|
||||
do_partI = False
|
||||
do_partI_scans = False
|
||||
do_partII = False
|
||||
do_partII_scans = False
|
||||
do_survey = True
|
||||
|
||||
if(do_partI):
|
||||
for m in tm_list:
|
||||
print("tm{}_".format(m))
|
||||
do_evtool_esass(evlist=el+'tm{}_partI.txt'.format(m), outfile=pr+'tm{}_partI.fits'.format(m), gti='628781744.631552 628981200.', emin=0.2, emax=10.0, region=region, rmlock=True)
|
||||
|
||||
### Part I ###
|
||||
partI=[628781744.631552,
|
||||
@@ -39,32 +48,41 @@ partI=[628781744.631552,
|
||||
628981202.60192,]
|
||||
scan=1
|
||||
for i in range(len(partI)-1):
|
||||
print("partI scan={}".format(scan))
|
||||
tstart=partI[i]
|
||||
tstop=partI[i+1]
|
||||
for m in [1,2,3,4,5,6,7]:
|
||||
print("tm{}_partI_scan{}".format(m,i+1))
|
||||
do_evtool_esass(evlist=el+'tm{}_partI.txt'.format(m), outfile=pr+'tm{}_scan{}.fits'.format(m,scan), gti='{} {}'.format(tstart,tstop), emin=0.2, emax=10.0, region=region, rmlock=True)
|
||||
if(do_partI_scans):
|
||||
for m in tm_list:
|
||||
print("*** tm{}_partI_scan{}".format(m,scan))
|
||||
do_evtool_esass(evlist=el+'tm{}_partI.txt'.format(m), outfile=pr+'tm{}_scan{}.fits'.format(m,scan), gti='{} {}'.format(tstart,tstop), emin=0.2, emax=10.0, region=region, rmlock=True)
|
||||
scan=scan+1
|
||||
|
||||
### Part II ###
|
||||
for m in [1,2,3,4,5,6,7]:
|
||||
print("tm{}_".format(m))
|
||||
do_evtool_esass(evlist=el+'tm{}_partII.txt'.format(m), outfile=pr+'tm{}_partII.fits'.format(m), gti='645681013.670848 645832002.60928', emin=0.2, emax=10.0, region=region, rmlock=True)
|
||||
if(do_partII):
|
||||
for m in tm_list:
|
||||
print("tm{}_".format(m))
|
||||
do_evtool_esass(evlist=el+'tm{}_partII.txt'.format(m), outfile=pr+'tm{}_partII.fits'.format(m), gti='645681013.670848 645832002.60928', emin=0.2, emax=10.0, region=region, rmlock=True)
|
||||
|
||||
partII=[645681013.670848,645746786.665408,645832002.60928]
|
||||
partII=[645681013.670848,
|
||||
645746786.665408,
|
||||
645832002.60928]
|
||||
for i in range(len(partII)-1):
|
||||
print("partII scan={}".format(scan))
|
||||
tstart=partII[i]
|
||||
tstop=partII[i+1]
|
||||
for m in [1,2,3,4,5,6,7]:
|
||||
print("tm{}_partII_scan{}".format(m,i+1))
|
||||
do_evtool_esass(evlist=el+'tm{}_partII.txt'.format(m), outfile=pr+'tm{}_scan{}.fits'.format(m,scan), gti='{} {}'.format(tstart,tstop), emin=0.2, emax=10.0, region=region, rmlock=True)
|
||||
if(do_partII_scans):
|
||||
for m in tm_list:
|
||||
print("*** tm{}_partII_scan{}".format(m,scan))
|
||||
do_evtool_esass(evlist=el+'tm{}_partII.txt'.format(m), outfile=pr+'tm{}_scan{}.fits'.format(m,scan), gti='{} {}'.format(tstart,tstop), emin=0.2, emax=10.0, region=region, rmlock=True)
|
||||
scan=scan+1
|
||||
|
||||
|
||||
"""
|
||||
|
||||
### Survey ###
|
||||
for m in [1,2,3,4,5,6,7]:
|
||||
do_evtool_esass(evlist=el+'tm{}_survey.txt'.format(m), outfile=pr+'tm{}_survey.fits'.format(m), emin=0.2, emax=10.0, rmlock=True)
|
||||
if(do_survey):
|
||||
for m in tm_list:
|
||||
do_evtool_esass(evlist=el+'tm{}_survey.txt'.format(m), outfile=pr+'tm{}_survey.fits'.format(m), emin=0.2, emax=10.0, rmlock=True, rusky=True)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
@@ -17,7 +17,6 @@ import coma
|
||||
from coma.utils import *
|
||||
from coma.config import *
|
||||
|
||||
outkey="mosa_tm0"
|
||||
|
||||
""" find root dir """
|
||||
|
||||
@@ -36,28 +35,33 @@ outfile_dir=root_path+'/products'
|
||||
create_folder(outfile_dir)
|
||||
|
||||
|
||||
do_init = False
|
||||
do_merge = True
|
||||
do_rate = False
|
||||
do_init = True
|
||||
do_merge = False
|
||||
do_rate = False
|
||||
do_adapt = False # requires CIAO
|
||||
|
||||
index=5 # select energy band
|
||||
width=7000
|
||||
index=0 # select energy band
|
||||
width=10000
|
||||
|
||||
vign=True
|
||||
vignetting = 'vign' if (vign==True) else 'novign'
|
||||
|
||||
#print(ra_cen, de_cen)
|
||||
#sys.exit()
|
||||
outkey="mosa_all_tm0"
|
||||
|
||||
events=[]
|
||||
expmaps=[]
|
||||
bkgmaps=[]
|
||||
for tmkey in keylist_tm.keys():
|
||||
|
||||
keylist=keylist_survey
|
||||
|
||||
for tmkey in keylist.keys():
|
||||
#if not (tmkey == '2'):
|
||||
# continue
|
||||
print("TM{} in work... init events".format(tmkey))
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
if ("survey" in datakey):
|
||||
continue
|
||||
for datakey in keylist[tmkey]:
|
||||
#if not ("survey" in datakey):
|
||||
# continue
|
||||
|
||||
print("--> {}".format(datakey))
|
||||
""" Подготавливаем списки событий индивидуальных наблюдений """
|
||||
outfile_evtool,outfile_expmap=init_events(key=datakey, eband_index=eband[index],
|
||||
@@ -67,21 +71,21 @@ for tmkey in keylist_tm.keys():
|
||||
do_obsmode=True, # also controlled by lock file!
|
||||
do_center=True, # also controlled by lock file!
|
||||
do_evtool=True,
|
||||
do_expmap=True,
|
||||
do_expmap=False,
|
||||
vign=vign,
|
||||
ra_cen=ra_cen, de_cen=de_cen, width=width,
|
||||
emin_kev=emin_kev[index],
|
||||
emax_kev=emax_kev[index])
|
||||
events.append(outfile_evtool)
|
||||
expmaps.append(outfile_expmap)
|
||||
bkgmaps.append("{}_BackMap3_en{}.fits".format(os.path.join(outfile_dir,datakey), eband[0]))
|
||||
bkgmaps.append("{}_BackMap3_en{:02d}.fits".format(os.path.join(outfile_dir,datakey), eband[0]))
|
||||
|
||||
|
||||
""" Собираем общий список событий """
|
||||
outfile_evtool="{}_EventList_en{}.fits".format(os.path.join(outfile_dir,outkey), eband[index])
|
||||
outfile_evtool="{}_EventList_en{:02d}.fits".format(os.path.join(outfile_dir,outkey), eband[index])
|
||||
|
||||
outfile_expmap="{}_ExposureMap_en{}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
outfile_bkgmap="{}_BackMap_en{}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
outfile_expmap="{}_ExposureMap_en{:02d}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
outfile_bkgmap="{}_BackMap_en{:02d}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
|
||||
if(do_merge==True):
|
||||
evlist="{}.evlist.txt".format(os.getpid())
|
||||
@@ -91,22 +95,23 @@ if(do_merge==True):
|
||||
f.close()
|
||||
|
||||
do_evtool_esass(evlist=evlist, outfile=outfile_evtool, width=width)
|
||||
|
||||
# old version, does not work with long list of files
|
||||
#do_evtool_esass(events=events, outfile=outfile_evtool)
|
||||
|
||||
#do_fimgmerge_ftools(maps=expmaps, outfile=outfile_expmap)
|
||||
do_fimgmerge_ftools(maps=expmaps, outfile=outfile_expmap)
|
||||
#do_fimgmerge_ftools(maps=bkgmaps, outfile=outfile_bkgmap)
|
||||
|
||||
if(os.path.isfile(evlist)==True):
|
||||
os.remove(evlist)
|
||||
|
||||
outfile_rate="{}_RateMap_en{}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
outfile_rate="{}_RateMap_en{:02d}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
if(do_rate==True):
|
||||
make_rate_map(cntmap=outfile_evtool, expmap=outfile_expmap, outfile=outfile_rate)
|
||||
|
||||
|
||||
function='gaussian'
|
||||
outfile_adapt="{}_ImageAdapt_en{}.{}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], function, vignetting)
|
||||
outfile_adapt="{}_ImageAdapt_en{:02d}.{}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], function, vignetting)
|
||||
if(do_adapt==True):
|
||||
do_adapt_ciao(infile=outfile_evtool, outfile=outfile_adapt, expmap=outfile_expmap, function=function, expcut=100)
|
||||
|
||||
|
@@ -47,48 +47,50 @@ from multiprocessing import Pool
|
||||
|
||||
from os.path import dirname
|
||||
import inspect
|
||||
import uds
|
||||
import coma
|
||||
|
||||
from uds.utils import *
|
||||
from uds.config import *
|
||||
from coma.utils import *
|
||||
from coma.config import *
|
||||
|
||||
|
||||
""" find UDS root dir """
|
||||
root_path=dirname(dirname(dirname(inspect.getfile(uds))))
|
||||
print("UDS root path: {}".format(root_path))
|
||||
""" find Coma root dir """
|
||||
root_path=dirname(dirname(dirname(inspect.getfile(coma))))
|
||||
print("Coma root path: {}".format(root_path))
|
||||
|
||||
infile_dir=root_path+'/data/processed'
|
||||
outfile_dir=root_path+'/products'
|
||||
create_folder(outfile_dir)
|
||||
|
||||
run_Pool=False
|
||||
keylist=keylist_survey
|
||||
|
||||
do_init = False
|
||||
do_ermask = False
|
||||
do_init = True
|
||||
do_ermask = True
|
||||
|
||||
do_erbox1 = False # local mode
|
||||
do_erbackmap1 = False #
|
||||
do_erbox2 = False # map mode, with background map
|
||||
do_erbackmap2 = False #
|
||||
do_erbox3 = False # map mode, with background map
|
||||
do_erbackmap3 = False #
|
||||
do_erbox1 = True # local mode
|
||||
do_erbackmap1 = True #
|
||||
do_erbox2 = True # map mode, with background map
|
||||
do_erbackmap2 = True #
|
||||
do_erbox3 = True # map mode, with background map
|
||||
do_erbackmap3 = True #
|
||||
|
||||
do_ermldet = False
|
||||
do_catprep = False
|
||||
do_cross_match = False
|
||||
do_ermldet = True
|
||||
do_catprep = True
|
||||
do_cross_match = True
|
||||
|
||||
do_astro_corr = False # search optimal shift
|
||||
do_astro_update = True
|
||||
do_astro_corr = True # search optimal shift
|
||||
do_astro_update = True
|
||||
|
||||
do_wcs_match = False # Chandra task -- DEPRECATED
|
||||
do_wcs_update = False # Chandra task -- DEPRECATED
|
||||
|
||||
eband_selected=[5]
|
||||
eband_selected=[0]
|
||||
|
||||
vign=True
|
||||
vign=False
|
||||
vignetting = 'vign' if (vign==True) else 'novign'
|
||||
|
||||
|
||||
width=10000
|
||||
|
||||
def runme(datakey):
|
||||
""" runs datakey over energy bands """
|
||||
events=[]
|
||||
@@ -120,7 +122,7 @@ def runme(datakey):
|
||||
do_evtool=True,
|
||||
do_expmap=True,
|
||||
vign=vign,
|
||||
ra_cen=ra_cen, de_cen=de_cen,
|
||||
ra_cen=ra_cen, de_cen=de_cen, width=width,
|
||||
emin_kev=emin_kev[index],
|
||||
emax_kev=emax_kev[index])
|
||||
expmaps.append(outfile_expmap)
|
||||
@@ -151,7 +153,7 @@ def runme(datakey):
|
||||
print("\t>>> Energy band en{} -- {}-{} keV".format(eband[index],emin_kev[index],emax_kev[index]))
|
||||
|
||||
""" erbox in local mode """
|
||||
outfile_boxlist1.append("{}_BoxList1_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
outfile_boxlist1.append("{}_BoxList1_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
if(do_erbox1==True):
|
||||
""" erbox in local mode """
|
||||
cmd=["erbox",
|
||||
@@ -178,8 +180,8 @@ def runme(datakey):
|
||||
save_ds9reg(outfile_boxlist1[ii])
|
||||
|
||||
|
||||
outfile_backmap1.append("{}_BackMap1_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
cheese_mask="{}_CheeseMask1_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
outfile_backmap1.append("{}_BackMap1_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
cheese_mask="{}_CheeseMask1_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
if(do_erbackmap1==True):
|
||||
""" back map 1 """
|
||||
cmd=["erbackmap",
|
||||
@@ -205,7 +207,7 @@ def runme(datakey):
|
||||
os.system((" ").join(cmd))
|
||||
print((" ").join(cmd))
|
||||
|
||||
outfile_boxlist2.append("{}_BoxList2_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
outfile_boxlist2.append("{}_BoxList2_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
if(do_erbox2==True):
|
||||
""" erbox in background mode """
|
||||
cmd=["erbox",
|
||||
@@ -233,8 +235,8 @@ def runme(datakey):
|
||||
save_ds9reg(outfile_boxlist2[ii])
|
||||
|
||||
|
||||
outfile_backmap2.append("{}_BackMap2_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
cheese_mask="{}_CheeseMask2_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
outfile_backmap2.append("{}_BackMap2_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
cheese_mask="{}_CheeseMask2_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
if(do_erbackmap2==True):
|
||||
""" back map 2 """
|
||||
cmd=["erbackmap",
|
||||
@@ -260,7 +262,7 @@ def runme(datakey):
|
||||
os.system((" ").join(cmd))
|
||||
print((" ").join(cmd))
|
||||
|
||||
outfile_boxlist3.append("{}_BoxList3_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
outfile_boxlist3.append("{}_BoxList3_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
if(do_erbox3==True):
|
||||
""" erbox in map mode FINAL """
|
||||
cmd=["erbox",
|
||||
@@ -287,8 +289,8 @@ def runme(datakey):
|
||||
os.system((" ").join(cmd))
|
||||
save_ds9reg(outfile_boxlist3[ii])
|
||||
|
||||
outfile_backmap3.append("{}_BackMap3_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
cheese_mask="{}_CheeseMask3_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
outfile_backmap3.append("{}_BackMap3_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post))
|
||||
cheese_mask="{}_CheeseMask3_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
if(do_erbackmap3==True):
|
||||
""" back map 3 FINAL """
|
||||
cmd=["erbackmap",
|
||||
@@ -314,8 +316,8 @@ def runme(datakey):
|
||||
os.system((" ").join(cmd))
|
||||
print((" ").join(cmd))
|
||||
|
||||
mllist="{}_MaxLikSourceList_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
srcmap="{}_SourceMap_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
mllist="{}_MaxLikSourceList_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
srcmap="{}_SourceMap_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
|
||||
cmd=["ermldet",
|
||||
"mllist=%s" %(mllist),
|
||||
@@ -359,8 +361,8 @@ def runme(datakey):
|
||||
print((" ").join(cmd))
|
||||
save_ermldet_ds9reg(mllist,scale=60*60)
|
||||
|
||||
catprep="{}_SourceCatalog_en{}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
catprep_en0="{}_SourceCatalog_en{}{}".format(os.path.join(outfile_dir,datakey), eband[0], outfile_post)
|
||||
catprep="{}_SourceCatalog_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[index], outfile_post)
|
||||
catprep_en0="{}_SourceCatalog_en{:02d}{}".format(os.path.join(outfile_dir,datakey), eband[0], outfile_post)
|
||||
if(do_catprep==True):
|
||||
cmd=["catprep",
|
||||
"infile={}".format(mllist),
|
||||
@@ -371,21 +373,23 @@ def runme(datakey):
|
||||
save_catprep_ds9reg(catprep,scale=60*60)
|
||||
|
||||
if(do_cross_match==True):
|
||||
crossmatch_shu2019(catprep,dlmin=10,refimage=events[ii],crval=wcslist[datakey],
|
||||
catalog=root_path+"/data/Gaia_unWISE/Gaia_unWISE_UDS.fits.catalog",errlim=5.0)
|
||||
crossmatch_shu2019(catprep, dlmin=10,crval=[ra_cen, de_cen], refimage=events[ii],datakey=datakey,
|
||||
catalog=root_path+"/data/Gaia_unWISE/Gaia_unWISE_Coma.fits.catalog",errlim=5.0)
|
||||
|
||||
if(do_astro_corr==True and eband[index]=='0'):
|
||||
if(do_astro_corr==True and eband[index]==0):
|
||||
""" run astro_corr for 0.3-2.3 keV only """
|
||||
print("START")
|
||||
wcs_astro_corr(catprep)
|
||||
#wcs_match_ciao(catprep, method='rst',radius=12,residlim=0,residtype=0,residfac=1)
|
||||
|
||||
if(do_astro_update==True):
|
||||
""" run astro_corr for 0.3-2.3 keV only """
|
||||
attcorr=wcs_update_shift(events[ii],flog=catprep_en0.replace(".fits", ".shift.log"))
|
||||
do_evtool_esass(evfile=attcorr,outfile=attcorr,rmlock=False, do_center=True, ra_cen=ra_cen, de_cen=de_cen)
|
||||
do_evtool_esass(evfile=attcorr,outfile=attcorr,rmlock=False, do_center=True, ra_cen=ra_cen, de_cen=de_cen, width=width)
|
||||
|
||||
|
||||
|
||||
if(do_wcs_match==True and eband[index]=='0'):
|
||||
if(do_wcs_match==True and eband[index] == 0):
|
||||
""" run wcs_match for 0.3-2.3 keV only """
|
||||
wcs_match_ciao(catprep, method='trans',radius=12,residlim=5)
|
||||
#wcs_match_ciao(catprep, method='rst',radius=12,residlim=0,residtype=0,residfac=1)
|
||||
@@ -393,7 +397,7 @@ def runme(datakey):
|
||||
if(do_wcs_update==True):
|
||||
""" use 0.3-2.3 keV transform matrix for all other bands """
|
||||
attcorr=wcs_update_ciao(events[ii],crval=wcslist[datakey],transformfile=catprep_en0.replace(".fits", ".xfm"),clean=False)
|
||||
do_evtool_esass(evfile=attcorr,outfile=attcorr,rmlock=False, do_center=True, ra_cen=ra_cen, de_cen=de_cen)
|
||||
do_evtool_esass(evfile=attcorr,outfile=attcorr,rmlock=False, do_center=True, ra_cen=ra_cen, de_cen=de_cen, width=width)
|
||||
|
||||
|
||||
"""
|
||||
@@ -403,13 +407,16 @@ runme("tm5_obs_1")
|
||||
runme("tm6_scan_1")
|
||||
"""
|
||||
|
||||
#runme("tm1_scan1")
|
||||
|
||||
|
||||
|
||||
|
||||
if(run_Pool==True):
|
||||
# parallel run
|
||||
items=[]
|
||||
for tmkey in keylist_tm.keys():
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
for tmkey in keylist.keys():
|
||||
for datakey in keylist[tmkey]:
|
||||
items.append(datakey)
|
||||
|
||||
with Pool() as pool:
|
||||
@@ -417,8 +424,9 @@ if(run_Pool==True):
|
||||
|
||||
else:
|
||||
# conventional run
|
||||
for tmkey in keylist_tm.keys():
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
for tmkey in keylist.keys():
|
||||
for datakey in keylist[tmkey]:
|
||||
print("--> {}".format(datakey))
|
||||
runme(datakey)
|
||||
#sys.exit()
|
||||
|
||||
|
@@ -51,50 +51,51 @@ import pickle
|
||||
|
||||
|
||||
|
||||
import uds
|
||||
import coma
|
||||
|
||||
from uds.utils import *
|
||||
from uds.config import *
|
||||
from coma.utils import *
|
||||
from coma.config import *
|
||||
|
||||
|
||||
""" find UDS root dir """
|
||||
#root_path=dirname(dirname(dirname(inspect.getfile(uds))))
|
||||
""" find Coma root dir """
|
||||
root_path=dirname(dirname(dirname(inspect.getfile(coma))))
|
||||
|
||||
"""
|
||||
ftools does not like long file path names,
|
||||
for this reason, we use relative path here
|
||||
"""
|
||||
root_path='..'
|
||||
print("UDS root path: {}".format(root_path))
|
||||
#root_path='..'
|
||||
|
||||
print("Coma root path: {}".format(root_path))
|
||||
|
||||
infile_dir=root_path+'/data/processed'
|
||||
outfile_dir=root_path+'/products'
|
||||
create_folder(outfile_dir)
|
||||
|
||||
local_run = False
|
||||
local_run = True
|
||||
|
||||
outkey="tm0"
|
||||
|
||||
do_init = True
|
||||
do_merge = True
|
||||
do_detmask = True
|
||||
do_expmap = True
|
||||
do_erbox1 = True # local mode
|
||||
do_erbackmap1 = True #
|
||||
do_erbox2 = True # map mode, with background map
|
||||
do_erbackmap2 = True #
|
||||
do_erbox3 = True # map mode, with background map
|
||||
do_erbackmap3 = True #
|
||||
do_detmask = False
|
||||
do_expmap = False
|
||||
do_erbox1 = False # local mode
|
||||
do_erbackmap1 = False #
|
||||
do_erbox2 = False # map mode, with background map
|
||||
do_erbackmap2 = False #
|
||||
do_erbox3 = False # map mode, with background map
|
||||
do_erbackmap3 = False #
|
||||
do_ersensmap = False
|
||||
do_ermldet = True
|
||||
do_ermldet = False
|
||||
do_fixcat = False # only for index=0
|
||||
do_fixxmm = False # prepare forced photometry, only for index=0
|
||||
do_apetool = False
|
||||
do_catprep = True
|
||||
do_catprep = False
|
||||
do_filter_catalog = False
|
||||
|
||||
do_cross_match = False
|
||||
|
||||
index=3
|
||||
index=0
|
||||
|
||||
forced=False
|
||||
""" If forced=True, take input catalog from energy range en0 """
|
||||
@@ -103,29 +104,39 @@ comm='' # for 4XMM-DR12 forced photometry use '-xmm'
|
||||
|
||||
|
||||
vign=True
|
||||
attcorr=False
|
||||
|
||||
keylist = keylist_tm
|
||||
outkey = "mosa_all_tm0{}".format('_attcorr' if (attcorr==True) else '')
|
||||
|
||||
"""
|
||||
mosa_scans_tm0 -- all scans individually (keylist_scans)
|
||||
mosa_partI_tm0 -- partI only (as is) (keylist_partI)
|
||||
mosa_partII_tm0 -- partII only (as is) (keylist_partII)
|
||||
mosa_parts_tm0 -- all parts (partI and partII) (keylist_parts)
|
||||
mosa_all_tm0 -- all scans (scan1-7) and survey data (keylist_tm)
|
||||
"""
|
||||
|
||||
vignetting = 'vign' if (vign==True) else 'novign'
|
||||
|
||||
attcorr=True
|
||||
|
||||
events=[]
|
||||
expmaps=[]
|
||||
bkgmaps=[]
|
||||
for tmkey in keylist_tm.keys():
|
||||
for tmkey in keylist.keys():
|
||||
print("TM{} in work... init events".format(tmkey))
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
print("--> {}".format(datakey))
|
||||
for datakey in keylist[tmkey]:
|
||||
#print("--> {}".format(datakey))
|
||||
""" Подготавливаем списки событий индивидуальных наблюдений """
|
||||
outfile_evtool,outfile_expmap=init_events(key=datakey,attcorr=attcorr,
|
||||
eband_index=eband[index],
|
||||
infile_dir=infile_dir,
|
||||
outfile_dir=outfile_dir,
|
||||
do_init=do_init,
|
||||
do_obsmode=False,
|
||||
do_center=False,
|
||||
do_obsmode=True,
|
||||
do_center=True,
|
||||
do_evtool=True,
|
||||
do_expmap=False,
|
||||
vign=vign,
|
||||
ra_cen=ra_cen, de_cen=de_cen,
|
||||
ra_cen=ra_cen, de_cen=de_cen, width=width,
|
||||
emin_kev=emin_kev[index],
|
||||
emax_kev=emax_kev[index])
|
||||
events.append(outfile_evtool)
|
||||
@@ -133,15 +144,25 @@ for tmkey in keylist_tm.keys():
|
||||
|
||||
|
||||
""" Собираем общий список событий """
|
||||
outfile_evtool="{}_EventList_en{}.fits".format(os.path.join(outfile_dir,outkey),
|
||||
outfile_evtool="{}_EventList_en{:02d}.fits".format(os.path.join(outfile_dir,outkey),
|
||||
eband[index])
|
||||
|
||||
if(do_merge==True):
|
||||
do_evtool_esass(events=events, outfile=outfile_evtool)
|
||||
#do_evtool_esass(events=events, outfile=outfile_evtool)
|
||||
evlist="{}.evlist.txt".format(os.getpid())
|
||||
f = open(evlist, "w")
|
||||
for s in events:
|
||||
f.write("{}\n".format(s))
|
||||
f.close()
|
||||
print(outfile_evtool)
|
||||
do_check_events(events=events)
|
||||
do_evtool_esass(evlist=evlist, outfile=outfile_evtool, width=width)
|
||||
#if(os.path.isfile(evlist)==True):
|
||||
# os.remove(evlist)
|
||||
|
||||
|
||||
""" makes detmask from TM exposures """
|
||||
detmask="{}/{}_DetectorMask_en{}{}".format(outfile_dir,
|
||||
detmask="{}/{}_DetectorMask_en{:02d}{}".format(outfile_dir,
|
||||
outkey,
|
||||
eband[index],
|
||||
outfile_post)
|
||||
@@ -151,16 +172,16 @@ if(do_detmask==True):
|
||||
"""
|
||||
Собираем общую карту экспозиции, обратите внимание на коэффициент 7.
|
||||
Экспозиция рассчитывается на 7 телескопов.
|
||||
outfile_expmap="{}_ExposureMap_en{}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
outfile_bkgmap="{}_BackMap_en{}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
outfile_expmap="{}_ExposureMap_en{:02d}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
outfile_bkgmap="{}_BackMap_en{:02d}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
|
||||
"""
|
||||
outfile_expmap="{}_ExposureMap_en{}.{}{}".format(os.path.join(outfile_dir,outkey),
|
||||
outfile_expmap="{}_ExposureMap_en{:02d}.{}{}".format(os.path.join(outfile_dir,outkey),
|
||||
eband[index],vignetting,
|
||||
outfile_post)
|
||||
if(do_expmap==True):
|
||||
create_expmap_merged(expmaps,outfile_expmap,scale=7.0)
|
||||
|
||||
outfile_boxlist1="{}/{}_BoxList1_en{}{}".format(outfile_dir,outkey, eband[index], outfile_post)
|
||||
outfile_boxlist1="{}/{}_BoxList1_en{:02d}{}".format(outfile_dir,outkey, eband[index], outfile_post)
|
||||
if(do_erbox1==True):
|
||||
cmd=["erbox",
|
||||
"images=\'{}\'".format(outfile_evtool),
|
||||
@@ -184,13 +205,13 @@ if(do_erbox1==True):
|
||||
save_ds9reg(outfile_boxlist1)
|
||||
|
||||
""" Background map 1 """
|
||||
outfile_backmap1="{}_BackMap1_en{}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
cheese_mask="{}_CheeseMask1_en{}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
outfile_backmap1="{}_BackMap1_en{:02d}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
cheese_mask="{}_CheeseMask1_en{:02d}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
if(do_erbackmap1==True):
|
||||
do_erbackmap_esass(outfile_evtool,outfile_expmap,outfile_boxlist1,detmask,emin_ev[index],emax_ev[index],
|
||||
outfile_backmap1,cheese_mask)
|
||||
|
||||
outfile_boxlist2="{}/{}_BoxList2_en{}{}".format(outfile_dir,outkey, eband[index], outfile_post)
|
||||
outfile_boxlist2="{}/{}_BoxList2_en{:02d}{}".format(outfile_dir,outkey, eband[index], outfile_post)
|
||||
if(do_erbox2==True):
|
||||
cmd=["erbox",
|
||||
"images=\'{}\'".format(outfile_evtool),
|
||||
@@ -215,13 +236,13 @@ if(do_erbox2==True):
|
||||
save_ds9reg(outfile_boxlist2)
|
||||
|
||||
""" Background map 2 """
|
||||
outfile_backmap2="{}_BackMap2_en{}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
cheese_mask="{}_CheeseMask2_en{}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
outfile_backmap2="{}_BackMap2_en{:02d}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
cheese_mask="{}_CheeseMask2_en{:02d}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
if(do_erbackmap2==True):
|
||||
do_erbackmap_esass(outfile_evtool,outfile_expmap,outfile_boxlist2,detmask,emin_ev[index],emax_ev[index],
|
||||
outfile_backmap2,cheese_mask)
|
||||
|
||||
outfile_boxlist3="{}/{}_BoxList3_en{}{}".format(outfile_dir,outkey, eband[index], outfile_post)
|
||||
outfile_boxlist3="{}/{}_BoxList3_en{:02d}{}".format(outfile_dir,outkey, eband[index], outfile_post)
|
||||
if(do_erbox3==True):
|
||||
cmd=["erbox",
|
||||
"images=\'{}\'".format(outfile_evtool),
|
||||
@@ -246,21 +267,21 @@ if(do_erbox3==True):
|
||||
save_ds9reg(outfile_boxlist3)
|
||||
|
||||
""" Background map 3 """
|
||||
outfile_backmap3="{}_BackMap3_en{}.{}{}".format(os.path.join(outfile_dir,outkey), eband[index], vignetting, outfile_post)
|
||||
cheese_mask="{}_CheeseMask3_en{}.{}{}".format(os.path.join(outfile_dir,outkey), eband[index], vignetting, outfile_post)
|
||||
outfile_backmap3="{}_BackMap3_en{:02d}.{}{}".format(os.path.join(outfile_dir,outkey), eband[index], vignetting, outfile_post)
|
||||
cheese_mask="{}_CheeseMask3_en{:02d}.{}{}".format(os.path.join(outfile_dir,outkey), eband[index], vignetting, outfile_post)
|
||||
if(do_erbackmap3==True):
|
||||
boxlist3 = outfile_boxlist3 if(forced == False) else "{}/{}_BoxList3_en{}{}".format(outfile_dir,outkey, eband[0], outfile_post)
|
||||
boxlist3 = outfile_boxlist3 if(forced == False) else "{}/{}_BoxList3_en{:02d}{}".format(outfile_dir,outkey, eband[0], outfile_post)
|
||||
do_erbackmap_esass(outfile_evtool,outfile_expmap,boxlist3,detmask,emin_ev[index],emax_ev[index],
|
||||
outfile_backmap3,cheese_mask)
|
||||
|
||||
if(forced==True):
|
||||
mllist="{}_MaxLikSourceList_en{}.forced{}{}".format(os.path.join(outfile_dir,outkey), eband[index], comm, outfile_post)
|
||||
srcmap="{}_SourceMap_en{}.forced{}{}".format(os.path.join(outfile_dir,outkey), eband[index], comm, outfile_post)
|
||||
mllist="{}_MaxLikSourceList_en{:02d}.forced{}{}".format(os.path.join(outfile_dir,outkey), eband[index], comm, outfile_post)
|
||||
srcmap="{}_SourceMap_en{:02d}.forced{}{}".format(os.path.join(outfile_dir,outkey), eband[index], comm, outfile_post)
|
||||
|
||||
""" for en1,2,3,6 give mllist from en0 as input """
|
||||
#boxlist3="{}_MaxLikSourceList_en{}.forced{}{}".format(os.path.join(outfile_dir,outkey), eband[0], comm, outfile_post)
|
||||
#boxlist3="{}_MaxLikSourceList_en{:02d}.forced{}{}".format(os.path.join(outfile_dir,outkey), eband[0], comm, outfile_post)
|
||||
#if(index==0):
|
||||
boxlist3="{}_MaxLikSourceList_en{}.fixed{}{}".format(os.path.join(outfile_dir,outkey), eband[0], comm, outfile_post)
|
||||
boxlist3="{}_MaxLikSourceList_en{:02d}.fixed{}{}".format(os.path.join(outfile_dir,outkey), eband[0], comm, outfile_post)
|
||||
if not (os.path.exists(boxlist3)):
|
||||
print("{} not found. Run do_fixcat=True, index=0, forced=False".format(boxlist3))
|
||||
sys.exit()
|
||||
@@ -274,11 +295,11 @@ if(forced==True):
|
||||
cutrad="cutrad=15."
|
||||
if(index == 3 or index == 6):
|
||||
""" for hard band take unvignetted background """
|
||||
outfile_backmap3="{}_BackMap3_en{}.{}{}".format(os.path.join(outfile_dir,outkey), eband[index], "novign", outfile_post)
|
||||
outfile_backmap3="{}_BackMap3_en{:02d}.{}{}".format(os.path.join(outfile_dir,outkey), eband[index], "novign", outfile_post)
|
||||
|
||||
else:
|
||||
mllist="{}_MaxLikSourceList_en{}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
srcmap="{}_SourceMap_en{}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
mllist="{}_MaxLikSourceList_en{:02d}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
srcmap="{}_SourceMap_en{:02d}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
boxlist3 = outfile_boxlist3
|
||||
fitpos_flag="fitpos_flag=yes"
|
||||
fitext_flag="fitext_flag=yes"
|
||||
@@ -325,18 +346,14 @@ cmd=["ermldet",
|
||||
|
||||
if(do_ersensmap==True):
|
||||
detlike=10
|
||||
create_sensmap(sensmap="{}_SensitivityMap_dl{}_en{}{}".format(os.path.join(outfile_dir,outkey), detlike,
|
||||
eband[index], outfile_post),
|
||||
areatab="{}_AreaTable_dl{}_en{}{}".format(os.path.join(outfile_dir,outkey),
|
||||
detlike, eband[index], outfile_post),
|
||||
create_sensmap(sensmap="{}_SensitivityMap_dl{}_en{:02d}{}".format(os.path.join(outfile_dir,outkey), detlike, eband[index], outfile_post),
|
||||
areatab="{}_AreaTable_dl{}_en{:02d}{}".format(os.path.join(outfile_dir,outkey), detlike, eband[index], outfile_post),
|
||||
expmap=outfile_expmap, backmap=outfile_backmap3,detlike=detlike,
|
||||
detmask=detmask, emin=emin_ev[index], emax=emax_ev[index],ecf=ecf[index])
|
||||
"""
|
||||
detlike=6
|
||||
create_sensmap(sensmap="{}_SensitivityMap_dl{}_en{}{}".format(os.path.join(outfile_dir,outkey), detlike,
|
||||
eband[index], outfile_post),
|
||||
areatab="{}_AreaTable_dl{}_en{}{}".format(os.path.join(outfile_dir,outkey),
|
||||
detlike, eband[index], outfile_post),
|
||||
create_sensmap(sensmap="{}_SensitivityMap_dl{}_en{:02d}{}".format(os.path.join(outfile_dir,outkey), detlike, eband[index], outfile_post),
|
||||
areatab="{}_AreaTable_dl{}_en{:02d}{}".format(os.path.join(outfile_dir,outkey), detlike, eband[index], outfile_post),
|
||||
expmap=outfile_expmap, backmap=outfile_backmap3,detlike=detlike,
|
||||
detmask=detmask, emin=emin_ev[index], emax=emax_ev[index],ecf=ecf[index])
|
||||
"""
|
||||
@@ -435,9 +452,9 @@ if(do_apetool==True):
|
||||
runme(cmd, local_run=local_run)
|
||||
|
||||
if(forced==True):
|
||||
catprep="{}_SourceCatalog_en{}.forced{}{}".format(os.path.join(outfile_dir,outkey), eband[index], comm, outfile_post)
|
||||
catprep="{}_SourceCatalog_en{:02d}.forced{}{}".format(os.path.join(outfile_dir,outkey), eband[index], comm, outfile_post)
|
||||
else:
|
||||
catprep="{}_SourceCatalog_en{}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
catprep="{}_SourceCatalog_en{:02d}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
|
||||
if(do_catprep==True):
|
||||
cmd=["catprep",
|
||||
|
Reference in New Issue
Block a user