annotate source_extraction.py @ 0:f4648bd69d48 draft default tip

planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
author astroteam
date Fri, 18 Jul 2025 14:23:35 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
1 #!/usr/bin/env python
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
2 # coding: utf-8
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
3
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
4 #!/usr/bin/env python
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
5
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
6 # This script is generated with nb2galaxy
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
7
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
8 # flake8: noqa
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
9
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
10 import json
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
11 import os
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
12 import shutil
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
13
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
14 import matplotlib.pyplot as plt
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
15 import numpy as np
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
16 import sep
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
17 import tifffile
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
18 from astropy.io import fits
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
19 from astropy.table import Table
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
20 from matplotlib import rcParams
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
21 from matplotlib.patches import Ellipse
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
22 from oda_api.json import CustomJSONEncoder
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
23
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
24 get_ipython().run_line_magic("matplotlib", "inline") # noqa: F821
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
25
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
26 rcParams["figure.figsize"] = [10.0, 8.0]
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
27
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
28 input_file = "./input.fits" # oda:POSIXPath; oda:label "Input file"
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
29
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
30 ### These params are for both functions
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
31 mask_file = None # oda:POSIXPath, oda:optional; oda:label "Mask file"
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
32
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
33 ### These params are for sep.extract()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
34 thresh = 1.5 # oda:Float
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
35 err_option = "float_globalrms" # oda:String; oda:allowed_value 'float_globalrms','array_rms', 'none'
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
36 # gain = None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
37 maskthresh = 0.0 # oda:Float
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
38 minarea = 5 # oda:Integer
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
39 filter_case = "default" # oda:String; oda:label "Filter Case"; oda:allowed_value 'none', 'default', 'file'
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
40 filter_file = None # oda:POSIXPath, oda:optional; oda:label "Filter file"
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
41 filter_type = "matched" # oda:String; oda:allowed_value 'matched','conv'
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
42 deblend_nthresh = 32 # oda:Integer
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
43 deblend_cont = 0.005 # oda:Float
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
44 clean = True # oda:Boolean
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
45 clean_param = 1.0 # oda:Float
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
46
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
47 ### These params are for sep.Background()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
48 # maskthresh = 0.0
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
49 bw = 64 # oda:Integer
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
50 bh = 64 # oda:Integer
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
51 fw = 3 # oda:Integer
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
52 fh = 3 # oda:Integer
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
53 fthresh = 0.0 # oda:Float
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
54
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
55 _galaxy_wd = os.getcwd()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
56
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
57 with open("inputs.json", "r") as fd:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
58 inp_dic = json.load(fd)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
59 if "C_data_product_" in inp_dic.keys():
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
60 inp_pdic = inp_dic["C_data_product_"]
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
61 else:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
62 inp_pdic = inp_dic
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
63 input_file = str(inp_pdic["input_file"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
64
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
65 mask_file = (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
66 str(inp_pdic["mask_file"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
67 if inp_pdic.get("mask_file", None) is not None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
68 else None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
69 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
70
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
71 thresh = float(inp_pdic["thresh"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
72 err_option = str(inp_pdic["err_option"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
73 maskthresh = float(inp_pdic["maskthresh"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
74 minarea = int(inp_pdic["minarea"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
75 filter_case = str(inp_pdic["filter_case"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
76
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
77 filter_file = (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
78 str(inp_pdic["filter_file"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
79 if inp_pdic.get("filter_file", None) is not None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
80 else None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
81 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
82
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
83 filter_type = str(inp_pdic["filter_type"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
84 deblend_nthresh = int(inp_pdic["deblend_nthresh"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
85 deblend_cont = float(inp_pdic["deblend_cont"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
86 clean = bool(inp_pdic["clean"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
87 clean_param = float(inp_pdic["clean_param"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
88 bw = int(inp_pdic["bw"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
89 bh = int(inp_pdic["bh"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
90 fw = int(inp_pdic["fw"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
91 fh = int(inp_pdic["fh"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
92 fthresh = float(inp_pdic["fthresh"])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
93
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
94 try:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
95 hdul = fits.open(input_file)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
96 data = hdul[0].data
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
97 data = data.astype(data.dtype.newbyteorder("=")).astype(float)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
98 except:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
99 try:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
100 data = tifffile.imread(input_file).astype(float)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
101 except:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
102 raise RuntimeError(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
103 "The input file should have the FITS or TIFF format."
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
104 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
105
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
106 print("INFO: Data shape:", data.shape)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
107
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
108 if mask_file is not None:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
109 try:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
110 hdul = fits.open(mask_file)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
111 mask = hdul[0].data
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
112 mask = mask.astype(mask.dtype.newbyteorder("="))
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
113 except:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
114 try:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
115 mask = tifffile.imread(mask_file)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
116 except:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
117 raise RuntimeError(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
118 "The mask file should have the FITS or TIFF format."
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
119 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
120 else:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
121 mask = None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
122
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
123 print("INFO: Mask type:", type(mask))
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
124
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
125 filter_kernel = None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
126 if filter_case == "none":
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
127 filter_kernel = None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
128 elif filter_case == "default":
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
129 filter_kernel = np.array([[1, 2, 1], [2, 4, 2], [1, 2, 1]])
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
130 elif filter_case == "file":
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
131 try:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
132 filter_kernel = np.loadtxt(filter_file)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
133 except:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
134 raise RuntimeError(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
135 "The filter file should be a text file that is loaded with numpy.loadtxt"
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
136 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
137
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
138 print("INFO: Filter kernel:", filter_kernel)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
139
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
140 # measure a spatially varying background on the image
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
141 bkg = sep.Background(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
142 data,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
143 mask=mask,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
144 maskthresh=maskthresh,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
145 bw=bw,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
146 bh=bh,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
147 fw=fw,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
148 fh=fh,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
149 fthresh=fthresh,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
150 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
151
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
152 # evaluate background as 2-d array, same size as original image
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
153 bkg_array = bkg.back()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
154 hdu_bkg = fits.PrimaryHDU(bkg_array)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
155 hdu_bkg.writeto("bkg_array.fits")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
156
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
157 # evaluate the background noise as 2-d array, same size as original image
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
158 bkg_rms = bkg.rms()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
159 hdu_rms = fits.PrimaryHDU(bkg_rms)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
160 hdu_rms.writeto("bkg_rms.fits")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
161
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
162 # subtract the background
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
163 data_sub = data - bkg
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
164
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
165 if err_option == "float_globalrms":
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
166 err = bkg.globalrms
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
167 elif err_option == "array_rms":
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
168 err = bkg_rms
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
169 else:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
170 err = None
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
171
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
172 # extract sources:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
173 objects, segmap = sep.extract(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
174 data_sub,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
175 thresh,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
176 err=err,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
177 gain=None,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
178 mask=mask,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
179 maskthresh=maskthresh,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
180 minarea=minarea,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
181 filter_kernel=filter_kernel,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
182 filter_type=filter_type,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
183 deblend_nthresh=deblend_nthresh,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
184 deblend_cont=deblend_cont,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
185 clean=clean,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
186 clean_param=clean_param,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
187 segmentation_map=True,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
188 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
189
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
190 # show the background
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
191 fig, ax = plt.subplots()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
192 im = ax.imshow(bkg_array, interpolation="nearest", cmap="gray", origin="lower")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
193 fig.colorbar(im)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
194 fig.savefig("./bkg_image.png", format="png", bbox_inches="tight")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
195
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
196 # show the background noise
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
197 fig, ax = plt.subplots()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
198 im = ax.imshow(bkg_rms, interpolation="nearest", cmap="gray", origin="lower")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
199 ax.set_title(f"This is array_rms. While float_globalrms={bkg.globalrms}")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
200 fig.colorbar(im)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
201 fig.savefig("./bkg_rms.png", format="png", bbox_inches="tight")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
202
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
203 # plot image
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
204 fig, ax = plt.subplots()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
205 m, s = np.mean(data), np.std(data)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
206 im = ax.imshow(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
207 data,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
208 interpolation="nearest",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
209 cmap="gray",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
210 vmin=m - s,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
211 vmax=m + s,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
212 origin="lower",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
213 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
214 fig.colorbar(im)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
215 fig.savefig("./fits2image.png", format="png", bbox_inches="tight")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
216
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
217 # show the segmentation map
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
218 fig, ax = plt.subplots()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
219 im = ax.imshow(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
220 segmap,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
221 interpolation="nearest",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
222 cmap="gray",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
223 origin="lower",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
224 vmin=0,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
225 vmax=1,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
226 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
227 fig.colorbar(im)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
228 fig.savefig("./segmap.png", format="png", bbox_inches="tight")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
229
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
230 # plot background-subtracted image
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
231 fig, ax = plt.subplots()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
232 m, s = np.mean(data_sub), np.std(data_sub)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
233 im = ax.imshow(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
234 data_sub,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
235 interpolation="nearest",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
236 cmap="gray",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
237 vmin=m - s,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
238 vmax=m + s,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
239 origin="lower",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
240 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
241
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
242 # plot an ellipse for each object
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
243 for i in range(len(objects)):
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
244 e = Ellipse(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
245 xy=(objects["x"][i], objects["y"][i]),
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
246 width=6 * objects["a"][i],
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
247 height=6 * objects["b"][i],
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
248 angle=objects["theta"][i] * 180.0 / np.pi,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
249 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
250 e.set_facecolor("none")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
251 e.set_edgecolor("red")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
252 ax.add_artist(e)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
253
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
254 fig.savefig("./sources.png", format="png", bbox_inches="tight")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
255
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
256 plt.show()
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
257
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
258 from oda_api.data_products import ODAAstropyTable
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
259
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
260 cat = ODAAstropyTable(Table(data=objects))
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
261 hdu_rms = fits.PrimaryHDU(segmap.astype("uint32"))
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
262 hdu_rms.writeto("segmentation_map.fits")
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
263
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
264 bkg_picture = "./bkg_image.png" # oda:POSIXPath
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
265 rms_picture = "./bkg_rms.png" # oda:POSIXPath
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
266 data_picture = "./fits2image.png" # oda:POSIXPath
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
267 sources_picture = "./sources.png" # oda:POSIXPath
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
268 segmentation_map_picture = "./segmap.png" # oda:POSIXPath
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
269 segmentation_map = "./segmentation_map.fits" # oda:POSIXPath
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
270 bkg_array = "./bkg_array.fits" # oda:POSIXPath
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
271 rms_array = "./bkg_rms.fits" # oda:POSIXPath
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
272 catalog_table = cat # oda:ODAAstropyTable
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
273
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
274 # output gathering
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
275 _galaxy_meta_data = {}
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
276 _oda_outs = []
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
277 _oda_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
278 (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
279 "out_source_extraction_catalog_table",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
280 "catalog_table_galaxy.output",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
281 catalog_table,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
282 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
283 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
284
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
285 for _outn, _outfn, _outv in _oda_outs:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
286 _galaxy_outfile_name = os.path.join(_galaxy_wd, _outfn)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
287 if isinstance(_outv, str) and os.path.isfile(_outv):
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
288 shutil.move(_outv, _galaxy_outfile_name)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
289 _galaxy_meta_data[_outn] = {"ext": "_sniff_"}
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
290 elif getattr(_outv, "write_fits_file", None):
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
291 _outv.write_fits_file(_galaxy_outfile_name)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
292 _galaxy_meta_data[_outn] = {"ext": "fits"}
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
293 elif getattr(_outv, "write_file", None):
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
294 _outv.write_file(_galaxy_outfile_name)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
295 _galaxy_meta_data[_outn] = {"ext": "_sniff_"}
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
296 else:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
297 with open(_galaxy_outfile_name, "w") as fd:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
298 json.dump(_outv, fd, cls=CustomJSONEncoder)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
299 _galaxy_meta_data[_outn] = {"ext": "json"}
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
300 _simple_outs = []
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
301 _simple_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
302 (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
303 "out_source_extraction_bkg_picture",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
304 "bkg_picture_galaxy.output",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
305 bkg_picture,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
306 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
307 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
308 _simple_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
309 (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
310 "out_source_extraction_rms_picture",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
311 "rms_picture_galaxy.output",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
312 rms_picture,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
313 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
314 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
315 _simple_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
316 (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
317 "out_source_extraction_data_picture",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
318 "data_picture_galaxy.output",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
319 data_picture,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
320 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
321 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
322 _simple_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
323 (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
324 "out_source_extraction_sources_picture",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
325 "sources_picture_galaxy.output",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
326 sources_picture,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
327 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
328 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
329 _simple_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
330 (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
331 "out_source_extraction_segmentation_map_picture",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
332 "segmentation_map_picture_galaxy.output",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
333 segmentation_map_picture,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
334 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
335 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
336 _simple_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
337 (
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
338 "out_source_extraction_segmentation_map",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
339 "segmentation_map_galaxy.output",
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
340 segmentation_map,
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
341 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
342 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
343 _simple_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
344 ("out_source_extraction_bkg_array", "bkg_array_galaxy.output", bkg_array)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
345 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
346 _simple_outs.append(
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
347 ("out_source_extraction_rms_array", "rms_array_galaxy.output", rms_array)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
348 )
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
349 _numpy_available = True
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
350
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
351 for _outn, _outfn, _outv in _simple_outs:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
352 _galaxy_outfile_name = os.path.join(_galaxy_wd, _outfn)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
353 if isinstance(_outv, str) and os.path.isfile(_outv):
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
354 shutil.move(_outv, _galaxy_outfile_name)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
355 _galaxy_meta_data[_outn] = {"ext": "_sniff_"}
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
356 elif _numpy_available and isinstance(_outv, np.ndarray):
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
357 with open(_galaxy_outfile_name, "wb") as fd:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
358 np.savez(fd, _outv)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
359 _galaxy_meta_data[_outn] = {"ext": "npz"}
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
360 else:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
361 with open(_galaxy_outfile_name, "w") as fd:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
362 json.dump(_outv, fd)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
363 _galaxy_meta_data[_outn] = {"ext": "expression.json"}
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
364
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
365 with open(os.path.join(_galaxy_wd, "galaxy.json"), "w") as fd:
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
366 json.dump(_galaxy_meta_data, fd)
f4648bd69d48 planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit 89e20bd2ec941d1d362da85bd81230419a1a4b2a
astroteam
parents:
diff changeset
367 print("*** Job finished successfully ***")