teareduce 0.6.5__py3-none-any.whl → 0.6.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- teareduce/cleanest/__main__.py +4 -10
- teareduce/cleanest/cosmicraycleanerapp.py +642 -233
- teareduce/cleanest/definitions.py +63 -5
- teareduce/cleanest/interpolate.py +1 -1
- teareduce/cleanest/interpolationeditor.py +23 -9
- teareduce/cleanest/lacosmicpad.py +23 -4
- teareduce/cleanest/parametereditor.py +386 -5
- teareduce/cleanest/reviewcosmicray.py +109 -18
- teareduce/sdistortion.py +1 -1
- teareduce/statsummary.py +1 -1
- teareduce/version.py +1 -1
- teareduce/wavecal.py +1 -1
- {teareduce-0.6.5.dist-info → teareduce-0.6.6.dist-info}/METADATA +5 -1
- {teareduce-0.6.5.dist-info → teareduce-0.6.6.dist-info}/RECORD +18 -18
- {teareduce-0.6.5.dist-info → teareduce-0.6.6.dist-info}/WHEEL +0 -0
- {teareduce-0.6.5.dist-info → teareduce-0.6.6.dist-info}/entry_points.txt +0 -0
- {teareduce-0.6.5.dist-info → teareduce-0.6.6.dist-info}/licenses/LICENSE.txt +0 -0
- {teareduce-0.6.5.dist-info → teareduce-0.6.6.dist-info}/top_level.txt +0 -0
|
@@ -19,11 +19,11 @@ VALID_LACOSMIC_PSFMODEL_VALUES = ["gauss", "moffat", "gaussx", "gaussy", "gaussx
|
|
|
19
19
|
# when reading user input.
|
|
20
20
|
lacosmic_default_dict = {
|
|
21
21
|
# L.A.Cosmic parameters for run 1
|
|
22
|
+
"run1_gain": {"value": 1.0, "type": float, "positive": True},
|
|
23
|
+
"run1_readnoise": {"value": 6.5, "type": float, "positive": True},
|
|
22
24
|
"run1_sigclip": {"value": 5.0, "type": float, "positive": True},
|
|
23
25
|
"run1_sigfrac": {"value": 0.3, "type": float, "positive": True},
|
|
24
26
|
"run1_objlim": {"value": 5.0, "type": float, "positive": True},
|
|
25
|
-
"run1_gain": {"value": 1.0, "type": float, "positive": True},
|
|
26
|
-
"run1_readnoise": {"value": 6.5, "type": float, "positive": True},
|
|
27
27
|
"run1_satlevel": {"value": 65535, "type": float, "positive": True},
|
|
28
28
|
"run1_niter": {"value": 4, "type": int, "positive": True, "intmode": "any"},
|
|
29
29
|
"run1_sepmed": {"value": True, "type": bool},
|
|
@@ -40,11 +40,11 @@ lacosmic_default_dict = {
|
|
|
40
40
|
"run1_psfbeta": {"value": 4.765, "type": float, "positive": True},
|
|
41
41
|
"run1_verbose": {"value": True, "type": bool},
|
|
42
42
|
# L.A.Cosmic parameters for run 2
|
|
43
|
+
"run2_gain": {"value": 1.0, "type": float, "positive": True},
|
|
44
|
+
"run2_readnoise": {"value": 6.5, "type": float, "positive": True},
|
|
43
45
|
"run2_sigclip": {"value": 3.0, "type": float, "positive": True},
|
|
44
46
|
"run2_sigfrac": {"value": 0.3, "type": float, "positive": True},
|
|
45
47
|
"run2_objlim": {"value": 5.0, "type": float, "positive": True},
|
|
46
|
-
"run2_gain": {"value": 1.0, "type": float, "positive": True},
|
|
47
|
-
"run2_readnoise": {"value": 6.5, "type": float, "positive": True},
|
|
48
48
|
"run2_satlevel": {"value": 65535, "type": float, "positive": True},
|
|
49
49
|
"run2_niter": {"value": 4, "type": int, "positive": True, "intmode": "any"},
|
|
50
50
|
"run2_sepmed": {"value": True, "type": bool},
|
|
@@ -72,6 +72,62 @@ lacosmic_default_dict = {
|
|
|
72
72
|
"nruns": {"value": 1, "type": int, "positive": True, "intmode": "any"},
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
# Default parameters for PyCosmic algorithm
|
|
76
|
+
pycosmic_default_dict = {
|
|
77
|
+
# PyCosmic parameters for run 1
|
|
78
|
+
"run1_gain": {"value": 1.0, "type": float, "positive": True},
|
|
79
|
+
"run1_rdnoise": {"value": 6.5, "type": float, "positive": True},
|
|
80
|
+
"run1_sigma_det": {"value": 5.0, "type": float, "positive": True},
|
|
81
|
+
"run1_rlim": {"value": 1.2, "type": float, "positive": True},
|
|
82
|
+
"run1_iterations": {"value": 5, "type": int, "positive": True, "intmode": "any"},
|
|
83
|
+
"run1_fwhm_gauss_x": {"value": 2.5, "type": float, "positive": True},
|
|
84
|
+
"run1_fwhm_gauss_y": {"value": 2.5, "type": float, "positive": True},
|
|
85
|
+
"run1_replace_box_x": {"value": 5, "type": int, "positive": True, "intmode": "odd"},
|
|
86
|
+
"run1_replace_box_y": {"value": 5, "type": int, "positive": True, "intmode": "odd"},
|
|
87
|
+
"run1_replace_error": {"value": 1e6, "type": float, "positive": True},
|
|
88
|
+
"run1_increase_radius": {"value": 0, "type": int, "positive": True},
|
|
89
|
+
"run1_bias": {"value": 0.0, "type": float},
|
|
90
|
+
"run1_verbose": {"value": True, "type": bool},
|
|
91
|
+
# PyCosmic parameters for run 2
|
|
92
|
+
"run2_gain": {"value": 1.0, "type": float, "positive": True},
|
|
93
|
+
"run2_rdnoise": {"value": 6.5, "type": float, "positive": True},
|
|
94
|
+
"run2_sigma_det": {"value": 3.0, "type": float, "positive": True},
|
|
95
|
+
"run2_rlim": {"value": 1.2, "type": float, "positive": True},
|
|
96
|
+
"run2_iterations": {"value": 5, "type": int, "positive": True, "intmode": "any"},
|
|
97
|
+
"run2_fwhm_gauss_x": {"value": 2.5, "type": float, "positive": True},
|
|
98
|
+
"run2_fwhm_gauss_y": {"value": 2.5, "type": float, "positive": True},
|
|
99
|
+
"run2_replace_box_x": {"value": 5, "type": int, "positive": True, "intmode": "odd"},
|
|
100
|
+
"run2_replace_box_y": {"value": 5, "type": int, "positive": True, "intmode": "odd"},
|
|
101
|
+
"run2_replace_error": {"value": 1e6, "type": float, "positive": True},
|
|
102
|
+
"run2_increase_radius": {"value": 0, "type": int, "positive": True},
|
|
103
|
+
"run2_bias": {"value": 0.0, "type": float},
|
|
104
|
+
"run2_verbose": {"value": True, "type": bool},
|
|
105
|
+
# Limits for the image section to process (pixels start at 1)
|
|
106
|
+
"xmin": {"value": 1, "type": int, "positive": True},
|
|
107
|
+
"xmax": {"value": None, "type": int, "positive": True},
|
|
108
|
+
"ymin": {"value": 1, "type": int, "positive": True},
|
|
109
|
+
"ymax": {"value": None, "type": int, "positive": True},
|
|
110
|
+
# Number of runs to execute PyCosmic
|
|
111
|
+
"nruns": {"value": 1, "type": int, "positive": True, "intmode": "any"},
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# Default parameters for deepCR algorithm
|
|
115
|
+
deepcr_default_dict = {
|
|
116
|
+
# Model name
|
|
117
|
+
"mask": {"value": "ACS-WFC", "type": str, "valid_values": ["ACS-WFC", "WFC3-UVIS"]},
|
|
118
|
+
# Threshold for CR probability map
|
|
119
|
+
"threshold": {"value": 0.5, "type": float, "positive": True},
|
|
120
|
+
"dilation": {"value": 0, "type": int, "positive": True},
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
# Default parameters for Cosmic-CoNN algorithm
|
|
124
|
+
cosmicconn_default_dict = {
|
|
125
|
+
# Threshold for CR probability map
|
|
126
|
+
"threshold": {"value": 0.5, "type": float, "positive": True},
|
|
127
|
+
# Dilation of the mask
|
|
128
|
+
"dilation": {"value": 0, "type": int, "positive": True},
|
|
129
|
+
}
|
|
130
|
+
|
|
75
131
|
# Valid cleaning methods (as shown to the user and their internal codes)
|
|
76
132
|
VALID_CLEANING_METHODS = {
|
|
77
133
|
"x interp.": "x",
|
|
@@ -80,6 +136,8 @@ VALID_CLEANING_METHODS = {
|
|
|
80
136
|
"median": "a-median",
|
|
81
137
|
"mean": "a-mean",
|
|
82
138
|
"lacosmic": "lacosmic",
|
|
139
|
+
"pycosmic": "pycosmic",
|
|
140
|
+
"deepcr": "deepcr",
|
|
83
141
|
"maskfill": "maskfill",
|
|
84
142
|
"auxdata": "auxdata",
|
|
85
143
|
}
|
|
@@ -102,7 +160,7 @@ DEFAULT_MASKFILL_VERBOSE = False
|
|
|
102
160
|
|
|
103
161
|
# Default Tk window size
|
|
104
162
|
DEFAULT_TK_WINDOW_SIZE_X = 800
|
|
105
|
-
DEFAULT_TK_WINDOW_SIZE_Y =
|
|
163
|
+
DEFAULT_TK_WINDOW_SIZE_Y = 800
|
|
106
164
|
|
|
107
165
|
# Default font settings
|
|
108
166
|
DEFAULT_FONT_FAMILY = "Helvetica"
|
|
@@ -20,7 +20,7 @@ except ModuleNotFoundError as e:
|
|
|
20
20
|
import numpy as np
|
|
21
21
|
from rich import print
|
|
22
22
|
from scipy import ndimage
|
|
23
|
-
from tqdm.
|
|
23
|
+
from tqdm.auto import tqdm
|
|
24
24
|
|
|
25
25
|
from .dilatemask import dilatemask
|
|
26
26
|
from .interpolation_x import interpolation_x
|
|
@@ -35,6 +35,8 @@ class InterpolationEditor:
|
|
|
35
35
|
last_maskfill_verbose,
|
|
36
36
|
auxdata,
|
|
37
37
|
cleandata_lacosmic,
|
|
38
|
+
cleandata_pycosmic,
|
|
39
|
+
cleandata_deepcr,
|
|
38
40
|
xmin,
|
|
39
41
|
xmax,
|
|
40
42
|
ymin,
|
|
@@ -65,6 +67,10 @@ class InterpolationEditor:
|
|
|
65
67
|
Auxiliary data for cleaning, if available.
|
|
66
68
|
cleandata_lacosmic : array-like or None
|
|
67
69
|
Cleaned data from L.A.Cosmic, if available.
|
|
70
|
+
cleandata_pycosmic : array-like or None
|
|
71
|
+
Cleaned data from PyCosmic, if available.
|
|
72
|
+
cleandata_deepcr : array-like or None
|
|
73
|
+
Cleaned data from DeepCR, if available.
|
|
68
74
|
xmin : float
|
|
69
75
|
Minimum x value of the data. From 1 to NAXIS1.
|
|
70
76
|
xmax : float
|
|
@@ -97,6 +103,10 @@ class InterpolationEditor:
|
|
|
97
103
|
Auxiliary data for cleaning, if available.
|
|
98
104
|
cleandata_lacosmic : array-like or None
|
|
99
105
|
Cleaned data from L.A.Cosmic, if available.
|
|
106
|
+
cleandata_pycosmic : array-like or None
|
|
107
|
+
Cleaned data from PyCosmic, if available.
|
|
108
|
+
cleandata_deepcr : array-like or None
|
|
109
|
+
Cleaned data from DeepCR, if available.
|
|
100
110
|
dict_interp_methods : dict
|
|
101
111
|
Mapping of interpolation method names to their codes.
|
|
102
112
|
cleaning_method : str or None
|
|
@@ -127,6 +137,8 @@ class InterpolationEditor:
|
|
|
127
137
|
self.last_dilation = last_dilation
|
|
128
138
|
self.auxdata = auxdata
|
|
129
139
|
self.cleandata_lacosmic = cleandata_lacosmic
|
|
140
|
+
self.cleandata_pycosmic = cleandata_pycosmic
|
|
141
|
+
self.cleandata_deepcr = cleandata_deepcr
|
|
130
142
|
# Initialize parameters
|
|
131
143
|
self.cleaning_method = None
|
|
132
144
|
self.npoints = last_npoints
|
|
@@ -169,13 +181,22 @@ class InterpolationEditor:
|
|
|
169
181
|
for interp_method in VALID_CLEANING_METHODS.keys():
|
|
170
182
|
state = "normal"
|
|
171
183
|
# Skip replace by L.A.Cosmic values if last dilation is not zero
|
|
184
|
+
# or cleandata_lacosmic is not available
|
|
172
185
|
if interp_method == "lacosmic":
|
|
173
186
|
if self.last_dilation != 0:
|
|
174
187
|
state = "disabled"
|
|
175
188
|
if self.cleandata_lacosmic is None:
|
|
176
189
|
state = "disabled"
|
|
190
|
+
# Skip replace by PyCosmic values if cleandata_pycosmic is not available
|
|
191
|
+
elif interp_method == "pycosmic":
|
|
192
|
+
if self.cleandata_pycosmic is None:
|
|
193
|
+
state = "disabled"
|
|
194
|
+
# Skip replace by DeepCR values if cleandata_deepcr is not available
|
|
195
|
+
elif interp_method == "deepcr":
|
|
196
|
+
if self.cleandata_deepcr is None:
|
|
197
|
+
state = "disabled"
|
|
177
198
|
# Skip auxdata method if auxdata is not available
|
|
178
|
-
|
|
199
|
+
elif interp_method == "auxdata" and self.auxdata is None:
|
|
179
200
|
state = "disabled"
|
|
180
201
|
tk.Radiobutton(
|
|
181
202
|
main_frame,
|
|
@@ -454,14 +475,7 @@ class InterpolationEditor:
|
|
|
454
475
|
self.entry_maskfill_operator.config(state="disabled")
|
|
455
476
|
self.entry_maskfill_smooth.config(state="disabled")
|
|
456
477
|
self.entry_maskfill_verbose.config(state="disabled")
|
|
457
|
-
elif selected_method
|
|
458
|
-
self.entry_npoints.config(state="disabled")
|
|
459
|
-
self.entry_degree.config(state="disabled")
|
|
460
|
-
self.entry_maskfill_size.config(state="disabled")
|
|
461
|
-
self.entry_maskfill_operator.config(state="disabled")
|
|
462
|
-
self.entry_maskfill_smooth.config(state="disabled")
|
|
463
|
-
self.entry_maskfill_verbose.config(state="disabled")
|
|
464
|
-
elif selected_method == "auxdata":
|
|
478
|
+
elif selected_method in ["lacosmic", "pycosmic", "deepcr", "auxdata"]:
|
|
465
479
|
self.entry_npoints.config(state="disabled")
|
|
466
480
|
self.entry_degree.config(state="disabled")
|
|
467
481
|
self.entry_maskfill_size.config(state="disabled")
|
|
@@ -17,6 +17,7 @@ except ModuleNotFoundError as e:
|
|
|
17
17
|
"Please install teareduce with the 'cleanest' extra dependencies: "
|
|
18
18
|
"`pip install teareduce[cleanest]`."
|
|
19
19
|
) from e
|
|
20
|
+
from importlib.metadata import version
|
|
20
21
|
import numpy as np
|
|
21
22
|
from rich import print
|
|
22
23
|
|
|
@@ -24,7 +25,7 @@ from .definitions import VALID_LACOSMIC_PSFMODEL_VALUES
|
|
|
24
25
|
from .gausskernel2d_elliptical import gausskernel2d_elliptical
|
|
25
26
|
|
|
26
27
|
|
|
27
|
-
def lacosmicpad(pad_width, show_arguments=False, **kwargs):
|
|
28
|
+
def lacosmicpad(pad_width, show_arguments=False, display_ccdproc_version=True, **kwargs):
|
|
28
29
|
"""Execute LACosmic algorithm on a padded array.
|
|
29
30
|
|
|
30
31
|
This function pads the input image array before applying the LACosmic
|
|
@@ -46,6 +47,8 @@ def lacosmicpad(pad_width, show_arguments=False, **kwargs):
|
|
|
46
47
|
the LACosmic algorithm.
|
|
47
48
|
show_arguments : bool
|
|
48
49
|
If True, display LACosmic arguments being employed.
|
|
50
|
+
display_ccdproc_version : bool
|
|
51
|
+
If True, display the version of the ccdproc package being used.
|
|
49
52
|
**kwargs : dict
|
|
50
53
|
Keyword arguments to be passed to the `cosmicray_lacosmic` function.
|
|
51
54
|
|
|
@@ -145,13 +148,29 @@ def lacosmicpad(pad_width, show_arguments=False, **kwargs):
|
|
|
145
148
|
else:
|
|
146
149
|
raise ValueError("The 'fsmode' keyword argument must be either 'convolve' or 'median'.")
|
|
147
150
|
|
|
151
|
+
# Apply LACosmic algorithm to the padded array
|
|
152
|
+
try:
|
|
153
|
+
version_ccdproc = version("ccdproc")
|
|
154
|
+
except Exception:
|
|
155
|
+
version_ccdproc = "unknown"
|
|
156
|
+
if display_ccdproc_version:
|
|
157
|
+
print(f"Running L.A.Cosmic implementation from ccdproc version {version_ccdproc}")
|
|
158
|
+
if kwargs["verbose"] or show_arguments:
|
|
159
|
+
end = "\n"
|
|
160
|
+
else:
|
|
161
|
+
end = ""
|
|
162
|
+
print("(please wait...) ", end=end)
|
|
148
163
|
# Show LACosmic arguments if requested
|
|
149
164
|
if show_arguments:
|
|
150
165
|
for key, value in kwargs.items():
|
|
151
166
|
print(f"LACosmic parameter: {key} = {value}")
|
|
152
|
-
# Apply LACosmic algorithm to the padded array
|
|
153
167
|
cleaned_padded_array, mask_padded_array = cosmicray_lacosmic(ccd=padded_array, **kwargs)
|
|
168
|
+
print(f"Done!")
|
|
154
169
|
# Remove padding
|
|
155
|
-
|
|
156
|
-
|
|
170
|
+
if pad_width == 0:
|
|
171
|
+
cleaned_array = cleaned_padded_array
|
|
172
|
+
mask_array = mask_padded_array
|
|
173
|
+
else:
|
|
174
|
+
cleaned_array = cleaned_padded_array[pad_width:-pad_width, pad_width:-pad_width]
|
|
175
|
+
mask_array = mask_padded_array[pad_width:-pad_width, pad_width:-pad_width]
|
|
157
176
|
return cleaned_array, mask_array
|