1
0
forked from erosita/uds
This commit is contained in:
Roman Krivonos 2024-11-14 11:28:13 +03:00
parent 13046181ea
commit b276a4e533
4 changed files with 56 additions and 31 deletions

View File

@ -5,20 +5,20 @@
Координаты сентрального кадра, к которому будут
приводиться изображения всех списков событий
"""
ra_cen=194.953
de_cen=27.981
ra_cen=194.9601418
de_cen=27.6857267
"""
Словарь камер со списком наблюдений каждой камеры.
Номера камер должны быть отсортированы
"""
keylist_tm={'1':['tm1_partI',],
'2':['tm2_partI',],
'3':['tm3_partI',],
'4':['tm4_partI',],
'5':['tm5_partI',],
'6':['tm6_partI',],
'7':['tm7_partI',],}
keylist_tm={'1':['tm1_scan1','tm1_scan2','tm1_scan3','tm1_scan4','tm1_scan5','tm1_scan6','tm1_scan7','tm1_survey'],
'2':['tm2_scan1','tm2_scan2','tm2_scan3','tm2_scan4','tm2_scan5','tm2_scan6','tm2_scan7','tm2_survey'],
'3':['tm3_scan1','tm3_scan2','tm3_scan3','tm3_scan4','tm3_scan5','tm3_scan6','tm3_scan7','tm3_survey'],
'4':['tm4_scan1','tm4_scan2','tm4_scan3','tm4_scan4','tm4_scan5','tm4_scan6','tm4_scan7','tm4_survey'],
'5':['tm5_scan1','tm5_scan2','tm5_scan3','tm5_scan4','tm5_scan5','tm5_scan6','tm5_scan7','tm5_survey'],
'6':['tm6_scan1','tm6_scan2','tm6_scan3','tm6_scan4','tm6_scan5','tm6_scan6','tm6_scan7','tm6_survey'],
'7':['tm7_scan1','tm7_scan2','tm7_scan3','tm7_scan4','tm7_scan5','tm7_scan6','tm7_scan7','tm7_survey'],}
"""
Примерные центры изображений каждого наблюдения.

View File

@ -95,7 +95,7 @@ def convert_dr12_to_erosita_flux(rec, field_prefix='SC_'):
def do_evtool_esass(evfile=None,events=None,outfile=None,evlist=None,
gti=None,region=None,emin=None,emax=None, rmlock=False,
do_center=False, ra_cen=None, de_cen=None):
do_center=False, width=1024, ra_cen=None, de_cen=None):
eventfiles=None
if(events):
@ -130,10 +130,11 @@ def do_evtool_esass(evfile=None,events=None,outfile=None,evlist=None,
cmd=["evtool",
eventfiles,
gti,region,emin,emax,
"outfile={}".format(outfile),
"image=yes",
"flag=0x2000",
"pattern=15"
"outfile={}".format(outfile),
"image=yes",
"size='{}'".format(width),
"flag=0x2000",
"pattern=15"
]
print((" ").join(cmd))
@ -211,7 +212,7 @@ def do_badpix_tm6(filename):
f.close()
def init_events(key=None, eband_selected=[0], eband_index=None,
ra_cen=None, de_cen=None,do_init=True,vign=True,
ra_cen=None, de_cen=None, width=1024, do_init=True,vign=True,
emin_kev=None, emax_kev=None, infile_dir=None, outfile_dir=None,
do_obsmode=False,do_center=False,do_evtool=False,do_expmap=False,attcorr=False):
expmaps=[]
@ -287,6 +288,7 @@ def init_events(key=None, eband_selected=[0], eband_index=None,
"emax=%f" %(emax_kev),
#"region=%s" %(region),
"image=yes",
"size='{}'".format(width),
"flag=0x2000",
"pattern=15"
]

View File

@ -21,7 +21,10 @@ el=root_path+'/data/evtlists/'
pr=root_path+'/data/processed/'
create_folder(pr)
region="box({},{},8d,8d,0)".format(ra_cen,de_cen) # Selection region
region="box({},{},12d,12d,0)".format(ra_cen,de_cen) # Selection region
for m in [1,2,3,4,5,6,7]:
print("tm{}_".format(m))
@ -57,9 +60,11 @@ for i in range(len(partII)-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)
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, region=region, rmlock=True)
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)
"""

View File

@ -28,48 +28,54 @@ ftools does not like long file path names, for this reason, we use relative path
root_path='..'
print("UDS root path: {}".format(root_path))
print("Coma root path: {}".format(root_path))
infile_dir=root_path+'/data/processed'
outfile_dir=root_path+'/products'
create_folder(outfile_dir)
index=5 # select energy band
do_init = True
do_merge = False
do_init = False
do_merge = True
do_rate = False
do_adapt = False # requires CIAO
vign=False
index=5 # select energy band
width=7000
vign=True
vignetting = 'vign' if (vign==True) else 'novign'
#print(ra_cen, de_cen)
#sys.exit()
events=[]
expmaps=[]
bkgmaps=[]
for tmkey in keylist_tm.keys():
print("TM{} in work... init events".format(tmkey))
for datakey in keylist_tm[tmkey]:
#if not ("scan" in datakey):
# continue
if ("survey" in datakey):
continue
print("--> {}".format(datakey))
""" Подготавливаем списки событий индивидуальных наблюдений """
outfile_evtool,outfile_expmap=init_events(key=datakey, 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, # also controlled by lock file!
do_center=True, # also controlled by lock file!
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])
events.append(outfile_evtool)
expmaps.append(outfile_expmap)
bkgmaps.append("{}_BackMap3_en{}.fits".format(os.path.join(outfile_dir,datakey), eband[0]))
""" Собираем общий список событий """
outfile_evtool="{}_EventList_en{}.fits".format(os.path.join(outfile_dir,outkey), eband[index])
@ -78,9 +84,21 @@ outfile_expmap="{}_ExposureMap_en{}.{}.fits".format(os.path.join(outfile_dir,out
outfile_bkgmap="{}_BackMap_en{}.{}.fits".format(os.path.join(outfile_dir,outkey), eband[index], vignetting)
if(do_merge==True):
do_evtool_esass(events=events, outfile=outfile_evtool)
do_fimgmerge_ftools(maps=expmaps, outfile=outfile_expmap)
do_fimgmerge_ftools(maps=bkgmaps, outfile=outfile_bkgmap)
evlist="{}.evlist.txt".format(os.getpid())
f = open(evlist, "w")
for s in events:
f.write("{}\n".format(s))
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=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)
if(do_rate==True):