forked from erosita/uds
Many changes
This commit is contained in:
@@ -35,14 +35,14 @@ outfile_dir=root_path+'/products'
|
||||
|
||||
create_folder(outfile_dir)
|
||||
|
||||
index=5 # select energy band
|
||||
index=3 # select energy band
|
||||
|
||||
do_init = False
|
||||
do_init = True
|
||||
do_merge = True
|
||||
do_rate = False
|
||||
do_adapt = False # requires CIAO
|
||||
do_adapt = True # requires CIAO
|
||||
|
||||
vign=True
|
||||
vign=False
|
||||
vignetting = 'vign' if (vign==True) else 'novign'
|
||||
|
||||
events=[]
|
||||
@@ -61,8 +61,8 @@ for tmkey in keylist_tm.keys():
|
||||
do_init=do_init,
|
||||
do_obsmode=False,
|
||||
do_center=False,
|
||||
do_evtool=False,
|
||||
do_expmap=True,
|
||||
do_evtool=True,
|
||||
do_expmap=False,
|
||||
vign=vign,
|
||||
ra_cen=ra_cen, de_cen=de_cen,
|
||||
emin_kev=emin_kev[index],
|
||||
|
@@ -43,6 +43,8 @@ import sys, os, os.path, time, subprocess
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import glob
|
||||
from multiprocessing import Pool
|
||||
|
||||
from os.path import dirname
|
||||
import inspect
|
||||
import uds
|
||||
@@ -59,24 +61,29 @@ infile_dir=root_path+'/data/processed'
|
||||
outfile_dir=root_path+'/products'
|
||||
create_folder(outfile_dir)
|
||||
|
||||
do_init = True
|
||||
do_ermask = True
|
||||
run_Pool=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_init = False
|
||||
do_ermask = False
|
||||
|
||||
do_ermldet = True
|
||||
do_catprep = 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_ermldet = False
|
||||
do_catprep = False
|
||||
do_cross_match = False
|
||||
|
||||
do_wcs_match = True # Chandra task
|
||||
do_wcs_update = True # Chandra task
|
||||
do_astro_corr = False # search optimal shift
|
||||
do_astro_update = True
|
||||
|
||||
eband_selected=[0,1,2,3,4]
|
||||
do_wcs_match = False # Chandra task -- DEPRECATED
|
||||
do_wcs_update = False # Chandra task -- DEPRECATED
|
||||
|
||||
eband_selected=[5]
|
||||
|
||||
vign=True
|
||||
vignetting = 'vign' if (vign==True) else 'novign'
|
||||
@@ -95,6 +102,11 @@ def runme(datakey):
|
||||
cheesemask=[]
|
||||
bkgimage=[]
|
||||
srcmaps=[]
|
||||
|
||||
print(datakey)
|
||||
print('module name:', __name__)
|
||||
print('parent process:', os.getppid())
|
||||
print('process id:', os.getpid())
|
||||
|
||||
for ii in range(len(eband_selected)):
|
||||
index=eband_selected[ii]
|
||||
@@ -114,10 +126,10 @@ def runme(datakey):
|
||||
expmaps.append(outfile_expmap)
|
||||
events.append(outfile_evtool)
|
||||
|
||||
"""
|
||||
After astrometry-corrected files (*.attcorr.fits) are obtained, one can take them as original, in order to check the full chain:
|
||||
events.append(outfile_evtool.replace(".fits", ".attcorr.fits"))
|
||||
"""
|
||||
|
||||
# After astrometry-corrected files (*.attcorr.fits) are obtained, one can take them as original, in order to check the full chain:
|
||||
#events.append(outfile_evtool.replace(".fits", ".attcorr.fits"))
|
||||
|
||||
|
||||
""" Detmask """
|
||||
|
||||
@@ -339,12 +351,13 @@ def runme(datakey):
|
||||
]
|
||||
|
||||
if(do_ermldet==True):
|
||||
test_exe('ermldet')
|
||||
remove_file(mllist)
|
||||
remove_file(srcmap)
|
||||
|
||||
os.system((" ").join(cmd))
|
||||
print((" ").join(cmd))
|
||||
#save_ermldet_ds9reg(mllist,scale=60*60)
|
||||
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)
|
||||
@@ -359,12 +372,24 @@ def runme(datakey):
|
||||
|
||||
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")
|
||||
catalog=root_path+"/data/Gaia_unWISE/Gaia_unWISE_UDS.fits.catalog",errlim=5.0)
|
||||
|
||||
if(do_wcs_match==True and eband[index]==0):
|
||||
if(do_astro_corr==True and eband[index]=='0'):
|
||||
""" run astro_corr for 0.3-2.3 keV only """
|
||||
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)
|
||||
|
||||
|
||||
if(do_wcs_match==True and eband[index]=='0'):
|
||||
""" run wcs_match for 0.3-2.3 keV only """
|
||||
wcs_match_ciao(catprep, method='rst',radius=12,residlim=5)
|
||||
|
||||
wcs_match_ciao(catprep, method='trans',radius=12,residlim=5)
|
||||
#wcs_match_ciao(catprep, method='rst',radius=12,residlim=0,residtype=0,residfac=1)
|
||||
|
||||
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)
|
||||
@@ -372,13 +397,28 @@ def runme(datakey):
|
||||
|
||||
|
||||
"""
|
||||
testing
|
||||
# individual run, testing
|
||||
runme("tm7_obs_1")
|
||||
runme("tm5_obs_1")
|
||||
runme("tm6_scan_1")
|
||||
"""
|
||||
|
||||
for tmkey in keylist_tm.keys():
|
||||
print("TM{} in work... init events".format(tmkey))
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
print("--> {}".format(datakey))
|
||||
runme(datakey)
|
||||
|
||||
|
||||
if(run_Pool==True):
|
||||
# parallel run
|
||||
items=[]
|
||||
for tmkey in keylist_tm.keys():
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
items.append(datakey)
|
||||
|
||||
with Pool() as pool:
|
||||
pool.map(runme, items)
|
||||
|
||||
else:
|
||||
# conventional run
|
||||
for tmkey in keylist_tm.keys():
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
print("--> {}".format(datakey))
|
||||
runme(datakey)
|
||||
#sys.exit()
|
||||
|
@@ -13,7 +13,7 @@
|
||||
ВЫЗОВ:
|
||||
|
||||
esass
|
||||
./01_mosaics.py
|
||||
./04_mosaics.py
|
||||
|
||||
|
||||
УПРАВЛЕНИЕ:
|
||||
@@ -74,37 +74,39 @@ local_run = False
|
||||
|
||||
outkey="tm0"
|
||||
|
||||
do_init = False
|
||||
do_merge = False
|
||||
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_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_ersensmap = False
|
||||
do_ermldet = False
|
||||
do_ermldet = True
|
||||
do_fixcat = False # only for index=0
|
||||
do_fixxmm = True # only for index=0
|
||||
do_fixxmm = False # prepare forced photometry, only for index=0
|
||||
do_apetool = False
|
||||
do_catprep = False
|
||||
do_catprep = True
|
||||
do_filter_catalog = False
|
||||
|
||||
do_cross_match = False
|
||||
|
||||
index=0
|
||||
index=3
|
||||
|
||||
forced=False
|
||||
""" If forced=True, take input catalog from energy range en0 """
|
||||
|
||||
comm='-xmm' # for 4XMM-DR12 forced photometry use '-xmm'
|
||||
comm='' # for 4XMM-DR12 forced photometry use '-xmm'
|
||||
|
||||
|
||||
vign=True
|
||||
vignetting = 'vign' if (vign==True) else 'novign'
|
||||
|
||||
attcorr=True
|
||||
|
||||
events=[]
|
||||
expmaps=[]
|
||||
bkgmaps=[]
|
||||
@@ -113,7 +115,7 @@ for tmkey in keylist_tm.keys():
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
print("--> {}".format(datakey))
|
||||
""" Подготавливаем списки событий индивидуальных наблюдений """
|
||||
outfile_evtool,outfile_expmap=init_events(key=datakey,
|
||||
outfile_evtool,outfile_expmap=init_events(key=datakey,attcorr=attcorr,
|
||||
eband_index=eband[index],
|
||||
infile_dir=infile_dir,
|
||||
outfile_dir=outfile_dir,
|
||||
@@ -121,7 +123,7 @@ for tmkey in keylist_tm.keys():
|
||||
do_obsmode=False,
|
||||
do_center=False,
|
||||
do_evtool=True,
|
||||
do_expmap=True,
|
||||
do_expmap=False,
|
||||
vign=vign,
|
||||
ra_cen=ra_cen, de_cen=de_cen,
|
||||
emin_kev=emin_kev[index],
|
||||
@@ -138,7 +140,7 @@ if(do_merge==True):
|
||||
do_evtool_esass(events=events, outfile=outfile_evtool)
|
||||
|
||||
|
||||
""" makes detmask from TM exposures """
|
||||
""" makes detmask from TM exposures """
|
||||
detmask="{}/{}_DetectorMask_en{}{}".format(outfile_dir,
|
||||
outkey,
|
||||
eband[index],
|
||||
@@ -256,19 +258,20 @@ if(forced==True):
|
||||
srcmap="{}_SourceMap_en{}.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)
|
||||
if(index==0):
|
||||
boxlist3="{}_MaxLikSourceList_en{}.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()
|
||||
#boxlist3="{}_MaxLikSourceList_en{}.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)
|
||||
if not (os.path.exists(boxlist3)):
|
||||
print("{} not found. Run do_fixcat=True, index=0, forced=False".format(boxlist3))
|
||||
sys.exit()
|
||||
|
||||
add_specific_columns(boxlist3)
|
||||
fitpos_flag="fitpos_flag=no"
|
||||
fitext_flag="fitext_flag=no"
|
||||
nmulsou = "nmulsou=1"
|
||||
nmaxfit="nmaxfit=1"
|
||||
""" don't allow ermpldet to split sources """
|
||||
nmaxfit="nmaxfit=10"
|
||||
multrad="multrad=15."
|
||||
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)
|
||||
@@ -281,10 +284,12 @@ else:
|
||||
fitext_flag="fitext_flag=yes"
|
||||
nmulsou = "nmulsou=2"
|
||||
nmaxfit="nmaxfit=4"
|
||||
multrad="multrad=20."
|
||||
cutrad="cutrad=20."
|
||||
""" allow ermpldet to split sources (no more than two) """
|
||||
|
||||
cmd=["ermldet",
|
||||
"mllist=%s" %(mllist),
|
||||
"mllist={}".format(mllist),
|
||||
"boxlist=%s" %(boxlist3),
|
||||
"images=\'{}\'".format(outfile_evtool),
|
||||
"expimages=\'{}\'".format(outfile_expmap),
|
||||
@@ -297,8 +302,8 @@ cmd=["ermldet",
|
||||
"likemin=0.",
|
||||
"extlikemin=5.",
|
||||
"compress_flag=N",
|
||||
"cutrad=15.",
|
||||
"multrad=20.",
|
||||
cutrad,
|
||||
multrad,
|
||||
"extmin=2.0",
|
||||
"extmax=35.0",
|
||||
#"bkgima_flag=Y", looks outdated
|
||||
@@ -337,17 +342,22 @@ if(do_ersensmap==True):
|
||||
"""
|
||||
|
||||
if(do_ermldet==True):
|
||||
test_exe('ermldet')
|
||||
if(vign==False):
|
||||
print('Run ermldet with vignetted exposure!')
|
||||
sys.exit()
|
||||
remove_file(mllist)
|
||||
remove_file(srcmap)
|
||||
print(cmd)
|
||||
runme(cmd, local_run=local_run)
|
||||
|
||||
#correct_fluxerr_ermldet_forced(mllist)
|
||||
print(cmd)
|
||||
save_ermldet_ds9reg(mllist,scale=60*60,label='det_like')
|
||||
save_ermldet_ds9reg(mllist,scale=60*60,label='id_src')
|
||||
|
||||
correct_fluxerr_ermldet_forced(mllist)
|
||||
if(forced==True):
|
||||
result = check_ermldet_forced(mllist)
|
||||
""" for a some reason, for an arbitrary energy band, ermldet break order of sources. Do this forced correction. """
|
||||
# for a some reason, for an arbitrary energy band, ermldet break order of sources. Do this forced correction.
|
||||
if(result == False):
|
||||
correct_srcid_ermldet_forced(mllist)
|
||||
|
||||
@@ -359,32 +369,22 @@ if(do_fixcat==True):
|
||||
print("ERROR: You can fix only non-forced catalog for en0.")
|
||||
sys.exit()
|
||||
|
||||
srcs_remove=[174,
|
||||
90,
|
||||
299,
|
||||
300,
|
||||
504,
|
||||
215,
|
||||
401,
|
||||
20,] # keep 671 as unclassified extended source
|
||||
srcs_add = {'4XMM J021925.4-042647':[34.8559099,-4.4465007, 1.366], # 147
|
||||
'4XMM J021922.8-042655':[34.8451832,-4.4487901, 1.958], # 147
|
||||
'4XMM J021929.4-043224':[34.8728586,-4.5400022, 0.660], # 90
|
||||
'4XMM J021931.2-043222':[34.8801169,-4.5395495, 2.561], # 90
|
||||
'4XMM J021911.2-050550':[34.7968110,-5.0972990, 0.732], # 504
|
||||
'4XMM J021919.3-050511':[34.8307176,-5.0864242,4.988], # 504
|
||||
'4XMM J021911.5-050501':[34.7981099,-5.0837146,6.834], # 504
|
||||
'4XMM J021658.9-044900':[34.2455964,-4.8168126,4.449], # 300
|
||||
'4XMM J021659.2-044945':[34.2468704,-4.8291892,1.548], # 300
|
||||
'4XMM J021812.2-045814':[34.5510753,-4.9705972,0.550], # 215
|
||||
'4XMM J021812.0-045813':[34.5502698,-4.9703004,0.497], # 215
|
||||
'4XMM J021912.6-052756':[34.8028459,-5.4656239,0.579], # 401
|
||||
'4XMM J021705.5-042254':[34.2730294,-4.3816810,0.288], # 20
|
||||
'4XMM J021705.3-042314':[34.2720952,-4.3873162,0.587], # 20
|
||||
'4XMM J021827.2-045456':[34.6134256,-4.9157208,0.252],
|
||||
'4XMM J021831.3-045504':[34.6306930,-4.9178676,0.242],
|
||||
'4XMM J021925.4-045201':[34.8558373,-4.8671200,0.529],
|
||||
|
||||
srcs_remove=[341,446,346,96]
|
||||
srcs_add = {'4XMM J021738.8-051257':[34.4117002, -5.2159135, 0.624],# 341
|
||||
'4XMM J021733.8-051311':[34.3910215,-5.2199877,2.247],# 341
|
||||
'4XMM J021929.4-051220':[34.8725460,-5.2056849,1.074],#446
|
||||
'4XMM J021930.7-051225':[34.8782267,-5.2072112,0.624],# 446
|
||||
'4XMM J021945.2-045331':[34.9383593,-4.8919843,1.538],#346
|
||||
'4XMM J021929.4-043224':[34.8728586,-4.5400022,0.659555],#96
|
||||
#'4XMM J021929.4-043224':[34.8728586,-4.5400022, 0.660],
|
||||
#'4XMM J021831.8-050059':[34.6328841,-5.0163909,1.529],
|
||||
#'4XMM J022131.1-050027':[35.3797879,-5.0075498,0.941],
|
||||
#'4XMM J022129.5-045914':[35.3732136,-4.9874025,0.332],
|
||||
#'4XMM J022026.3-050251':[35.1098619,-5.0476199,0.551],
|
||||
#'4XMM J021925.4-042647':[34.8559099,-4.4465007,1.366],
|
||||
#'4XMM J021910.9-045108':[34.7954311,-4.8522901,0.898],
|
||||
#'4XMM J021945.2-045331':[34.9383593,-4.8919843,1.538],
|
||||
#'4XMM J021733.8-051311':[34.3910215,-5.2199877,2.247],
|
||||
}
|
||||
fix_catalog(mllist=mllist,refimage=outfile_evtool, srcs_remove=srcs_remove, srcs_add=srcs_add)
|
||||
"""
|
||||
@@ -451,7 +451,7 @@ if(do_filter_catalog==True):
|
||||
#filter_mllist(mllist,expcut=5000.0,dlcut=10.0,dlmin=10,dlmax=10000)
|
||||
""" works the same """
|
||||
filter_catprep(catprep,expcut=5000.0,dlmin=10,dlmax=10000,outkey='bright')
|
||||
filter_catprep(catprep,expcut=5000.0,dlmin=6,dlmax=10,outkey='faint')
|
||||
#filter_catprep(catprep,expcut=5000.0,dlmin=6,dlmax=10,outkey='faint')
|
||||
|
||||
if(do_cross_match==True):
|
||||
crossmatch_shu2019(catprep,dlmin=10,refimage=outfile_evtool,crval=[ra_cen, de_cen],
|
||||
|
@@ -73,20 +73,34 @@ outkey="tm0"
|
||||
|
||||
outfile_srctool="{}_SrcTool_".format(outkey)
|
||||
|
||||
do_init = False
|
||||
do_merge = False
|
||||
do_srctool = False
|
||||
do_grppha = False
|
||||
do_ecf_calc = False # for all bands
|
||||
do_ecf_print = False # for all bands
|
||||
do_catalog = False
|
||||
do_extended = False
|
||||
do_ds9reg = False
|
||||
do_xmm_catalog = False
|
||||
do_xmm_final = True
|
||||
do_init = False
|
||||
do_merge = False
|
||||
do_srctool = False
|
||||
do_grppha = False
|
||||
do_ecf_calc = False # for all bands
|
||||
do_ecf_print = False # for all bands
|
||||
do_flux_calc = False # for all bands
|
||||
|
||||
do_catalog = False
|
||||
do_extended = False
|
||||
do_ds9reg = False
|
||||
do_euds_final = False
|
||||
do_euds_dr12 = False # crossmatch eUDS with DR12
|
||||
do_euds_stat = False
|
||||
do_euds_cds = False
|
||||
|
||||
do_xmm_catalog = False
|
||||
do_xmm_final = False
|
||||
do_xmm_xmatch = False
|
||||
do_xmm_ds9reg = False
|
||||
do_xmm_cds = False
|
||||
do_euds_cosmatch = True
|
||||
|
||||
do_cross_check = False # Check whether all E3,E6 sources are detected in E0
|
||||
|
||||
|
||||
index=0
|
||||
""" работаем именно в этом диапазоне, чтобы спектры покрывали все энергии """
|
||||
""" чтобы спектры покрывали все энергии работаем в диапазоне 5 """
|
||||
|
||||
vign=True
|
||||
vignetting = 'vign' if (vign==True) else 'novign'
|
||||
@@ -99,7 +113,7 @@ for tmkey in keylist_tm.keys():
|
||||
for datakey in keylist_tm[tmkey]:
|
||||
print("--> {}".format(datakey))
|
||||
""" Подготавливаем списки событий индивидуальных наблюдений """
|
||||
outfile_evtool,outfile_expmap=init_events(key=datakey,
|
||||
outfile_evtool,outfile_expmap=init_events(key=datakey,attcorr=True,
|
||||
eband_index=eband[index],
|
||||
infile_dir=infile_dir,
|
||||
outfile_dir=outfile_dir,
|
||||
@@ -144,19 +158,21 @@ if(do_srctool==True):
|
||||
"eventfiles={}".format(outfile_evtool),
|
||||
"prefix=\'{}\'".format(os.path.join(srctool_dir,outfile_srctool)),
|
||||
"suffix=\'{}\'".format(suffix_srctool),
|
||||
"srccoord={}".format(catprep),
|
||||
"srccoord={}".format("../products/eUDS_for_srctool.fits"),
|
||||
# the same as original file eUDS.fits, but changed ML_CTS --> ML_CTS_0, ML_BKG --> ML_BKG_0, ML_EXP --> ML_EXP_0
|
||||
#"srcreg=\'fk5;circle * * 60s\'",
|
||||
#"backreg=\'fk5;annulus * * 90s 120s\'",
|
||||
"srcreg=AUTO",
|
||||
"backreg=AUTO",
|
||||
"clobber=yes",]
|
||||
os.system((" ").join(cmd))
|
||||
print((" ").join(cmd))
|
||||
#os.system((" ").join(cmd))
|
||||
#print((" ").join(cmd))
|
||||
|
||||
if(do_grppha==True):
|
||||
group_spectra("{}/*_SourceSpec_*.fits".format(srctool_dir))
|
||||
group_spectra("{}/*020_SourceSpec_*.fits".format(srctool_dir))
|
||||
|
||||
ecfout="{}_SampleFlux.pickle".format(os.path.join(outfile_dir,outkey))
|
||||
ecfout="{}_SampleFlux_v1.pickle".format(os.path.join(outfile_dir,outkey))
|
||||
|
||||
if(do_ecf_calc==True):
|
||||
calc_ecf("{}/tm0_SrcTool_020_ARF_?????.fits".format(srctool_dir),
|
||||
@@ -165,16 +181,27 @@ if(do_ecf_calc==True):
|
||||
if(do_ecf_print==True):
|
||||
print_ecf(infile=ecfout, emin=emin_kev, emax=emax_kev, eband=eband, skipfrac=10.0)
|
||||
|
||||
index=0
|
||||
fluxout="{}_SherpaFlux.pickle".format(os.path.join(outfile_dir,outkey))
|
||||
if(do_flux_calc==True):
|
||||
calc_flux("{}/tm0_SrcTool_020_ARF_?????.fits".format(srctool_dir),
|
||||
catprep=catprep, emin=emin_kev, emax=emax_kev, eband=eband, outfile=ecfout, simnum=100)
|
||||
|
||||
|
||||
|
||||
#index=0
|
||||
|
||||
catprep="{}_SourceCatalog_en{}{}".format(os.path.join(outfile_dir,outkey), eband[index], outfile_post)
|
||||
rawcat="{}_SourceCatalog_en{}.pickle".format(os.path.join(outfile_dir,outkey), eband[index])
|
||||
if(do_catalog==True):
|
||||
forced_xmm_sources="{}_MaxLikSourceList_en{}.xmm.pickle".format(os.path.join(outfile_dir,outkey), eband[index])
|
||||
with open(forced_xmm_sources, 'rb') as f:
|
||||
print("Reading forced XMM sources from {}".format(forced_xmm_sources))
|
||||
srcs_forced = pickle.load(f)
|
||||
print()
|
||||
print(srcs_forced)
|
||||
print()
|
||||
|
||||
make_catalog(infile='../products/tm0_SourceCatalog_en0.forced.fits', rawcat=rawcat, dlmin=10.0, dlmax=100000, ext_like=1000,
|
||||
make_euds_catalog(infile='../products/tm0_SourceCatalog_en0.forced.fits', rawcat=rawcat, dlmin=10.0, dlmax=100000, ext_like=1000,
|
||||
emin=emin_kev[index], emax=emax_kev[index], eband=eband[index],
|
||||
infile_en00cat=catprep,
|
||||
infile_en01cat='../products/tm0_SourceCatalog_en1.forced.fits',
|
||||
@@ -194,7 +221,27 @@ if(do_extended==True):
|
||||
make_extended(infile=rawcat,outreg="{}_ExtendedCat_en{}.reg".format(os.path.join(outfile_dir,outkey), eband[index]))
|
||||
|
||||
if(do_ds9reg==True):
|
||||
make_final_ds9reg(infile=rawcat,outreg="{}_FinalCat_dl10.reg".format(os.path.join(outfile_dir,outkey)))
|
||||
#make_final_ds9reg(infile=rawcat,outreg="{}_FinalCat_dl10.reg".format(os.path.join(outfile_dir,outkey)))
|
||||
make_final_ds9reg(infile=rawcat,scale=(60*60)/10,outreg="{}_FinalCat_dl10_talk.reg".format(os.path.join(outfile_dir,outkey)))
|
||||
|
||||
if(do_euds_final==True):
|
||||
""" make final eUDS catalog """
|
||||
final_euds_catalog(infile=rawcat, outfile_fits='../products/eUDS.fits')
|
||||
|
||||
if(do_euds_dr12==True):
|
||||
crossmatch_dr12('../products/eUDS.fits', catalog=root_path+"/data/4XMM-DR12/4XMM_DR12cat_slim_v1.0_UDS.fits.catalog", devmax=15)
|
||||
|
||||
|
||||
|
||||
if(do_euds_stat==True):
|
||||
make_euds_stat(infile="../products/eUDS.fits",fluxlim=5e-14)
|
||||
|
||||
if(do_euds_cds==True):
|
||||
make_euds_cds(infile="../products/eUDS.fits",outfile='../products/eUDS.cds')
|
||||
|
||||
if(do_cross_check==True):
|
||||
""" cross check final eUDS catalog """
|
||||
cross_check_euds(infile=catprep, euds='../products/eUDS.fits', outkey="../products/en{}_FinalCat_dl10".format(index))
|
||||
|
||||
if(do_xmm_catalog==True):
|
||||
""" complile raw forced XMM catalog """
|
||||
@@ -211,3 +258,27 @@ if(do_xmm_final==True):
|
||||
""" make final XMM-forced catalog """
|
||||
final_xmm_catalog(infile='../products/tm0_4XMM-DR12.pickle', outfile_fits='../products/eUDS_4XMM-DR12.fits')
|
||||
|
||||
if(do_xmm_xmatch==True):
|
||||
""" cross-match XMM-forced catalog
|
||||
outfile_cvs contains 0.3-2.3 keV eUDS flux (col1=flux,col2=err) vs. 4XMM-DR12 flux (col3=flux, col4=err)
|
||||
XMM flux was converted from 0.2-2.0 keV to 0.3-2.3 keV using wabs*powerlow with wabs=0.02 gamma=2.0
|
||||
"""
|
||||
final_xmm_xmatch(infile='../products/eUDS_4XMM-DR12.fits',
|
||||
xmmslim='../data/4XMM-DR12/4XMM_DR12cat_slim_v1.0_UDS.fits.catalog',
|
||||
xmmfull='../data/4XMM-DR12/4XMM_DR12cat_v1.0_UDS.fits.catalog',
|
||||
xmmlim=2e-14,
|
||||
outfile_flux="../products/eUDS_4XMM-DR12.flux.csv")
|
||||
|
||||
if(do_xmm_ds9reg==True):
|
||||
""" show XMM-forced catalog """
|
||||
make_xmm_ds9reg_confused(infile='../products/eUDS_4XMM-DR12.fits', outfile='../products/eUDS_4XMM-DR12.confused.reg')
|
||||
|
||||
""" obsolete """
|
||||
if(do_xmm_cds==True):
|
||||
make_xmm_cds(infile="../products/eUDS_4XMM-DR12.fits", outfile='../products/eUDS_4XMM-DR12.cds')
|
||||
|
||||
|
||||
|
||||
if(do_euds_cosmatch==True):
|
||||
""" prepare eUDS catalog for CosMatch (Mescheryakov) """
|
||||
make_euds_cosmatch(infile='../products/eUDS.fits', outfile='../products/eUDS-CosMatch.fits')
|
||||
|
@@ -45,10 +45,10 @@ import glob
|
||||
from os.path import dirname
|
||||
import inspect
|
||||
import uds
|
||||
|
||||
from scipy.stats import norm
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from uds.utils import *
|
||||
from uds.config import *
|
||||
@@ -76,7 +76,13 @@ outkey="tm0"
|
||||
outfile_srctool="{}_SrcTool_".format(outkey)
|
||||
|
||||
do_flux_distr = False
|
||||
do_sens_curve = True
|
||||
do_sens_curve = False
|
||||
do_4xmm_ratio = False
|
||||
do_euds_radec_err = False
|
||||
do_euds_dr12_diff = False
|
||||
do_euds_dr12_stat = True
|
||||
|
||||
do_print_ecf = False
|
||||
|
||||
index=0
|
||||
|
||||
@@ -87,8 +93,9 @@ if not (os.path.isfile(catalog)==True):
|
||||
sys.exit()
|
||||
|
||||
if(do_flux_distr==True):
|
||||
|
||||
|
||||
data, logbins = get_log_distr(infile=catalog, field='ml_rate', minval=1e-3, maxval=2)
|
||||
data, logbins, mean, median = get_log_distr(infile=catalog, field='ml_rate', minval=1e-3, maxval=2)
|
||||
fig, ax = plt.subplots()
|
||||
for axis in ['top','bottom','left','right']:
|
||||
ax.spines[axis].set_linewidth(1)
|
||||
@@ -101,9 +108,9 @@ if(do_flux_distr==True):
|
||||
plt.yscale('log')
|
||||
plt.savefig(catalog.replace("main.selected.csv", "ml_rate.png"), bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
data, logbins = get_log_distr(infile=catalog, field='ml_flux', minval=1e-15, maxval=2e-12)
|
||||
|
||||
data, logbins, mean, median = get_log_distr(infile=catalog, field='ml_flux', minval=1e-15, maxval=2e-12)
|
||||
fig, ax = plt.subplots()
|
||||
for axis in ['top','bottom','left','right']:
|
||||
ax.spines[axis].set_linewidth(1)
|
||||
@@ -143,11 +150,12 @@ if(do_sens_curve==True):
|
||||
ax.set_xlim([3e-16,1e-13])
|
||||
ax.set_ylim([0.3,160])
|
||||
|
||||
plt.plot(limflux_dl10,area_dl10, color="black", linestyle='solid',label="eUDS (DL10)")
|
||||
plt.plot(limflux_dl6,area_dl6, color="black", linestyle='dashed', label="eUDS (DL6)")
|
||||
|
||||
df = pandas.read_csv("../data/surveys/eFEDS.dat",header=None,names=['limflux','area'])
|
||||
plt.plot(df['limflux'],df['area'], color="brown", linestyle='solid',label="eFEDS (DL6)")
|
||||
|
||||
plt.plot(limflux_dl10,area_dl10, color="black", linestyle='solid',label="eUDS (DL10)")
|
||||
plt.plot(limflux_dl6,area_dl6, color="black", linestyle='dashed', label="eUDS (DL6)")
|
||||
|
||||
df = pandas.read_csv("../data/surveys/cosmos-legacy.dat",header=None,names=['limflux','area'])
|
||||
plt.plot(df['limflux'],df['area'], color="blue", linestyle='solid',label="COSMOS Legacy")
|
||||
@@ -187,3 +195,251 @@ if(do_sens_curve==True):
|
||||
Model Flux 0.00028334 photons (3.4012e-13 ergs/cm^2/s) range (0.30000 - 2.3000 keV)
|
||||
Model Flux 0.0001619 photons (2.4336e-13 ergs/cm^2/s) range (0.50000 - 2.0000 keV)
|
||||
"""
|
||||
if(do_4xmm_ratio==True):
|
||||
filename="../products/eUDS_4XMM-DR12.flux.csv"
|
||||
|
||||
data, logbins, mean, median = get_log_distr(infile=filename, field='ratio', minval=8e-2, maxval=60, nbin=60)
|
||||
print("Median {}".format(median))
|
||||
print(" Mean {}".format(mean))
|
||||
print("Ntotal {}".format(len(data)))
|
||||
fig, ax = plt.subplots()
|
||||
#plt.figure(figsize=(5,5))
|
||||
#plt.figure().set_figheight(3.6)
|
||||
#plt.rcParams['figure.figsize'] = [4, 4]
|
||||
for axis in ['top','bottom','left','right']:
|
||||
ax.spines[axis].set_linewidth(1)
|
||||
ax.tick_params(axis="both", width=1, labelsize=14)
|
||||
plt.hist(data, bins=logbins, histtype='step', color='blue', linewidth=1, linestyle='solid')
|
||||
plt.axvline(x = median, color = 'black', label = 'Median value', linestyle='dashed')
|
||||
plt.xlabel('Energy flux ratio',fontsize=14, fontweight='normal')
|
||||
plt.ylabel('Number',fontsize=14, fontweight='normal')
|
||||
plt.grid(visible=True)
|
||||
plt.xscale('log')
|
||||
plt.yscale('log')
|
||||
plt.savefig(filename.replace(".csv", ".distr.png"), bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
df = pandas.read_csv(filename)
|
||||
fig, ax = plt.subplots()
|
||||
#plt.rcParams['figure.figsize'] = [4, 4]
|
||||
#plt.figure(figsize=(5,5))
|
||||
#plt.figure().set_figheight(4)
|
||||
for axis in ['top','bottom','left','right']:
|
||||
ax.spines[axis].set_linewidth(1)
|
||||
ax.tick_params(axis="both", width=1, labelsize=14)
|
||||
plt.plot(np.array([1e-17,1e-11]), np.array([1e-17,1e-11]), linestyle = 'solid', color='black')
|
||||
plt.plot(np.array([1e-17,1e-11]), 10*np.array([1e-17,1e-11]), linestyle = 'dashed', color='black')
|
||||
plt.plot(np.array([1e-17,1e-11]), 0.1*np.array([1e-17,1e-11]), linestyle = 'dotted', color='black')
|
||||
#plt.plot(np.array([1e-17,1e-11]), median*np.array([1e-17,1e-11]), linestyle = 'dashed', color='blue')
|
||||
plt.errorbar(df['dr12_flux'],df['euds_flux'], yerr=df['euds_flux_err'], xerr=df['dr12_flux_err'], linestyle='None', color='black', label='Errors')
|
||||
plt.plot(df['dr12_flux'],df['euds_flux'], marker="o", linewidth=1, linestyle='None', markerfacecolor='Gold',markeredgecolor="black",)
|
||||
#plt.axvline(x = median, color = 'black', label = 'Median value', linestyle='dashed')
|
||||
plt.xlabel('4XMM-DR12 Energy flux (erg s$^{-1}$ cm$^{-2}$)',fontsize=14, fontweight='normal')
|
||||
plt.ylabel('eUDS Energy flux (erg s$^{-1}$ cm$^{-2}$)',fontsize=14, fontweight='normal')
|
||||
plt.grid(visible=True)
|
||||
plt.xlim(2e-16,1e-12)
|
||||
plt.ylim(1e-15,2e-12)
|
||||
plt.xscale('log')
|
||||
plt.yscale('log')
|
||||
plt.savefig(filename.replace(".csv", ".png"), bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
if(do_euds_radec_err==True):
|
||||
filename="../products/eUDS.fits"
|
||||
|
||||
ecat={}
|
||||
hdul = fits.open(filename)
|
||||
etab = hdul[1].data
|
||||
hdul.close()
|
||||
|
||||
x=[]
|
||||
y=[]
|
||||
for s in etab:
|
||||
if ("XMM" in s['DR12_IAU_NAME']):
|
||||
print("Skip ",s['DR12_IAU_NAME'])
|
||||
continue
|
||||
if (s['EXT_LIKE']>0.0):
|
||||
print("Skip extended ",s['ID_SRC'])
|
||||
continue
|
||||
x.append(s['DET_LIKE'])
|
||||
y.append(s['RADEC_ERR'])
|
||||
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
for axis in ['top','bottom','left','right']:
|
||||
ax.spines[axis].set_linewidth(1)
|
||||
ax.tick_params(axis="both", width=1, labelsize=14)
|
||||
ax.set_xlim([10,10000])
|
||||
ax.set_ylim([0.1,40])
|
||||
|
||||
plt.plot(x,y,".", color="gold", markersize=12, markeredgewidth=1.5, markeredgecolor="black")
|
||||
|
||||
plt.xlabel('DET_LIKE',fontsize=14, fontweight='normal')
|
||||
plt.ylabel('RADEC_ERR (arcsec)',fontsize=14, fontweight='normal')
|
||||
plt.grid(visible=True)
|
||||
plt.xscale('log')
|
||||
plt.yscale('log')
|
||||
png="../products/en0_radec_err.png"
|
||||
plt.savefig(png, bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
stat={}
|
||||
hdul = fits.open("../products/eUDS.dr12.cross.fits")
|
||||
tab = hdul[1].data
|
||||
hdul.close()
|
||||
|
||||
print(len(np.unique(tab['ID'])))
|
||||
for rec in tab:
|
||||
sid=rec['ID']
|
||||
if sid in stat.keys():
|
||||
stat[sid]=stat[sid]+1
|
||||
else:
|
||||
stat[sid]=1
|
||||
|
||||
unique=0
|
||||
double=0
|
||||
triple=0
|
||||
for key in stat.keys():
|
||||
if(stat[key]==1):
|
||||
unique=unique+1
|
||||
if(stat[key]==2):
|
||||
double=double+1
|
||||
if(stat[key]==3):
|
||||
triple=triple+1
|
||||
print("unique: {}, double: {}. triple: {}".format(unique, double, triple))
|
||||
|
||||
|
||||
if(do_euds_dr12_diff==True):
|
||||
# read forced first
|
||||
# fieldnames = ['euds_det_like', 'euds_flux', 'euds_flux_err', 'dr12_flux', 'dr12_flux_err', 'ratio']
|
||||
filename="../products/eUDS_4XMM-DR12.flux.csv"
|
||||
df = pandas.read_csv(filename)
|
||||
# calculate difference similar to Bruner
|
||||
|
||||
threshold=5e-14
|
||||
|
||||
# forced catalog contains CONF flag, take it to remove from histogram
|
||||
hdul = fits.open("../products/eUDS_4XMM-DR12.fits")
|
||||
forced = hdul[1].data
|
||||
fcat={}
|
||||
for rec in forced:
|
||||
key=rec['DR12_SRCID']
|
||||
fcat[key]={'conf':rec['CONF'],}
|
||||
|
||||
# read cross-match results (not forced)
|
||||
hdul = fits.open('../products/eUDS.dr12.cross.fits')
|
||||
tb = hdul[1].data
|
||||
cross_diff=[]
|
||||
cross_ratio=[]
|
||||
mean=0.0
|
||||
count=0
|
||||
for ind,s in enumerate(tb):
|
||||
key=rec['DR12_SRCID']
|
||||
#if not (tb[ind]['dr12_flux']>threshold and tb[ind]['src_flux']>threshold):
|
||||
if not (tb[ind]['dr12_flux']>threshold):
|
||||
continue
|
||||
ape_flux=(tb[ind]['ape_cts']-tb[ind]['ape_bkg'])/tb[ind]['ape_exp']/ecf[index]
|
||||
|
||||
cross_dr12_flux=(tb[ind]['dr12_flux'])
|
||||
cross_dr12_flux_error=(tb[ind]['dr12_flux_error'])
|
||||
cross_euds_flux=(tb[ind]['src_flux'])
|
||||
#cross_euds_flux=ape_flux
|
||||
cross_euds_flux_error=(tb[ind]['src_flux_error'])
|
||||
|
||||
print(cross_euds_flux,cross_euds_flux_error,tb[ind]['ape_cts'],tb[ind]['det_like'])
|
||||
|
||||
d=(cross_dr12_flux - cross_euds_flux) / np.sqrt(cross_dr12_flux_error**2 + cross_euds_flux_error**2)
|
||||
#if(d < -15):
|
||||
# continue
|
||||
r=cross_euds_flux/cross_dr12_flux
|
||||
cross_diff.append(d)
|
||||
cross_ratio.append(r)
|
||||
|
||||
#if(d < -15.0):
|
||||
#print("GGG",d,r,cross_euds_flux,cross_dr12_flux)
|
||||
#print(tb[ind]['DR12_NAME'],tb[ind]['DR12_RA'],tb[ind]['DR12_DEC'])
|
||||
mean=mean + (cross_euds_flux/cross_dr12_flux)
|
||||
count=count+1
|
||||
|
||||
|
||||
|
||||
print("min={:.2f}, max={:.2f}, mean={:.2f}, median={:.2f}, std={:.2f} N={}".format(min(cross_diff),
|
||||
max(cross_diff),
|
||||
np.mean(cross_diff),
|
||||
np.median(cross_diff),
|
||||
np.std(cross_diff),
|
||||
len(cross_diff)))
|
||||
print("ratio mean",mean/count)
|
||||
print("ratio median",np.median(cross_ratio))
|
||||
|
||||
|
||||
|
||||
nbin=50
|
||||
bins=np.linspace(-30,30, nbin)
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
for axis in ['top','bottom','left','right']:
|
||||
ax.spines[axis].set_linewidth(1)
|
||||
ax.tick_params(axis="both", width=1, labelsize=14)
|
||||
plt.hist(cross_diff, bins=bins,histtype='step', color='green', linewidth=1, linestyle='solid', density=True)
|
||||
|
||||
#x = np.arange(-10, 10, 0.001)
|
||||
#plot normal distribution with mean 0 and standard deviation 1
|
||||
#plt.plot(x, norm.pdf(x, 0, 1), color='red', linewidth=2)
|
||||
|
||||
plt.ylabel('Relative fraction',fontsize=14, fontweight='normal')
|
||||
plt.xlabel('(F$_{XMM}$-F$_{eUDS}$)/$\sqrt{\Delta F_{XMM}^{2}+\Delta F_{eUDS}^{2}}$',fontsize=14, fontweight='normal')
|
||||
plt.grid(visible=True)
|
||||
plt.xscale('linear')
|
||||
plt.yscale('linear')
|
||||
ax.set_xlim([-31, 31])
|
||||
ax.set_ylim([0, 0.2])
|
||||
plt.savefig("../products/cross-match_diff.png", bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
nbin=200
|
||||
bins=np.linspace(-1,1.0, nbin)
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
for axis in ['top','bottom','left','right']:
|
||||
ax.spines[axis].set_linewidth(1)
|
||||
ax.tick_params(axis="both", width=1, labelsize=14)
|
||||
plt.hist(cross_ratio, bins=bins, histtype='step', color='green', linewidth=1, linestyle='solid', density=False)
|
||||
|
||||
#x = np.arange(-10, 10, 0.001)
|
||||
#plot normal distribution with mean 0 and standard deviation 1
|
||||
#plt.plot(x, norm.pdf(x, 0, 1), color='red', linewidth=2)
|
||||
|
||||
plt.xlabel('eUDS and 4XMM-DR12 flux ratio',fontsize=14, fontweight='normal')
|
||||
plt.ylabel('Relative fraction',fontsize=14, fontweight='normal')
|
||||
plt.grid(visible=True)
|
||||
plt.xscale('linear')
|
||||
plt.yscale('linear')
|
||||
plt.savefig("../products/cross-match_ratio.png", bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
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
|
||||
|
||||
if(do_euds_dr12_stat==True):
|
||||
dr12_stat(infile='../products/eUDS_4XMM-DR12.fits',
|
||||
xmmslim='../data/4XMM-DR12/4XMM_DR12cat_slim_v1.0_UDS.fits.catalog',
|
||||
xmmlim=None,
|
||||
outfile_reg='../products/dr12_fluxlim.reg')
|
||||
|
55
scripts/print_radec_err.py
Normal file
55
scripts/print_radec_err.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import glob, sys
|
||||
from astropy.io import fits
|
||||
import statistics
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import csv
|
||||
colnames=['Match', 'Ref', 'Dup', 'RA', 'Dec', 'Incl']
|
||||
|
||||
flist=glob.glob('../products/tm[1,5,6,7]*en0*src.fits')
|
||||
total1=0
|
||||
total2=0
|
||||
|
||||
for f in flist:
|
||||
|
||||
hdul = fits.open(f)
|
||||
try:
|
||||
table=hdul[1].data['RADEC_ERR']
|
||||
except:
|
||||
continue
|
||||
hdul.close()
|
||||
|
||||
dref=f.replace("src.fits","ref.fits")
|
||||
hdul = fits.open(dref)
|
||||
try:
|
||||
rtable=hdul[1].data['RA']
|
||||
except:
|
||||
continue
|
||||
hdul.close()
|
||||
|
||||
err=[]
|
||||
err10=[]
|
||||
dfile=f.replace("shu2019.src.fits","xfm.log.dat.awk")
|
||||
with open(dfile) as csvfile:
|
||||
spamreader = csv.reader(csvfile, delimiter=' ')
|
||||
total=0
|
||||
for row in spamreader:
|
||||
if(row[5] == 'N'):
|
||||
continue
|
||||
for ii,values in np.ndenumerate(rtable):
|
||||
if(int(row[2]) == int(ii[0])):
|
||||
total=total+1
|
||||
#print(">>",row[5],rtable[ii],table[ii],ii[0])
|
||||
if(table[ii]>0.0):
|
||||
err.append(table[ii])
|
||||
if(table[ii]>10.0):
|
||||
err10.append(table[ii])
|
||||
|
||||
total1=total1+total
|
||||
total2=total2+len(err)
|
||||
#print("{} MIN {:.2f} MAX {:.2f} ({}/{})".format(f[12:15],min(err),max(err),len(err10),len(err)))
|
||||
print("{} MIN {:.2f} MAX {:.2f} ({}/{})".format(f,min(err),max(err),len(err10),len(err)))
|
||||
#sys.exit()
|
||||
|
||||
|
||||
#print(total1,total2)
|
67
scripts/print_transform.py
Normal file
67
scripts/print_transform.py
Normal file
@@ -0,0 +1,67 @@
|
||||
import glob, sys
|
||||
from astropy.io import fits
|
||||
import statistics
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import csv
|
||||
from uds.config import *
|
||||
|
||||
colnames=['Match', 'Ref', 'Dup', 'RA', 'Dec', 'Incl']
|
||||
|
||||
flist=glob.glob('../products/tm[1,5,6,7]*en0*.xfm')
|
||||
total1=0
|
||||
total2=0
|
||||
|
||||
for f in flist:
|
||||
|
||||
pos = f.find("_SourceCatalog")
|
||||
key=f[12:pos]
|
||||
|
||||
hdul = fits.open(f)
|
||||
try:
|
||||
tab=hdul[1].data
|
||||
except:
|
||||
continue
|
||||
hdul.close()
|
||||
|
||||
dsrc=f.replace(".xfm",".shu2019.src.fits")
|
||||
hdul = fits.open(dsrc)
|
||||
try:
|
||||
hdr=hdul[0].header
|
||||
cdelt=hdr['CDELT2']*3600
|
||||
except:
|
||||
continue
|
||||
hdul.close()
|
||||
|
||||
a11=tab[0]['a11']
|
||||
a12=tab[0]['a12']
|
||||
a22=tab[0]['a22']
|
||||
a21=tab[0]['a21']
|
||||
x_scale=tab[0]['x_scale']
|
||||
y_scale=tab[0]['y_scale']
|
||||
|
||||
t1=tab[0]['t1']*cdelt
|
||||
t2=tab[0]['t2']*cdelt
|
||||
|
||||
sx1=np.sign(a11)*np.sqrt(a11**2 + a12**2)
|
||||
sy1=np.sign(a22)*np.sqrt(a21**2 + a22**2)
|
||||
|
||||
sx2=np.sign(a11)*np.sqrt(a11**2 + a21**2)
|
||||
sy2=np.sign(a22)*np.sqrt(a12**2 + a22**2)
|
||||
|
||||
a1 = np.arctan2(a12/sx1,a11/sy2) * 180 / np.pi * 60
|
||||
a2 = np.arctan2(a12/sx1,a22/sy2) * 180 / np.pi * 60
|
||||
|
||||
b1 = np.arctan2(a21,a11) * 180 / np.pi * 60
|
||||
b2 = np.arctan2(a21,a22) * 180 / np.pi * 60
|
||||
|
||||
det=a11*a22-a12*a21
|
||||
|
||||
alpha=355*np.pi/180
|
||||
a3 = np.arctan2(np.sin(alpha),np.cos(alpha)) * 180 / np.pi
|
||||
|
||||
print("{:+.8} {:+.8}".format(a11,a12))
|
||||
print("{:+.8} {:+.8}".format(a21,a22))
|
||||
|
||||
#print("{} d {:.10f} s {:.8f} {:.8f} {:.8f} {:.8f} | {:+.8f} {:+.8f} {:+.8f} {:+.8f} t {:+.2f} {:+.2f}".format(obslist[key],np.sqrt(det)*cdelt,sx1*cdelt,sx2*cdelt,sy1*cdelt,sy2*cdelt,a1,a2,b1,b2,t1,t2))
|
||||
#print("{} d {:.10f} s {:.8f} {:.8f} {:.8f} {:.8f} | {:+.8f} {:+.8f} {:+.8f} {:+.8f} t {:+.2f} {:+.2f}".format(obslist[key],np.sqrt(det)*cdelt,sx1*cdelt,sx2*cdelt,sy1*cdelt,sy2*cdelt,a1,a2,b1,b2,t1,t2))
|
Reference in New Issue
Block a user