#!/usr/bin/env python """Создает объедененный список событий и помещает его в uds/products Этот список событий нужен, в основном для извлечения спектров с помощью srctool """ 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 uds from uds.utils import * from uds.config import * """ find UDS root dir """ root_path=dirname(dirname(dirname(inspect.getfile(uds)))) print("UDS root path: {}".format(root_path)) infile_dir=root_path+'/data/processed' outfile_dir=root_path+'/products' create_folder(outfile_dir) do_init=True do_ermask=False eband_selected=[0] def runme(datakey): """ runs datakey over energy bands """ events=[] expmaps=[] for ii in range(len(eband_selected)): index=eband_selected[ii] print("\t>>> Energy band en{} -- {}-{} keV".format(eband[index],emin_kev[index],emax_kev[index])) 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=True, do_evtool=True, do_expmap=False, ra_cen=ra_cen, de_cen=de_cen, emin_kev=emin_kev[index], emax_kev=emax_kev[index]) events.append(outfile_evtool) expmaps.append(outfile_expmap) detmask="{}_DetectionMask{}".format(os.path.join(outfile_dir,datakey), outfile_post) if(do_ermask==True): cmd=["ermask", "expimage=%s" %(expmaps[0]), # use the first exposure maps calculated for that skyfield, independent of the energy band "detmask=%s" %(detmask), "threshold1=0.01", "threshold2=10.0", "regionfile_flag=no" ] remove_file(detmask) print((" ").join(cmd)) os.system((" ").join(cmd)) runme("tm7_obs_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) """