Mercurial > repos > astroteam > hess_astro_tool
annotate Spectrum.py @ 0:02e4bb4fa10c draft
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
author | astroteam |
---|---|
date | Mon, 19 Feb 2024 10:56:44 +0000 |
parents | |
children | 593c4b45eda5 |
rev | line source |
---|---|
0
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
1 #!/usr/bin/env python |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
2 # coding: utf-8 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
3 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
4 # flake8: noqa |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
5 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
6 import json |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
7 import os |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
8 import shutil |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
9 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
10 import matplotlib.pyplot as plt |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
11 import numpy as np |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
12 from astropy.coordinates import SkyCoord |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
13 from astropy.io import fits |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
14 from astropy.time import Time |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
15 from numpy import log10, sqrt |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
16 from oda_api.data_products import ODAAstropyTable, PictureProduct |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
17 from oda_api.json import CustomJSONEncoder |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
18 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
19 if os.path.exists("hess_dl3_dr1.tar.gz") == False: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
20 get_ipython().system( # noqa: F821 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
21 "wget https://zenodo.org/record/1421099/files/hess_dl3_dr1.tar.gz" |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
22 ) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
23 get_ipython().system("tar -zxvf hess_dl3_dr1.tar.gz") # noqa: F821 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
24 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
25 # src_name='Crab' #http://odahub.io/ontology#AstrophysicalObject |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
26 # RA = 83.628700 # http://odahub.io/ontology#PointOfInterestRA |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
27 # DEC = 22.014700 # http://odahub.io/ontology#PointOfInterestDEC |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
28 src_name = "PKS 2155-304" |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
29 RA = 329.716938 # http://odahub.io/ontology#PointOfInterestRA |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
30 DEC = -30.225588 # http://odahub.io/ontology#PointOfInterestDEC |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
31 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
32 T1 = "2000-10-09T13:16:00.0" # http://odahub.io/ontology#StartTime |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
33 T2 = "2022-10-10T13:16:00.0" # http://odahub.io/ontology#EndTime |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
34 Radius = 2.5 # http://odahub.io/ontology#AngleDegrees |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
35 R_s = 0.2 # http://odahub.io/ontology#AngleDegrees |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
36 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
37 Emin = 100.0 # http://odahub.io/ontology#Energy_GeV |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
38 Emax = 10000.0 # http://odahub.io/ontology#Energy_GeV |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
39 NEbins = 20 # http://odahub.io/ontology#Integer |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
40 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
41 _galaxy_wd = os.getcwd() |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
42 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
43 with open("inputs.json", "r") as fd: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
44 inp_dic = json.load(fd) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
45 if "_data_product" in inp_dic.keys(): |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
46 inp_pdic = inp_dic["_data_product"] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
47 else: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
48 inp_pdic = inp_dic |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
49 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
50 for vn, vv in inp_pdic.items(): |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
51 if vn != "_selector": |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
52 globals()[vn] = type(globals()[vn])(vv) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
53 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
54 Emin = Emin / 1e3 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
55 Emax = Emax / 1e3 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
56 Ebins = np.logspace(log10(Emin), log10(Emax), NEbins + 1) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
57 Ebins |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
58 Emin = Ebins[:-1] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
59 Emax = Ebins[1:] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
60 Emean = sqrt(Emin * Emax) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
61 lgEmean = log10(Emean) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
62 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
63 T1 = Time(T1, format="isot", scale="utc").mjd |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
64 T2 = Time(T2, format="isot", scale="utc").mjd |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
65 message = "" |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
66 RA_pnts = [] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
67 DEC_pnts = [] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
68 DL3_files = [] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
69 OBSIDs = [] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
70 Tstart = [] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
71 Tstop = [] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
72 flist = os.listdir("data") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
73 for f in flist: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
74 if f[-7:] == "fits.gz": |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
75 DL3_files.append(f) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
76 OBSIDs.append(int(f[20:26])) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
77 hdul = fits.open("data/" + f) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
78 RA_pnts.append(float(hdul[1].header["RA_PNT"])) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
79 DEC_pnts.append(float(hdul[1].header["DEC_PNT"])) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
80 Tstart.append( |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
81 Time( |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
82 hdul[1].header["DATE-OBS"] + "T" + hdul[1].header["TIME-OBS"], |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
83 format="isot", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
84 scale="utc", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
85 ).mjd |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
86 ) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
87 Tstop.append( |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
88 Time( |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
89 hdul[1].header["DATE-END"] + "T" + hdul[1].header["TIME-END"], |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
90 format="isot", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
91 scale="utc", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
92 ).mjd |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
93 ) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
94 hdul.close() |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
95 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
96 Coords_s = SkyCoord(RA, DEC, unit="degree") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
97 COORDS_pnts = SkyCoord(RA_pnts, DEC_pnts, unit="degree") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
98 seps = COORDS_pnts.separation(Coords_s).deg |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
99 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
100 mask = np.where((seps < Radius) & (Tstart > T1) & (Tstop < T2))[0] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
101 OBSlist = [] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
102 for i in mask: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
103 OBSlist.append(DL3_files[i]) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
104 if len(OBSlist) == 0: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
105 message = "No data found" |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
106 raise RuntimeError("No data found") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
107 message |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
108 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
109 cts_s = np.zeros(NEbins) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
110 cts_b = np.zeros(NEbins) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
111 Expos = np.zeros(NEbins) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
112 for f in OBSlist: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
113 hdul = fits.open("data/" + f) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
114 RA_pnt = hdul[1].header["RA_PNT"] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
115 DEC_pnt = hdul[1].header["DEC_PNT"] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
116 Texp = hdul[1].header["LIVETIME"] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
117 dRA = RA - RA_pnt |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
118 dDEC = DEC - DEC_pnt |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
119 RA_b = RA_pnt - dRA |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
120 DEC_b = DEC_pnt - dDEC |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
121 Coords_b = SkyCoord(RA_b, DEC_b, unit="degree") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
122 Coords_pnt = SkyCoord(RA_pnt, DEC_pnt, unit="degree") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
123 dist = Coords_pnt.separation(Coords_s).deg |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
124 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
125 ev = hdul["EVENTS"].data |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
126 ev_ra = ev["RA"] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
127 ev_dec = ev["DEC"] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
128 ev_en = ev["ENERGY"] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
129 ev_time = ev["TIME"] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
130 ev_coords = SkyCoord(ev_ra, ev_dec, unit="degree") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
131 sep_s = ev_coords.separation(Coords_s).deg |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
132 sep_b = ev_coords.separation(Coords_b).deg |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
133 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
134 hdu = hdul["AEFF"].data |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
135 EEmin = hdu["ENERG_LO"][0] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
136 EEmax = hdu["ENERG_HI"][0] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
137 lgEE = log10(sqrt(EEmin * EEmax)) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
138 lgAA = log10(hdu["EFFAREA"][0] + 1e-10) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
139 Thmin = hdu["THETA_LO"][0] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
140 Thmax = hdu["THETA_HI"][0] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
141 ind = np.argmin((Thmin - dist) ** 2) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
142 Expos += 10 ** (np.interp(lgEmean, lgEE, lgAA[ind])) * Texp |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
143 mask = sep_s < R_s |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
144 cts_s += np.histogram(ev_en[mask], bins=Ebins)[0] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
145 mask = sep_b < R_s |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
146 cts_b += np.histogram(ev_en[mask], bins=Ebins)[0] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
147 hdul.close() |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
148 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
149 flux = (cts_s - cts_b) / (Emax - Emin) * Emax * Emin / (Expos * 1e4) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
150 flux_err = sqrt(cts_s + cts_b) / (Emax - Emin) * Emax * Emin / (Expos * 1e4) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
151 plt.errorbar(Emean, flux, yerr=flux_err, xerr=[Emean - Emin, Emax - Emean]) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
152 plt.xscale("log") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
153 plt.yscale("log") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
154 plt.xlabel("$E$, TeV") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
155 plt.ylabel("$E^2 dN/dE$, erg/(cm$^2$s)") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
156 plt.savefig("Spectrum.png", format="png") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
157 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
158 bin_image = PictureProduct.from_file("Spectrum.png") |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
159 from astropy.table import Table |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
160 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
161 data = [Emean, Emin, Emax, flux, flux_err, cts_s, cts_b, Expos * 1e4] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
162 names = ( |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
163 "Emean[TeV]", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
164 "Emin[TeV]", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
165 "Emax[TeV]", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
166 "Flux[TeV/cm2s]", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
167 "Flux_error[TeV/cm2s]", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
168 "Cts_s", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
169 "Cts_b", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
170 "Exposure[cm2s]", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
171 ) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
172 spec = ODAAstropyTable(Table(data, names=names)) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
173 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
174 picture_png = bin_image # http://odahub.io/ontology#ODAPictureProduct |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
175 spectrum_astropy_table = spec # http://odahub.io/ontology#ODAAstropyTable |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
176 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
177 # output gathering |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
178 _galaxy_meta_data = {} |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
179 _oda_outs = [] |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
180 _oda_outs.append( |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
181 ("out_Spectrum_picture_png", "picture_png_galaxy.output", picture_png) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
182 ) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
183 _oda_outs.append( |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
184 ( |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
185 "out_Spectrum_spectrum_astropy_table", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
186 "spectrum_astropy_table_galaxy.output", |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
187 spectrum_astropy_table, |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
188 ) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
189 ) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
190 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
191 for _outn, _outfn, _outv in _oda_outs: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
192 _galaxy_outfile_name = os.path.join(_galaxy_wd, _outfn) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
193 if isinstance(_outv, str) and os.path.isfile(_outv): |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
194 shutil.move(_outv, _galaxy_outfile_name) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
195 _galaxy_meta_data[_outn] = {"ext": "_sniff_"} |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
196 elif getattr(_outv, "write_fits_file", None): |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
197 _outv.write_fits_file(_galaxy_outfile_name) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
198 _galaxy_meta_data[_outn] = {"ext": "fits"} |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
199 elif getattr(_outv, "write_file", None): |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
200 _outv.write_file(_galaxy_outfile_name) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
201 _galaxy_meta_data[_outn] = {"ext": "_sniff_"} |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
202 else: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
203 with open(_galaxy_outfile_name, "w") as fd: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
204 json.dump(_outv, fd, cls=CustomJSONEncoder) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
205 _galaxy_meta_data[_outn] = {"ext": "json"} |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
206 |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
207 with open(os.path.join(_galaxy_wd, "galaxy.json"), "w") as fd: |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
208 json.dump(_galaxy_meta_data, fd) |
02e4bb4fa10c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 2991f65b25d4e6d1b69458603fce917adff40f94
astroteam
parents:
diff
changeset
|
209 print("*** Job finished successfully ***") |