From 632117266ccaac36b84fe699d8e40cc5bc69334d Mon Sep 17 00:00:00 2001 From: ODA bot Date: Wed, 17 Jan 2024 15:14:53 +0000 Subject: [PATCH] update tool HESS --- tools/hess/Image.py | 252 +++++++++++++++++++++++++++++ tools/hess/Lightcurve.py | 280 +++++++++++++++++++++++++++++++++ tools/hess/Spectrum.py | 257 ++++++++++++++++++++++++++++++ tools/hess/hess_astro_tool.xml | 138 ++++++++++++++++ 4 files changed, 927 insertions(+) create mode 100644 tools/hess/Image.py create mode 100644 tools/hess/Lightcurve.py create mode 100644 tools/hess/Spectrum.py create mode 100644 tools/hess/hess_astro_tool.xml diff --git a/tools/hess/Image.py b/tools/hess/Image.py new file mode 100644 index 00000000..ac108f0b --- /dev/null +++ b/tools/hess/Image.py @@ -0,0 +1,252 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[ ]: + + +import json +import os +import shutil +import sys + +try: + import numpy as np + _numpy_available = True +except ImportError: + _numpy_available = False + +try: + from oda_api.json import CustomJSONEncoder +except ImportError: + from json import JSONEncoder as CustomJSONEncoder + +_galaxy_wd = os.getcwd() + + +# In[1]: + + +import astropy.units as u +from astropy.coordinates import SkyCoord + +import matplotlib.pyplot as plt +from gammapy.data import DataStore +from gammapy.makers import MapDatasetMaker +from gammapy.makers.utils import make_theta_squared_table +from gammapy.maps import Map, MapAxis, WcsGeom +from astropy.io import fits +import numpy as np +from numpy import pi,cos,sin,sqrt +import os +from astropy import wcs +from astropy.io import fits +from oda_api.data_products import PictureProduct +from oda_api.data_products import ImageDataProduct +from astropy.time import Time + + +# In[2]: + + +if(os.path.exists('hess_dl3_dr1.tar.gz')==False): + get_ipython().system('wget https://zenodo.org/record/1421099/files/hess_dl3_dr1.tar.gz') + get_ipython().system('tar -zxvf hess_dl3_dr1.tar.gz') + + +# In[3]: + + +src_name='Crab' #http://odahub.io/ontology#AstrophysicalObject +RA=83.628700 # http://odahub.io/ontology#PointOfInterestRA +DEC = 22.014700 # http://odahub.io/ontology#PointOfInterestDEC +T1='2000-10-09T13:16:00.0'# http://odahub.io/ontology#StartTime +T2='2022-10-10T13:16:00.0' # http://odahub.io/ontology#EndTime +Radius=2.5 #http://odahub.io/ontology#AngleDegrees +pixsize=0.1 #http://odahub.io/ontology#AngleDegrees +Emin=100. #http://odahub.io/ontology#Energy_GeV +Emax=10000. #http://odahub.io/ontology#Energy_GeV + + +# In[ ]: + + +with open('inputs.json', 'r') as fd: + inp_dic = json.load(fd) +if '_data_product' in inp_dic.keys(): + inp_pdic = inp_dic['_data_product'] +else: + inp_pdic = inp_dic + +for vn, vv in inp_pdic.items(): + if vn != '_selector': + globals()[vn] = type(globals()[vn])(vv) + + +# In[4]: + + +T1=Time(T1, format='isot', scale='utc').mjd +T2=Time(T2, format='isot', scale='utc').mjd +message='' +RA_pnts=[] +DEC_pnts=[] +DL3_files=[] +OBSIDs=[] +Tstart=[] +Tstop=[] +flist=os.listdir('data') +for f in flist: + if(f[-7:]=='fits.gz'): + DL3_files.append(f) + OBSIDs.append(int(f[20:26])) + hdul=fits.open('data/'+f) + RA_pnts.append(float(hdul[1].header['RA_PNT'])) + DEC_pnts.append(float(hdul[1].header['DEC_PNT'])) + Tstart.append(Time(hdul[1].header['DATE-OBS']+'T'+hdul[1].header['TIME-OBS'], format='isot', scale='utc').mjd) + Tstop.append(Time(hdul[1].header['DATE-END']+'T'+hdul[1].header['TIME-END'], format='isot', scale='utc').mjd) + hdul.close() + + +# In[5]: + + +Coords_s=SkyCoord(RA,DEC,unit='degree') +COORDS_pnts=SkyCoord(RA_pnts,DEC_pnts,unit='degree') +seps=COORDS_pnts.separation(Coords_s).deg + + +# In[6]: + + +mask=np.where((sepsT1) & (TstopT1) & (TstopT1) & (Tstop + + ipython + astropy + gammapy + matplotlib + astroquery + scipy + oda-api + + nbconvert + wget + + ipython '$__tool_directory__/${_data_product._selector}.py' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _data_product['_selector'] == 'Image' + + + _data_product['_selector'] == 'Image' + + + _data_product['_selector'] == 'Spectrum' + + + _data_product['_selector'] == 'Spectrum' + + + _data_product['_selector'] == 'Lightcurve' + + + _data_product['_selector'] == 'Lightcurve' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file