Mercurial > repos > astroteam > cta_astro_tool
annotate pre-defined_model.py @ 0:2f3e314c3dfa draft default tip
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
| author | astroteam | 
|---|---|
| date | Fri, 19 Apr 2024 10:06:21 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 1 #!/usr/bin/env python | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 2 # coding: utf-8 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 3 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 4 # flake8: noqa | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 5 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 6 import json | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 7 import os | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 8 import shutil | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 9 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 10 from oda_api.json import CustomJSONEncoder | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 11 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 12 get_ipython().run_cell_magic( # noqa: F821 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 13 "bash", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 14 "", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 15 'wget https://gitlab.renkulab.io/astronomy/mmoda/cta/-/raw/master/Franceschini17.txt\n\nrm -r IRFS | echo "Ok"\nmkdir IRFS\ncd IRFS\nwget https://zenodo.org/records/5499840/files/cta-prod5-zenodo-fitsonly-v0.1.zip\nunzip cta-prod5-zenodo-fitsonly-v0.1.zip\ncd fits\nfor fn in *.gz ; do tar -zxvf $fn; done \n \n', | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 16 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 17 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 18 import astropy.units as u | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 19 import matplotlib.pyplot as plt | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 20 import numpy as np | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 21 from astropy import wcs | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 22 from astropy.coordinates import SkyCoord | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 23 from astropy.io import fits | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 24 from gammapy.data import Observation | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 25 from gammapy.datasets import MapDataset, MapDatasetEventSampler | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 26 from gammapy.irf import load_irf_dict_from_file | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 27 from gammapy.makers import MapDatasetMaker | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 28 from gammapy.maps import MapAxis, WcsGeom | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 29 from gammapy.modeling.models import FoVBackgroundModel, Models | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 30 from numpy import cos, exp, pi, sqrt | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 31 from oda_api.api import ProgressReporter | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 32 from oda_api.data_products import BinaryProduct, PictureProduct | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 33 from regions import CircleSkyRegion | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 34 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 35 # from gammapy.irf import load_cta_irfs | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 36 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 37 RA = 166.113809 # http://odahub.io/ontology#PointOfInterestRA | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 38 DEC = 38.208833 # http://odahub.io/ontology#PointOfInterestDEC | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 39 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 40 OffAxis_angle = 0.78 # http://odahub.io/ontology#AngleDegrees | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 41 # Exposure time in hours | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 42 Texp = 1.0 # http://odahub.io/ontology#TimeIntervalHours | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 43 # Source redshift | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 44 z = 0.03 # http://odahub.io/ontology#Float | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 45 # Source flux normalisaiton F0 in 1/(TeV cm2 s) at reference energy E0 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 46 F0 = 1e-11 # http://odahub.io/ontology#Float | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 47 E0 = 1.0 # http://odahub.io/ontology#Energy_TeV | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 48 Gamma = 2.0 # http://odahub.io/ontology#Float | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 49 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 50 Radius_spectal_extraction = 0.2 # http://odahub.io/ontology#Float | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 51 Radius_sky_image = 2.5 # http://odahub.io/ontology#AngleDegrees | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 52 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 53 Site = "North" # http://odahub.io/ontology#String ; oda:allowed_value "North","South" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 54 Telescope_LST = True # http://odahub.io/ontology#Boolean | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 55 Telescope_MST = True # http://odahub.io/ontology#Boolean | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 56 Telescope_SST = False # http://odahub.io/ontology#Boolean | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 57 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 58 _galaxy_wd = os.getcwd() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 59 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 60 with open("inputs.json", "r") as fd: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 61 inp_dic = json.load(fd) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 62 if "_data_product" in inp_dic.keys(): | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 63 inp_pdic = inp_dic["_data_product"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 64 else: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 65 inp_pdic = inp_dic | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 66 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 67 for vn, vv in inp_pdic.items(): | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 68 if vn != "_selector": | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 69 globals()[vn] = type(globals()[vn])(vv) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 70 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 71 LSTs = Telescope_LST | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 72 MSTs = Telescope_MST | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 73 SSTs = Telescope_SST | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 74 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 75 Texp = Texp * 3600.0 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 76 DEC_pnt = DEC | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 77 cdec = cos(DEC * pi / 180.0) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 78 RA_pnt = RA - OffAxis_angle / cdec | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 79 Radius = Radius_sky_image | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 80 R_s = Radius_spectal_extraction | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 81 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 82 pointing = SkyCoord(RA_pnt, DEC_pnt, unit="deg", frame="icrs") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 83 coord_s = SkyCoord(RA, DEC, unit="deg", frame="icrs") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 84 RA_bkg = RA_pnt - (RA - RA_pnt) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 85 DEC_bkg = DEC_pnt - (DEC - DEC_pnt) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 86 coord_b = SkyCoord(RA_bkg, DEC_bkg, unit="deg", frame="icrs") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 87 offaxis = coord_s.separation(pointing).deg | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 88 pr = ProgressReporter() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 89 pr.report_progress(stage="Progress", progress=10.0) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 90 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 91 CTA_south_lat = -25.0 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 92 CTA_north_lat = 18.0 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 93 if Site == "North": | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 94 Zd = abs(DEC - CTA_north_lat) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 95 if Zd < 30.0: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 96 Zd = "20deg-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 97 elif Zd < 50: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 98 Zd = "40deg-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 99 elif Zd < 70.0: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 100 Zd = "60deg-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 101 else: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 102 raise RuntimeError("Source not visible from " + Site) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 103 if DEC > CTA_north_lat: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 104 N_S = "NorthAz-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 105 else: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 106 N_S = "SouthAz-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 107 if LSTs: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 108 tel = "4LSTs" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 109 if MSTs: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 110 tel += "09MSTs" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 111 if SSTs: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 112 raise RuntimeError("No SSTs on the North site") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 113 filename = "IRFS/fits/Prod5-North-" + Zd + N_S + tel | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 114 else: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 115 Zd = abs(DEC - CTA_south_lat) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 116 if Zd < 30.0: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 117 Zd = "20deg-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 118 elif Zd < 50: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 119 Zd = "40deg-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 120 elif Zd < 70.0: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 121 Zd = "60deg-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 122 else: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 123 raise RuntimeError("Source not visible from " + Site) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 124 if DEC > CTA_south_lat: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 125 N_S = "NorthAz-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 126 else: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 127 N_S = "SouthAz-" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 128 if MSTs: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 129 tel = "14MSTs" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 130 if SSTs: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 131 tel += "37MSTs" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 132 if LSTs: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 133 raise RuntimeError("No LSTs on the South site") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 134 filename = "IRFS/fits/Prod5-South-" + Zd + N_S + tel | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 135 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 136 if Texp < 1800: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 137 filename += ".1800s-v0.1.fits.gz" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 138 elif Texp < 18000: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 139 filename += ".18000s-v0.1.fits.gz" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 140 else: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 141 filename += ".180000s-v0.1.fits.gz" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 142 import os | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 143 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 144 print(filename) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 145 if os.path.exists(filename) == False: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 146 raise RuntimeError("No reponse function found") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 147 message = "No reponse function found!" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 148 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 149 hdul = fits.open(filename) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 150 aeff = hdul["EFFECTIVE AREA"].data | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 151 ENERG_LO = aeff["ENERG_LO"][0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 152 ENERG_HI = aeff["ENERG_HI"][0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 153 THETA_LO = aeff["THETA_LO"][0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 154 THETA_HI = aeff["THETA_HI"][0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 155 EFFAREA = aeff["EFFAREA"][0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 156 print(offaxis) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 157 ind_offaxis = len(THETA_LO[THETA_LO < offaxis] - 1) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 158 EFAREA = EFFAREA[ind_offaxis] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 159 HDU_EFFAREA = hdul["EFFECTIVE AREA"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 160 HDU_RMF = hdul["ENERGY DISPERSION"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 161 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 162 E = np.logspace(-2, 2, 20) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 163 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 164 d = np.genfromtxt("Franceschini17.txt") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 165 ee = d[:, 0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 166 z_grid = np.array([0.01, 0.03, 0.1, 0.3, 0.5, 1.0, 1.5, 2.0, 3.0]) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 167 ind = len(z_grid[z > z_grid]) - 1 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 168 coeff = (z - z_grid[ind]) / (z_grid[ind + 1] - z_grid[ind]) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 169 tau = d[:, ind + 1] + coeff * d[:, ind + 2] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 170 tau_interp = np.interp(E, ee, tau) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 171 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 172 def powerlaw_EBL(): | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 173 return F0 * (E / E0) ** (-Gamma) * exp(-tau_interp) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 174 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 175 F = powerlaw_EBL() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 176 plt.plot(E, E**2 * F) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 177 plt.xscale("log") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 178 plt.yscale("log") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 179 plt.ylim(1e-14, 1e-10) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 180 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 181 # filename = "IRFS/fits/Prod5-North-20deg-AverageAz-4LSTs09MSTs.180000s-v0.1.fits.gz" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 182 IRFS = load_irf_dict_from_file(filename) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 183 dic = { | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 184 "components": [ | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 185 { | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 186 "name": "Source1", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 187 "type": "SkyModel", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 188 "spectral": { | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 189 "type": "TemplateSpectralModel", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 190 "parameters": [{"name": "norm", "value": 1.0}], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 191 "energy": {"data": E.tolist(), "unit": "TeV"}, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 192 "values": {"data": F.tolist(), "unit": "1 / (cm2 TeV s)"}, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 193 }, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 194 "spatial": { | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 195 "type": "PointSpatialModel", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 196 "frame": "icrs", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 197 "parameters": [ | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 198 {"name": "lon_0", "value": RA, "unit": "deg"}, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 199 {"name": "lat_0", "value": DEC, "unit": "deg"}, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 200 ], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 201 }, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 202 }, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 203 { | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 204 "type": "FoVBackgroundModel", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 205 "datasets_names": ["my-dataset"], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 206 "spectral": { | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 207 "type": "PowerLawNormSpectralModel", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 208 "parameters": [ | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 209 {"name": "norm", "value": 1.0}, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 210 {"name": "tilt", "value": 0.0}, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 211 {"name": "reference", "value": 1.0, "unit": "TeV"}, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 212 ], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 213 }, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 214 }, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 215 ] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 216 } | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 217 modelsky = Models.from_dict(dic) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 218 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 219 bkg_model = FoVBackgroundModel(dataset_name="my-dataset") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 220 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 221 observation = Observation.create( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 222 obs_id="0", pointing=pointing, livetime=str(Texp) + " s", irfs=IRFS | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 223 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 224 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 225 print(f"Create the dataset for {pointing}") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 226 energy_axis = MapAxis.from_energy_bounds( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 227 "0.012 TeV", "100 TeV", nbin=10, per_decade=True | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 228 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 229 energy_axis_true = MapAxis.from_energy_bounds( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 230 "0.001 TeV", "300 TeV", nbin=20, per_decade=True, name="energy_true" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 231 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 232 migra_axis = MapAxis.from_bounds( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 233 0.5, 2, nbin=150, node_type="edges", name="migra" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 234 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 235 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 236 geom = WcsGeom.create( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 237 skydir=pointing, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 238 width=(2 * Radius, 2 * Radius), | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 239 binsz=0.02, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 240 frame="icrs", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 241 axes=[energy_axis], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 242 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 243 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 244 empty = MapDataset.create( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 245 geom, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 246 energy_axis_true=energy_axis_true, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 247 migra_axis=migra_axis, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 248 name="my-dataset", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 249 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 250 maker = MapDatasetMaker(selection=["exposure", "background", "psf", "edisp"]) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 251 dataset = maker.run(empty, observation) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 252 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 253 region_sky = CircleSkyRegion(center=pointing, radius=Radius * u.deg) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 254 mask_map = dataset.geoms["geom"].region_mask(region_sky) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 255 mod = modelsky.select_mask(mask_map) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 256 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 257 bkg_idx = np.where(np.array(modelsky.names) == "my-dataset-bkg") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 258 mod.append(modelsky[int(bkg_idx[0][0])]) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 259 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 260 dataset.models = mod | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 261 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 262 for m in dataset.models[:-1]: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 263 sep = m.spatial_model.position.separation(pointing).deg | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 264 print( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 265 f"This is the spatial separation of {m.name} from the pointing direction: {sep}" | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 266 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 267 pr.report_progress(stage="Progress", progress=50.0) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 268 print("Simulate...") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 269 sampler = MapDatasetEventSampler() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 270 events = sampler.run(dataset, observation) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 271 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 272 pr.report_progress(stage="Progress", progress=90.0) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 273 print(f"Save events ...") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 274 primary_hdu = fits.PrimaryHDU() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 275 hdu_evt = fits.BinTableHDU(events.table) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 276 hdu_gti = fits.BinTableHDU(dataset.gti.table, name="GTI") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 277 hdu_all = fits.HDUList([primary_hdu, hdu_evt, hdu_gti, HDU_EFFAREA, HDU_RMF]) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 278 hdu_all.writeto(f"./events.fits", overwrite=True) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 279 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 280 hdul = fits.open("events.fits") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 281 ev = hdul["EVENTS"].data | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 282 ra = ev["RA"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 283 dec = ev["DEC"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 284 coords = SkyCoord(ra, dec, unit="degree") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 285 en = ev["ENERGY"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 286 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 287 from matplotlib.colors import LogNorm | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 288 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 289 plt.figure() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 290 pixsize = 0.1 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 291 Nbins = 2 * int(Radius / pixsize) + 1 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 292 ra0 = np.mean(ra) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 293 dec0 = np.mean(dec) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 294 from numpy import cos, pi | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 295 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 296 cdec = cos(DEC_pnt * pi / 180.0) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 297 ra_bins = np.linspace( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 298 RA_pnt - Radius / cdec, RA_pnt + Radius / cdec, Nbins + 1 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 299 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 300 dec_bins = np.linspace(DEC_pnt - Radius, DEC_pnt + Radius, Nbins + 1) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 301 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 302 h = plt.hist2d(ra, dec, bins=[ra_bins, dec_bins], norm=LogNorm()) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 303 image = h[0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 304 plt.colorbar() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 305 plt.xlabel("RA") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 306 plt.ylabel("Dec") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 307 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 308 plt.figure() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 309 ev_src = en[coords.separation(coord_s).deg < R_s] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 310 ev_bkg = en[coords.separation(coord_b).deg < R_s] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 311 ENERG_BINS = np.concatenate((ENERG_LO, [ENERG_HI[-1]])) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 312 ENERG = sqrt(ENERG_LO * ENERG_HI) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 313 h1 = np.histogram(ev_src, bins=ENERG_BINS) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 314 h2 = np.histogram(ev_bkg, bins=ENERG_BINS) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 315 cts_s = h1[0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 316 cts_b = h2[0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 317 src = cts_s - cts_b | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 318 src_err = sqrt(cts_s + cts_b) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 319 plt.errorbar(ENERG, src, src_err) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 320 plt.axhline(0, linestyle="dashed", color="black") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 321 plt.xscale("log") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 322 plt.xlabel(r"$E$, TeV") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 323 plt.ylabel("Counts") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 324 plt.yscale("log") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 325 plt.ylim(0.1, 2 * max(src)) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 326 plt.savefig("Count_spectrum.png") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 327 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 328 plt.figure() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 329 sep_s = coords.separation(coord_s).deg | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 330 sep_b = coords.separation(coord_b).deg | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 331 plt.hist(sep_s**2, bins=np.linspace(0, 0.5, 50)) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 332 plt.hist(sep_b**2, bins=np.linspace(0, 0.5, 50)) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 333 plt.axvline(R_s**2, color="black", linestyle="dashed") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 334 plt.xlabel(r"$\theta^2$, degrees") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 335 plt.ylabel("Counts") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 336 plt.savefig("Theta2_plot.png") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 337 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 338 # Create a new WCS object. The number of axes must be set | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 339 # from the start | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 340 plt.figure() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 341 w = wcs.WCS(naxis=2) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 342 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 343 w.wcs.ctype = ["RA---CAR", "DEC--CAR"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 344 # we need a Plate carrée (CAR) projection since histogram is binned by ra-dec | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 345 # the peculiarity here is that CAR projection produces rectilinear grid only if CRVAL2==0 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 346 # also, we will follow convention of RA increasing from right to left (CDELT1<0, need to flip an input image) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 347 # otherwise, aladin-lite doesn't show it | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 348 w.wcs.crval = [RA_pnt, 0] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 349 w.wcs.crpix = [Nbins / 2.0 + 0.5, 1 - dec_bins[0] / pixsize] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 350 w.wcs.cdelt = np.array([-pixsize / cdec, pixsize]) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 351 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 352 header = w.to_header() | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 353 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 354 hdu = fits.PrimaryHDU(np.flip(image.T, axis=1), header=header) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 355 hdu.writeto("Image.fits", overwrite=True) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 356 hdu = fits.open("Image.fits") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 357 im = hdu[0].data | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 358 wcs1 = wcs.WCS(hdu[0].header) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 359 ax = plt.subplot(projection=wcs1) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 360 lon = ax.coords["ra"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 361 lon.set_major_formatter("d.dd") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 362 lat = ax.coords["dec"] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 363 lat.set_major_formatter("d.dd") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 364 plt.imshow(im, origin="lower") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 365 plt.colorbar(label="Counts") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 366 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 367 plt.scatter( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 368 [RA_pnt], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 369 [DEC_pnt], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 370 marker="x", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 371 color="white", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 372 alpha=0.5, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 373 transform=ax.get_transform("world"), | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 374 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 375 plt.scatter( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 376 [RA], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 377 [DEC], | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 378 marker="+", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 379 color="red", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 380 alpha=0.5, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 381 transform=ax.get_transform("world"), | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 382 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 383 plt.grid(color="white", ls="solid") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 384 plt.xlabel("RA") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 385 plt.ylabel("Dec") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 386 plt.savefig("Image.png", format="png", bbox_inches="tight") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 387 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 388 fits_events = BinaryProduct.from_file("events.fits") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 389 bin_image1 = PictureProduct.from_file("Image.png") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 390 bin_image2 = PictureProduct.from_file("Theta2_plot.png") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 391 bin_image3 = PictureProduct.from_file("Count_spectrum.png") | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 392 pr.report_progress(stage="Progress", progress=100.0) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 393 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 394 image_png = bin_image1 # http://odahub.io/ontology#ODAPictureProduct | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 395 theta2_png = bin_image2 # http://odahub.io/ontology#ODAPictureProduct | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 396 spectrum_png = bin_image3 # http://odahub.io/ontology#ODAPictureProduct | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 397 event_list_fits = fits_events # http://odahub.io/ontology#ODABinaryProduct | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 398 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 399 # output gathering | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 400 _galaxy_meta_data = {} | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 401 _oda_outs = [] | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 402 _oda_outs.append( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 403 ("out_pre_defined_model_image_png", "image_png_galaxy.output", image_png) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 404 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 405 _oda_outs.append( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 406 ( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 407 "out_pre_defined_model_theta2_png", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 408 "theta2_png_galaxy.output", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 409 theta2_png, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 410 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 411 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 412 _oda_outs.append( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 413 ( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 414 "out_pre_defined_model_spectrum_png", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 415 "spectrum_png_galaxy.output", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 416 spectrum_png, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 417 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 418 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 419 _oda_outs.append( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 420 ( | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 421 "out_pre_defined_model_event_list_fits", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 422 "event_list_fits_galaxy.output", | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 423 event_list_fits, | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 424 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 425 ) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 426 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 427 for _outn, _outfn, _outv in _oda_outs: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 428 _galaxy_outfile_name = os.path.join(_galaxy_wd, _outfn) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 429 if isinstance(_outv, str) and os.path.isfile(_outv): | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 430 shutil.move(_outv, _galaxy_outfile_name) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 431 _galaxy_meta_data[_outn] = {"ext": "_sniff_"} | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 432 elif getattr(_outv, "write_fits_file", None): | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 433 _outv.write_fits_file(_galaxy_outfile_name) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 434 _galaxy_meta_data[_outn] = {"ext": "fits"} | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 435 elif getattr(_outv, "write_file", None): | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 436 _outv.write_file(_galaxy_outfile_name) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 437 _galaxy_meta_data[_outn] = {"ext": "_sniff_"} | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 438 else: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 439 with open(_galaxy_outfile_name, "w") as fd: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 440 json.dump(_outv, fd, cls=CustomJSONEncoder) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 441 _galaxy_meta_data[_outn] = {"ext": "json"} | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 442 | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 443 with open(os.path.join(_galaxy_wd, "galaxy.json"), "w") as fd: | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 444 json.dump(_galaxy_meta_data, fd) | 
| 
2f3e314c3dfa
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 4543470805fc78f6cf2604b9d55beb6f06359995
 astroteam parents: diff
changeset | 445 print("*** Job finished successfully ***") | 
