2
0
forked from xmm/arches
This commit is contained in:
2026-01-28 13:53:52 +03:00
parent 777c92ef2e
commit 9bedea505c
19 changed files with 316 additions and 123 deletions

View File

@@ -1,6 +1,26 @@
from pathlib import Path
good=['0862470801','0862470701','0862470601']
# Arches 2020, Maica Clavel:
# good=['0862470801','0862470701','0862470601']
# after 2020: MOS1 is OFF, PN at border
good=[
#'0862470801', # 2020 Maica Clavel
#'0862470701', # 2020 Maica Clavel
#'0862470601', # 2020 Maica Clavel
'0860620401', # 2021-03-30 M1 off, M2 OK
'0860620201', # 2021-03-28 M1 off, M2 OK, PN border
'0860620301', # 2021-03-29 M1 off, M2 good, PN border
'0893811101', # 2022-03-18 M1 off, M2 OK, PN border Transient nearby
'0893811301', # 2022-03-26 M1 off, M2 OK, PN border, transient nearby
'0944580501', # 2024-03-29 M1 off, M2 good, PN border, note: "U" exposure
'0944580801', # 2024-03-28 M1 off, M2 OK
##'0944580701', low exposure
##'0860620501', # 2021-03-31 M1 off, M2 OK
##'0932392301', # 2024-04-03 M1 off, M2 Bad, no exposure
##'0944580601', # 2024-03-26 M1 off, M2 OK, but low exposure, PN border
]
""" The angular size of an XMM DETXY physical coordinate system is 0.05 arcseconds """
det_pix_as=0.05
@@ -26,11 +46,12 @@ skip=['0862471401','0862471501','0862470501']
# energy bands taken from Tatischeff 2012
emin=[
'2000', # continuum, 2-4 keV
'4170', # continuum, 4.17-5.86 keV (T12)
'6300', # 6.4 keV line, 6.3-6.48 keV (T12)
'6564', # 6.7 keV line, 6.564-6.753 keV (T12)
'8000', # high-energy continuum, 8-12 keV
'2000', # [0] continuum, 2-4 keV
'4170', # [1] continuum, 4.17-5.86 keV (T12)
'6300', # [2] 6.4 keV line, 6.3-6.48 keV (T12)
'6564', # [3] 6.7 keV line, 6.564-6.753 keV (T12)
'8000', # [4] high-energy continuum, 8-12 keV
'8000', # [5] high-energy continuum, 8-10 keV
]
emax=[
'4000',
@@ -38,4 +59,17 @@ emax=[
'6480',
'6753',
'12000',
'10000',
]
"""
nh=9.5, Gamma=3
Model Flux 1.5475e-05 photons (1.2204e-13 ergs/cm^2/s) range (4.1700 - 5.8600 keV)
Model Flux 9.3046e-07 photons (9.5245e-15 ergs/cm^2/s) range (6.3000 - 6.4800 keV)
0.0601267
Model Flux 8.7952e-07 photons (9.3813e-15 ergs/cm^2/s) range (6.5640 - 6.7530 keV)
0.0568349
Model Flux 6.195e-06 photons (9.5642e-14 ergs/cm^2/s) range (8.0000 - 12.000 keV)
0.400323
"""

View File

@@ -65,20 +65,30 @@ def remove_file(filename):
def move_files(pattern, destination):
for file in glob.glob(pattern):
shutil.move(file, os.path.join(destination,file))
def test_file(fn):
def test_file(fn, alive=False):
if not (os.path.isfile(fn)==True):
print(f'requested filename {fn} is not found')
cwd = os.getcwd()
print(f"Current directory: {cwd}")
sys.exit()
if(alive):
return False
else:
print("### Abort ###")
sys.exit()
return True
def get_first_file(pattern):
def get_first_file(pattern, alive=False):
files = glob.glob(pattern)
if not (files):
print(f"Files not found from pattern {pattern}")
sys.exit()
filename = files[0]
return filename
if(alive):
return None
else:
print("### Abort ###")
sys.exit()
return files[0]
# Function to plot Lightcurve
@@ -628,12 +638,12 @@ def run_evqpb(key, work_dir=None, evtfile=None, attfile=None, pimin=[200,], pima
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
"""
def run_mosaic(outfile_cts=None,outfile_qpb=None,outfile_exp=None,
outfile_sub=None,outfile_flx=None,outfile_pix=None,
cts=None,qpb=None,exp=None,nn=3,devmax=5.0,cutbox=100):
def run_mosaic(out_cts=None,out_qpb=None,out_exp=None,
out_sub=None,out_flx=None,out_pix=None,
cts=None,qpb=None,exp=None,nn=2,devmax=5.0,cutbox=100,fracexp=0.25):
ref_crd = SkyCoord(arches_ra, arches_dec, frame=FK5(), unit="deg")
nn2=nn*nn
print(outfile_cts)
print(out_cts)
print(cts[0])
print(exp[0])
# take first image as reference
@@ -684,19 +694,19 @@ def run_mosaic(outfile_cts=None,outfile_qpb=None,outfile_exp=None,
map_cts[col_index][row_index]=2.0
ref_hdul[0].data=map_cts
ref_hdul.writeto(outfile_cts,overwrite=True)
ref_hdul.writeto(out_cts,overwrite=True)
sys.exit()
"""
for idx,in_cts in enumerate(cts):
#if not (idx==2):
# continue
hdul0 = fits.open(in_cts)
c_data = hdul0[0].data
c_header = hdul0[0].header
c_wcs = WCS(c_header)
hdul0.close()
print(f"{in_cts} filter {c_header['FILTER']}")
hdul0 = fits.open(qpb[idx])
@@ -710,7 +720,9 @@ def run_mosaic(outfile_cts=None,outfile_qpb=None,outfile_exp=None,
e_header = hdul0[0].header
e_wcs = WCS(e_header)
hdul0.close()
print(exp[idx])
cutexp=np.max(e_data)*fracexp
print(f'{exp[idx]}, fracexp: {fracexp} cutexp: {cutexp:.1f} sec')
xx, yy = c_wcs.world_to_pixel(ref_crd)
@@ -740,7 +752,7 @@ def run_mosaic(outfile_cts=None,outfile_qpb=None,outfile_exp=None,
exp_xx, exp_yy = e_wcs.world_to_pixel(c_sky)
exp_x = int(np.rint(np.float64(exp_xx)))
exp_y = int(np.rint(np.float64(exp_yy)))
if not (e_data[exp_y, exp_x]>0):
if not (e_data[exp_y, exp_x]>cutexp):
continue
sep_arcmin = c_sky.separation(ref_crd).arcmin
@@ -775,39 +787,37 @@ def run_mosaic(outfile_cts=None,outfile_qpb=None,outfile_exp=None,
# Convert summed sky back to normal units
for x in range(nx):
for y in range(ny):
if(map_exp[y][x]>0):
map_flx[y][x]=(map_cts[y][x]-map_qpb[y][x])/map_exp[y][x]
map_cts[y][x]=map_cts[world_to_pixely][x]/map_pix[y][x]
map_qpb[y][x]=map_qpb[y][x]/map_pix[y][x]
map_exp[y][x]=map_exp[y][x]/map_pix[y][x]
else:
map_flx[y][x]=0.0
if(outfile_pix):
index = map_exp > 0
map_flx[index]=(map_cts[index]-map_qpb[index])/map_exp[index]
#map_cts[index]=map_cts[index]/map_pix[index]
#map_qpb[index]=map_qpb[index]/map_pix[index]
#map_exp[index]=map_exp[index]/map_pix[index]
if(out_pix):
ref_hdul[0].data=map_pix
ref_hdul.writeto(outfile_pix,overwrite=True)
ref_hdul.writeto(out_pix,overwrite=True)
ref_hdul[0].data=map_cts
ref_hdul.writeto(outfile_cts,overwrite=True)
ref_hdul.writeto(out_cts,overwrite=True)
ref_hdul[0].data=map_exp
ref_hdul.writeto(outfile_exp,overwrite=True)
ref_hdul.writeto(out_exp,overwrite=True)
ref_hdul[0].data=map_qpb
ref_hdul.writeto(outfile_qpb,overwrite=True)
ref_hdul.writeto(out_qpb,overwrite=True)
ref_hdul[0].data=map_flx
ref_hdul.writeto(outfile_flx,overwrite=True)
ref_hdul.writeto(out_flx,overwrite=True)
#sys.exit()
"""
cmd = ['farith', f'{outfile_cts}', f'{outfile_qpb}', f'{outfile_sub}', 'SUB',
cmd = ['farith', f'{out_cts}', f'{out_qpb}', f'{out_sub}', 'SUB',
'copyprime=yes', 'clobber=yes']
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
cmd = ['farith', f'{outfile_sub}', f'{outfile_exp}', f'{outfile_rat}', 'DIV',
cmd = ['farith', f'{out_sub}', f'{out_exp}', f'{out_rat}', 'DIV',
'copyprime=yes', 'clobber=yes']
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
"""