teareduce 0.5.7__tar.gz → 0.5.9__tar.gz
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-0.5.7/src/teareduce.egg-info → teareduce-0.5.9}/PKG-INFO +17 -4
- {teareduce-0.5.7 → teareduce-0.5.9}/README.md +12 -1
- {teareduce-0.5.7 → teareduce-0.5.9}/pyproject.toml +9 -3
- teareduce-0.5.9/src/teareduce/cleanest/__init__.py +19 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/__main__.py +0 -1
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/cosmicraycleanerapp.py +23 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/definitions.py +1 -1
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/interpolationeditor.py +1 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/lacosmicpad.py +8 -1
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/reviewcosmicray.py +70 -54
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/version.py +1 -1
- {teareduce-0.5.7 → teareduce-0.5.9/src/teareduce.egg-info}/PKG-INFO +17 -4
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce.egg-info/requires.txt +5 -2
- teareduce-0.5.7/src/teareduce/cleanest/__init__.py +0 -12
- {teareduce-0.5.7 → teareduce-0.5.9}/LICENSE.txt +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/setup.cfg +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/__init__.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/avoid_astropy_warnings.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/centerchildparent.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/dilatemask.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/find_closest_true.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/imagedisplay.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/interpolate.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/interpolation_a.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/interpolation_x.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/interpolation_y.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/mergemasks.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/modalprogressbar.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cleanest/parametereditor.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cookbook/__init__.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cookbook/get_cookbook_file.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/correct_pincushion_distortion.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/cosmicrays.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/ctext.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/draw_rectangle.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/elapsed_time.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/histogram1d.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/imshow.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/numsplines.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/peaks_spectrum.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/polfit.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/robust_std.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/sdistortion.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/simulateccdexposure.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/sliceregion.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/statsummary.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/tests/__init__.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/tests/test_cleanest.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/tests/test_sliceregion.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/tests/test_version.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/wavecal.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/write_array_to_fits.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce/zscale.py +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce.egg-info/SOURCES.txt +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce.egg-info/dependency_links.txt +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce.egg-info/entry_points.txt +0 -0
- {teareduce-0.5.7 → teareduce-0.5.9}/src/teareduce.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: teareduce
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.9
|
|
4
4
|
Summary: Utilities for astronomical data reduction
|
|
5
5
|
Author-email: Nicolás Cardiel <cardiel@ucm.es>
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -20,15 +20,17 @@ Requires-Python: >=3.10
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE.txt
|
|
22
22
|
Requires-Dist: astropy
|
|
23
|
-
Requires-Dist: ccdproc
|
|
24
23
|
Requires-Dist: lmfit
|
|
25
24
|
Requires-Dist: matplotlib
|
|
26
|
-
Requires-Dist: numpy>=
|
|
25
|
+
Requires-Dist: numpy>=2
|
|
27
26
|
Requires-Dist: requests
|
|
28
27
|
Requires-Dist: rich
|
|
29
28
|
Requires-Dist: rich-argparse
|
|
30
29
|
Requires-Dist: scipy
|
|
31
30
|
Requires-Dist: tqdm
|
|
31
|
+
Provides-Extra: cleanest
|
|
32
|
+
Requires-Dist: ccdproc; extra == "cleanest"
|
|
33
|
+
Requires-Dist: maskfill; extra == "cleanest"
|
|
32
34
|
Provides-Extra: test
|
|
33
35
|
Requires-Dist: pytest; extra == "test"
|
|
34
36
|
Dynamic: license-file
|
|
@@ -66,6 +68,13 @@ $ . venv_teareduce/bin/activate
|
|
|
66
68
|
(venv_teareduce) $
|
|
67
69
|
```
|
|
68
70
|
|
|
71
|
+
If you are planning to use **tea-cleanest**, you need to install this package
|
|
72
|
+
with extra dependencies. In this case employ:
|
|
73
|
+
|
|
74
|
+
```shell
|
|
75
|
+
(venv_teareduce) $ pip install 'teareduce[cleanest]'
|
|
76
|
+
```
|
|
77
|
+
|
|
69
78
|
### Installing the package
|
|
70
79
|
|
|
71
80
|
The latest stable version is available via de [PyPI repository](https://pypi.org/project/teareduce/):
|
|
@@ -93,6 +102,10 @@ The latest development version is available through [GitHub](https://github.com/
|
|
|
93
102
|
(venv_teareduce) $ ipython
|
|
94
103
|
In [1]: import teareduce as tea
|
|
95
104
|
In [2]: print(tea.__version__)
|
|
96
|
-
0.
|
|
105
|
+
0.5.9
|
|
97
106
|
```
|
|
98
107
|
|
|
108
|
+
Note that in PyPI there is a package called **tea** that provides utilities
|
|
109
|
+
unrelated to **teareduce**. However, throughout the examples described
|
|
110
|
+
in the documentation we are making use of ``import teareduce as tea``
|
|
111
|
+
to define a convenient alias.
|
|
@@ -31,6 +31,13 @@ $ . venv_teareduce/bin/activate
|
|
|
31
31
|
(venv_teareduce) $
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
If you are planning to use **tea-cleanest**, you need to install this package
|
|
35
|
+
with extra dependencies. In this case employ:
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
(venv_teareduce) $ pip install 'teareduce[cleanest]'
|
|
39
|
+
```
|
|
40
|
+
|
|
34
41
|
### Installing the package
|
|
35
42
|
|
|
36
43
|
The latest stable version is available via de [PyPI repository](https://pypi.org/project/teareduce/):
|
|
@@ -58,6 +65,10 @@ The latest development version is available through [GitHub](https://github.com/
|
|
|
58
65
|
(venv_teareduce) $ ipython
|
|
59
66
|
In [1]: import teareduce as tea
|
|
60
67
|
In [2]: print(tea.__version__)
|
|
61
|
-
0.
|
|
68
|
+
0.5.9
|
|
62
69
|
```
|
|
63
70
|
|
|
71
|
+
Note that in PyPI there is a package called **tea** that provides utilities
|
|
72
|
+
unrelated to **teareduce**. However, throughout the examples described
|
|
73
|
+
in the documentation we are making use of ``import teareduce as tea``
|
|
74
|
+
to define a convenient alias.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Minimum requirements for the build system to execute.
|
|
3
3
|
# (include packages imported in the different modules; otherwise
|
|
4
4
|
# a ModuleNotFoundError is raised when using $ pip install -e .)
|
|
5
|
-
requires = ["setuptools >= 61.0.0"]
|
|
5
|
+
requires = ["setuptools >= 61.0.0", "wheel"]
|
|
6
6
|
build-backend = "setuptools.build_meta"
|
|
7
7
|
|
|
8
8
|
[project]
|
|
@@ -28,12 +28,12 @@ classifiers = [
|
|
|
28
28
|
"Topic :: Scientific/Engineering :: Astronomy",
|
|
29
29
|
]
|
|
30
30
|
|
|
31
|
+
# Core dependencies (always installed)
|
|
31
32
|
dependencies = [
|
|
32
33
|
"astropy",
|
|
33
|
-
"ccdproc",
|
|
34
34
|
"lmfit",
|
|
35
35
|
"matplotlib",
|
|
36
|
-
"numpy >=
|
|
36
|
+
"numpy >= 2",
|
|
37
37
|
"requests",
|
|
38
38
|
"rich",
|
|
39
39
|
"rich-argparse",
|
|
@@ -42,6 +42,12 @@ dependencies = [
|
|
|
42
42
|
]
|
|
43
43
|
|
|
44
44
|
[project.optional-dependencies]
|
|
45
|
+
# Version with dependencies needed to run the tea-cleanest script
|
|
46
|
+
cleanest = [
|
|
47
|
+
"ccdproc",
|
|
48
|
+
"maskfill",
|
|
49
|
+
]
|
|
50
|
+
|
|
45
51
|
test = [
|
|
46
52
|
"pytest",
|
|
47
53
|
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2023-2025 Universidad Complutense de Madrid
|
|
3
|
+
#
|
|
4
|
+
# This file is part of teareduce
|
|
5
|
+
#
|
|
6
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
7
|
+
# License-Filename: LICENSE.txt
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
"""Module providing functions for cleaning astronomical images.
|
|
11
|
+
Includes functions for interpolating over bad pixels,
|
|
12
|
+
applying the L.A.Cosmic algorithm to detect cosmic ray pixels.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from .interpolate import interpolate
|
|
16
|
+
from .lacosmicpad import lacosmicpad
|
|
17
|
+
from .mergemasks import merge_peak_tail_masks
|
|
18
|
+
|
|
19
|
+
__all__ = ['interpolate', 'lacosmicpad', 'merge_peak_tail_masks']
|
|
@@ -17,6 +17,14 @@ from tkinter import simpledialog
|
|
|
17
17
|
import sys
|
|
18
18
|
|
|
19
19
|
from astropy.io import fits
|
|
20
|
+
try:
|
|
21
|
+
from maskfill import maskfill
|
|
22
|
+
except ModuleNotFoundError as e:
|
|
23
|
+
raise ModuleNotFoundError(
|
|
24
|
+
"The 'teareduce.cleanest' module requires the 'ccdproc' and 'maskfill' packages. "
|
|
25
|
+
"Please install teareduce with the 'cleanest' extra dependencies: "
|
|
26
|
+
"`pip install teareduce[cleanest]`."
|
|
27
|
+
) from e
|
|
20
28
|
import matplotlib.pyplot as plt
|
|
21
29
|
from matplotlib.backend_bases import key_press_handler
|
|
22
30
|
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
|
|
@@ -773,6 +781,21 @@ class CosmicRayCleanerApp(ImageDisplay):
|
|
|
773
781
|
# upate mask_crfound by eliminating the cleaned pixels
|
|
774
782
|
self.mask_crfound[mask_crfound_region] = False
|
|
775
783
|
data_has_been_modified = True
|
|
784
|
+
elif cleaning_method == "maskfill":
|
|
785
|
+
# Replace detected CR pixels with local median values
|
|
786
|
+
smoothed_output, _ = maskfill(
|
|
787
|
+
input_image=self.data,
|
|
788
|
+
mask=mask_crfound_region,
|
|
789
|
+
size=3,
|
|
790
|
+
operator="median",
|
|
791
|
+
smooth=True,
|
|
792
|
+
)
|
|
793
|
+
self.data[mask_crfound_region] = smoothed_output[mask_crfound_region]
|
|
794
|
+
# update mask_fixed to include the newly fixed pixels
|
|
795
|
+
self.mask_fixed[mask_crfound_region] = True
|
|
796
|
+
# upate mask_crfound by eliminating the cleaned pixels
|
|
797
|
+
self.mask_crfound[mask_crfound_region] = False
|
|
798
|
+
data_has_been_modified = True
|
|
776
799
|
elif cleaning_method == "auxdata":
|
|
777
800
|
if self.auxdata is None:
|
|
778
801
|
print("No auxiliary data available. Cleaning skipped!")
|
|
@@ -43,7 +43,7 @@ lacosmic_default_dict = {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
# Default parameters for cleaning methods
|
|
46
|
-
VALID_CLEANING_METHODS = ["x interp.", "y interp.", "surface interp.", "median", "mean", "lacosmic", "auxdata"]
|
|
46
|
+
VALID_CLEANING_METHODS = ["x interp.", "y interp.", "surface interp.", "median", "mean", "lacosmic", "maskfill", "auxdata"]
|
|
47
47
|
|
|
48
48
|
# Maximum pixel distance to consider when finding closest CR pixel
|
|
49
49
|
MAX_PIXEL_DISTANCE_TO_CR = 15
|
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
"""Execute LACosmic algorithm on a padded image."""
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
try:
|
|
13
|
+
from ccdproc import cosmicray_lacosmic
|
|
14
|
+
except ModuleNotFoundError as e:
|
|
15
|
+
raise ModuleNotFoundError(
|
|
16
|
+
"The 'teareduce.cleanest' module requires the 'ccdproc' and 'maskfill' packages. "
|
|
17
|
+
"Please install teareduce with the 'cleanest' extra dependencies: "
|
|
18
|
+
"`pip install teareduce[cleanest]`."
|
|
19
|
+
) from e
|
|
13
20
|
import numpy as np
|
|
14
21
|
|
|
15
22
|
|
|
@@ -13,6 +13,14 @@ import tkinter as tk
|
|
|
13
13
|
from tkinter import messagebox
|
|
14
14
|
from tkinter import simpledialog
|
|
15
15
|
|
|
16
|
+
try:
|
|
17
|
+
from maskfill import maskfill
|
|
18
|
+
except ModuleNotFoundError as e:
|
|
19
|
+
raise ModuleNotFoundError(
|
|
20
|
+
"The 'teareduce.cleanest' module requires the 'ccdproc' and 'maskfill' packages. "
|
|
21
|
+
"Please install teareduce with the 'cleanest' extra dependencies: "
|
|
22
|
+
"`pip install teareduce[cleanest]`."
|
|
23
|
+
) from e
|
|
16
24
|
import matplotlib.pyplot as plt
|
|
17
25
|
from matplotlib.backend_bases import key_press_handler
|
|
18
26
|
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
|
|
@@ -150,7 +158,7 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
150
158
|
self.root.minsize(1000, 700)
|
|
151
159
|
else:
|
|
152
160
|
# self.root.geometry("800x700+100+100") # This does not work in Fedora
|
|
153
|
-
self.root.minsize(
|
|
161
|
+
self.root.minsize(900, 700)
|
|
154
162
|
self.root.update_idletasks()
|
|
155
163
|
self.root.geometry("+100+100")
|
|
156
164
|
self.data = data
|
|
@@ -224,6 +232,8 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
224
232
|
self.interp_l_button.config(state=tk.DISABLED)
|
|
225
233
|
if self.cleandata_lacosmic is None:
|
|
226
234
|
self.interp_l_button.config(state=tk.DISABLED)
|
|
235
|
+
self.interp_maskfill_button = tk.Button(self.button_frame2, text="mas[k]fill", command=self.use_maskfill)
|
|
236
|
+
self.interp_maskfill_button.pack(side=tk.LEFT, padx=5)
|
|
227
237
|
self.interp_aux_button = tk.Button(self.button_frame2, text="[a]ux. data", command=self.use_auxdata)
|
|
228
238
|
self.interp_aux_button.pack(side=tk.LEFT, padx=5)
|
|
229
239
|
if self.auxdata is None:
|
|
@@ -246,7 +256,7 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
246
256
|
if self.auxdata is not None:
|
|
247
257
|
self.fig, (self.ax_aux, self.ax) = plt.subplots(ncols=2, figsize=(11, 5.5), constrained_layout=True)
|
|
248
258
|
else:
|
|
249
|
-
self.fig, self.ax = plt.subplots(figsize=(
|
|
259
|
+
self.fig, self.ax = plt.subplots(figsize=(9, 5.5), constrained_layout=True)
|
|
250
260
|
self.canvas = FigureCanvasTkAgg(self.fig, master=self.root)
|
|
251
261
|
self.canvas.get_tk_widget().pack(padx=5, pady=5)
|
|
252
262
|
# The next two instructions prevent a segmentation fault when pressing "q"
|
|
@@ -368,15 +378,9 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
368
378
|
|
|
369
379
|
def set_buttons_after_cleaning_cr(self):
|
|
370
380
|
"""Set the state of buttons after cleaning a cosmic ray."""
|
|
381
|
+
self.disable_interpolation_buttons()
|
|
371
382
|
self.restore_cr_button.config(state=tk.NORMAL)
|
|
372
383
|
self.remove_crosses_button.config(state=tk.DISABLED)
|
|
373
|
-
self.interp_x_button.config(state=tk.DISABLED)
|
|
374
|
-
self.interp_y_button.config(state=tk.DISABLED)
|
|
375
|
-
self.interp_s_button.config(state=tk.DISABLED)
|
|
376
|
-
self.interp_d_button.config(state=tk.DISABLED)
|
|
377
|
-
self.interp_m_button.config(state=tk.DISABLED)
|
|
378
|
-
self.interp_l_button.config(state=tk.DISABLED)
|
|
379
|
-
self.interp_aux_button.config(state=tk.DISABLED)
|
|
380
384
|
|
|
381
385
|
def interp_x(self):
|
|
382
386
|
"""Perform x-direction interpolation to clean a cosmic ray."""
|
|
@@ -461,6 +465,27 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
461
465
|
self.set_buttons_after_cleaning_cr()
|
|
462
466
|
self.update_display(cleaned=True)
|
|
463
467
|
|
|
468
|
+
def use_maskfill(self):
|
|
469
|
+
"""Use maskfill cleaned data to clean a cosmic ray."""
|
|
470
|
+
print(f"Maskfill interpolation of cosmic ray {self.cr_index}")
|
|
471
|
+
ycr_list, xcr_list = np.where(self.cr_labels == self.cr_index)
|
|
472
|
+
mask = np.zeros(self.data.shape, dtype=bool)
|
|
473
|
+
for iy, ix in zip(ycr_list, xcr_list):
|
|
474
|
+
mask[iy, ix] = True
|
|
475
|
+
smoothed_output, _ = maskfill(
|
|
476
|
+
input_image=self.data,
|
|
477
|
+
mask=mask,
|
|
478
|
+
size=3,
|
|
479
|
+
operator="median",
|
|
480
|
+
smooth=True,
|
|
481
|
+
)
|
|
482
|
+
for iy, ix in zip(ycr_list, xcr_list):
|
|
483
|
+
self.data[iy, ix] = smoothed_output[iy, ix]
|
|
484
|
+
self.mask_fixed[iy, ix] = True
|
|
485
|
+
self.num_cr_cleaned += 1
|
|
486
|
+
self.set_buttons_after_cleaning_cr()
|
|
487
|
+
self.update_display(cleaned=True)
|
|
488
|
+
|
|
464
489
|
def use_auxdata(self):
|
|
465
490
|
"""Use auxiliary data to clean a cosmic ray."""
|
|
466
491
|
if self.auxdata is None:
|
|
@@ -481,34 +506,21 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
481
506
|
for iy, ix in zip(ycr_list, xcr_list):
|
|
482
507
|
self.cr_labels[iy, ix] = 0
|
|
483
508
|
print(f"Removed all pixels of cosmic ray {self.cr_index}")
|
|
484
|
-
self.
|
|
485
|
-
self.interp_x_button.config(state=tk.DISABLED)
|
|
486
|
-
self.interp_y_button.config(state=tk.DISABLED)
|
|
487
|
-
self.interp_s_button.config(state=tk.DISABLED)
|
|
488
|
-
self.interp_d_button.config(state=tk.DISABLED)
|
|
489
|
-
self.interp_m_button.config(state=tk.DISABLED)
|
|
490
|
-
self.interp_l_button.config(state=tk.DISABLED)
|
|
491
|
-
self.interp_aux_button.config(state=tk.DISABLED)
|
|
509
|
+
self.disable_interpolation_buttons()
|
|
492
510
|
self.update_display()
|
|
493
511
|
|
|
494
512
|
def restore_cr(self):
|
|
495
513
|
"""Restore all pixels of the current cosmic ray to their original values."""
|
|
496
514
|
ycr_list, xcr_list = np.where(self.cr_labels == self.cr_index)
|
|
515
|
+
if len(xcr_list) == 0:
|
|
516
|
+
print(f"No pixels to restore for cosmic ray {self.cr_index}")
|
|
517
|
+
return
|
|
497
518
|
for iy, ix in zip(ycr_list, xcr_list):
|
|
498
519
|
self.data[iy, ix] = self.data_original[iy, ix]
|
|
499
520
|
self.mask_fixed[iy, ix] = False
|
|
500
|
-
self.interp_x_button.config(state=tk.NORMAL)
|
|
501
|
-
self.interp_y_button.config(state=tk.NORMAL)
|
|
502
|
-
self.interp_s_button.config(state=tk.NORMAL)
|
|
503
|
-
self.interp_d_button.config(state=tk.NORMAL)
|
|
504
|
-
self.interp_m_button.config(state=tk.NORMAL)
|
|
505
|
-
if self.cleandata_lacosmic is not None:
|
|
506
|
-
if self.last_dilation is None or self.last_dilation == 0:
|
|
507
|
-
self.interp_l_button.config(state=tk.NORMAL)
|
|
508
|
-
if self.auxdata is not None:
|
|
509
|
-
self.interp_aux_button.config(state=tk.NORMAL)
|
|
510
521
|
print(f"Restored all pixels of cosmic ray {self.cr_index}")
|
|
511
522
|
self.num_cr_cleaned -= 1
|
|
523
|
+
self.enable_interpolation_buttons()
|
|
512
524
|
self.remove_crosses_button.config(state=tk.NORMAL)
|
|
513
525
|
self.restore_cr_button.config(state=tk.DISABLED)
|
|
514
526
|
self.update_display()
|
|
@@ -524,16 +536,7 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
524
536
|
return # important: do not remove (to avoid errors)
|
|
525
537
|
self.first_plot = True
|
|
526
538
|
self.restore_cr_button.config(state=tk.DISABLED)
|
|
527
|
-
self.
|
|
528
|
-
self.interp_y_button.config(state=tk.NORMAL)
|
|
529
|
-
self.interp_s_button.config(state=tk.NORMAL)
|
|
530
|
-
self.interp_d_button.config(state=tk.NORMAL)
|
|
531
|
-
self.interp_m_button.config(state=tk.NORMAL)
|
|
532
|
-
if self.cleandata_lacosmic is not None:
|
|
533
|
-
if self.last_dilation is None or self.last_dilation == 0:
|
|
534
|
-
self.interp_l_button.config(state=tk.NORMAL)
|
|
535
|
-
if self.auxdata is not None:
|
|
536
|
-
self.interp_aux_button.config(state=tk.NORMAL)
|
|
539
|
+
self.enable_interpolation_buttons()
|
|
537
540
|
self.remove_crosses_button.config(state=tk.NORMAL)
|
|
538
541
|
self.update_display()
|
|
539
542
|
|
|
@@ -566,6 +569,9 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
566
569
|
elif event.key == "l":
|
|
567
570
|
if self.interp_l_button.cget("state") != "disabled":
|
|
568
571
|
self.use_lacosmic()
|
|
572
|
+
elif event.key == "k":
|
|
573
|
+
if self.interp_maskfill_button.cget("state") != "disabled":
|
|
574
|
+
self.use_maskfill()
|
|
569
575
|
elif event.key == "a":
|
|
570
576
|
if self.interp_aux_button.cget("state") != "disabled":
|
|
571
577
|
self.use_auxdata()
|
|
@@ -595,25 +601,35 @@ class ReviewCosmicRay(ImageDisplay):
|
|
|
595
601
|
print(f"Pixel ({ix+1}, {iy+1}), with signal {self.data[iy, ix]}, marked as cosmic ray.")
|
|
596
602
|
xcr_list, ycr_list = np.where(self.cr_labels == self.cr_index)
|
|
597
603
|
if len(xcr_list) == 0:
|
|
598
|
-
self.
|
|
599
|
-
self.interp_y_button.config(state=tk.DISABLED)
|
|
600
|
-
self.interp_s_button.config(state=tk.DISABLED)
|
|
601
|
-
self.interp_d_button.config(state=tk.DISABLED)
|
|
602
|
-
self.interp_m_button.config(state=tk.DISABLED)
|
|
603
|
-
self.interp_l_button.config(state=tk.DISABLED)
|
|
604
|
-
self.interp_aux_button.config(state=tk.DISABLED)
|
|
604
|
+
self.disable_interpolation_buttons()
|
|
605
605
|
self.remove_crosses_button.config(state=tk.DISABLED)
|
|
606
606
|
else:
|
|
607
|
-
self.
|
|
608
|
-
self.interp_y_button.config(state=tk.NORMAL)
|
|
609
|
-
self.interp_s_button.config(state=tk.NORMAL)
|
|
610
|
-
self.interp_d_button.config(state=tk.NORMAL)
|
|
611
|
-
self.interp_m_button.config(state=tk.NORMAL)
|
|
612
|
-
if self.cleandata_lacosmic is not None:
|
|
613
|
-
if self.last_dilation is None or self.last_dilation == 0:
|
|
614
|
-
self.interp_l_button.config(state=tk.NORMAL)
|
|
615
|
-
if self.auxdata is not None:
|
|
616
|
-
self.interp_aux_button.config(state=tk.NORMAL)
|
|
607
|
+
self.enable_interpolation_buttons()
|
|
617
608
|
self.remove_crosses_button.config(state=tk.NORMAL)
|
|
618
609
|
# Update the display to reflect the change
|
|
619
610
|
self.update_display()
|
|
611
|
+
|
|
612
|
+
def disable_interpolation_buttons(self):
|
|
613
|
+
"""Disable all interpolation buttons."""
|
|
614
|
+
self.interp_x_button.config(state=tk.DISABLED)
|
|
615
|
+
self.interp_y_button.config(state=tk.DISABLED)
|
|
616
|
+
self.interp_s_button.config(state=tk.DISABLED)
|
|
617
|
+
self.interp_d_button.config(state=tk.DISABLED)
|
|
618
|
+
self.interp_m_button.config(state=tk.DISABLED)
|
|
619
|
+
self.interp_l_button.config(state=tk.DISABLED)
|
|
620
|
+
self.interp_maskfill_button.config(state=tk.DISABLED)
|
|
621
|
+
self.interp_aux_button.config(state=tk.DISABLED)
|
|
622
|
+
|
|
623
|
+
def enable_interpolation_buttons(self):
|
|
624
|
+
"""Enable all interpolation buttons."""
|
|
625
|
+
self.interp_x_button.config(state=tk.NORMAL)
|
|
626
|
+
self.interp_y_button.config(state=tk.NORMAL)
|
|
627
|
+
self.interp_s_button.config(state=tk.NORMAL)
|
|
628
|
+
self.interp_d_button.config(state=tk.NORMAL)
|
|
629
|
+
self.interp_m_button.config(state=tk.NORMAL)
|
|
630
|
+
if self.cleandata_lacosmic is not None:
|
|
631
|
+
if self.last_dilation is None or self.last_dilation == 0:
|
|
632
|
+
self.interp_l_button.config(state=tk.NORMAL)
|
|
633
|
+
self.interp_maskfill_button.config(state=tk.NORMAL)
|
|
634
|
+
if self.auxdata is not None:
|
|
635
|
+
self.interp_aux_button.config(state=tk.NORMAL)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: teareduce
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.9
|
|
4
4
|
Summary: Utilities for astronomical data reduction
|
|
5
5
|
Author-email: Nicolás Cardiel <cardiel@ucm.es>
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -20,15 +20,17 @@ Requires-Python: >=3.10
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE.txt
|
|
22
22
|
Requires-Dist: astropy
|
|
23
|
-
Requires-Dist: ccdproc
|
|
24
23
|
Requires-Dist: lmfit
|
|
25
24
|
Requires-Dist: matplotlib
|
|
26
|
-
Requires-Dist: numpy>=
|
|
25
|
+
Requires-Dist: numpy>=2
|
|
27
26
|
Requires-Dist: requests
|
|
28
27
|
Requires-Dist: rich
|
|
29
28
|
Requires-Dist: rich-argparse
|
|
30
29
|
Requires-Dist: scipy
|
|
31
30
|
Requires-Dist: tqdm
|
|
31
|
+
Provides-Extra: cleanest
|
|
32
|
+
Requires-Dist: ccdproc; extra == "cleanest"
|
|
33
|
+
Requires-Dist: maskfill; extra == "cleanest"
|
|
32
34
|
Provides-Extra: test
|
|
33
35
|
Requires-Dist: pytest; extra == "test"
|
|
34
36
|
Dynamic: license-file
|
|
@@ -66,6 +68,13 @@ $ . venv_teareduce/bin/activate
|
|
|
66
68
|
(venv_teareduce) $
|
|
67
69
|
```
|
|
68
70
|
|
|
71
|
+
If you are planning to use **tea-cleanest**, you need to install this package
|
|
72
|
+
with extra dependencies. In this case employ:
|
|
73
|
+
|
|
74
|
+
```shell
|
|
75
|
+
(venv_teareduce) $ pip install 'teareduce[cleanest]'
|
|
76
|
+
```
|
|
77
|
+
|
|
69
78
|
### Installing the package
|
|
70
79
|
|
|
71
80
|
The latest stable version is available via de [PyPI repository](https://pypi.org/project/teareduce/):
|
|
@@ -93,6 +102,10 @@ The latest development version is available through [GitHub](https://github.com/
|
|
|
93
102
|
(venv_teareduce) $ ipython
|
|
94
103
|
In [1]: import teareduce as tea
|
|
95
104
|
In [2]: print(tea.__version__)
|
|
96
|
-
0.
|
|
105
|
+
0.5.9
|
|
97
106
|
```
|
|
98
107
|
|
|
108
|
+
Note that in PyPI there is a package called **tea** that provides utilities
|
|
109
|
+
unrelated to **teareduce**. However, throughout the examples described
|
|
110
|
+
in the documentation we are making use of ``import teareduce as tea``
|
|
111
|
+
to define a convenient alias.
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Copyright 2023-2025 Universidad Complutense de Madrid
|
|
3
|
-
#
|
|
4
|
-
# This file is part of teareduce
|
|
5
|
-
#
|
|
6
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
7
|
-
# License-Filename: LICENSE.txt
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
from .interpolate import interpolate
|
|
11
|
-
from .lacosmicpad import lacosmicpad
|
|
12
|
-
from .mergemasks import merge_peak_tail_masks
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|