teareduce 0.5.8__tar.gz → 0.6.0__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.8/src/teareduce.egg-info → teareduce-0.6.0}/PKG-INFO +17 -5
- {teareduce-0.5.8 → teareduce-0.6.0}/README.md +12 -1
- {teareduce-0.5.8 → teareduce-0.6.0}/pyproject.toml +9 -4
- teareduce-0.6.0/src/teareduce/cleanest/__init__.py +19 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/__main__.py +11 -6
- teareduce-0.6.0/src/teareduce/cleanest/askextension.py +85 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/cosmicraycleanerapp.py +297 -65
- teareduce-0.6.0/src/teareduce/cleanest/definitions.py +109 -0
- teareduce-0.6.0/src/teareduce/cleanest/gausskernel2d_elliptical.py +54 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/interpolate.py +65 -48
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/interpolationeditor.py +196 -52
- teareduce-0.6.0/src/teareduce/cleanest/lacosmicpad.py +155 -0
- teareduce-0.6.0/src/teareduce/cleanest/parametereditor.py +557 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/reviewcosmicray.py +285 -83
- teareduce-0.6.0/src/teareduce/cleanest/trackedbutton.py +73 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/version.py +1 -1
- {teareduce-0.5.8 → teareduce-0.6.0/src/teareduce.egg-info}/PKG-INFO +17 -5
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce.egg-info/SOURCES.txt +3 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce.egg-info/requires.txt +5 -3
- teareduce-0.5.8/src/teareduce/cleanest/__init__.py +0 -12
- teareduce-0.5.8/src/teareduce/cleanest/definitions.py +0 -63
- teareduce-0.5.8/src/teareduce/cleanest/lacosmicpad.py +0 -57
- teareduce-0.5.8/src/teareduce/cleanest/parametereditor.py +0 -329
- {teareduce-0.5.8 → teareduce-0.6.0}/LICENSE.txt +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/setup.cfg +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/__init__.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/avoid_astropy_warnings.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/centerchildparent.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/dilatemask.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/find_closest_true.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/imagedisplay.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/interpolation_a.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/interpolation_x.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/interpolation_y.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/mergemasks.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cleanest/modalprogressbar.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cookbook/__init__.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cookbook/get_cookbook_file.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/correct_pincushion_distortion.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/cosmicrays.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/ctext.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/draw_rectangle.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/elapsed_time.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/histogram1d.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/imshow.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/numsplines.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/peaks_spectrum.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/polfit.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/robust_std.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/sdistortion.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/simulateccdexposure.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/sliceregion.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/statsummary.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/tests/__init__.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/tests/test_cleanest.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/tests/test_sliceregion.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/tests/test_version.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/wavecal.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/write_array_to_fits.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce/zscale.py +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce.egg-info/dependency_links.txt +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/src/teareduce.egg-info/entry_points.txt +0 -0
- {teareduce-0.5.8 → teareduce-0.6.0}/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.
|
|
3
|
+
Version: 0.6.0
|
|
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,16 +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:
|
|
27
|
-
Requires-Dist: numpy>=1.22
|
|
25
|
+
Requires-Dist: numpy>=2
|
|
28
26
|
Requires-Dist: requests
|
|
29
27
|
Requires-Dist: rich
|
|
30
28
|
Requires-Dist: rich-argparse
|
|
31
29
|
Requires-Dist: scipy
|
|
32
30
|
Requires-Dist: tqdm
|
|
31
|
+
Provides-Extra: cleanest
|
|
32
|
+
Requires-Dist: ccdproc; extra == "cleanest"
|
|
33
|
+
Requires-Dist: maskfill; extra == "cleanest"
|
|
33
34
|
Provides-Extra: test
|
|
34
35
|
Requires-Dist: pytest; extra == "test"
|
|
35
36
|
Dynamic: license-file
|
|
@@ -67,6 +68,13 @@ $ . venv_teareduce/bin/activate
|
|
|
67
68
|
(venv_teareduce) $
|
|
68
69
|
```
|
|
69
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
|
+
|
|
70
78
|
### Installing the package
|
|
71
79
|
|
|
72
80
|
The latest stable version is available via de [PyPI repository](https://pypi.org/project/teareduce/):
|
|
@@ -94,6 +102,10 @@ The latest development version is available through [GitHub](https://github.com/
|
|
|
94
102
|
(venv_teareduce) $ ipython
|
|
95
103
|
In [1]: import teareduce as tea
|
|
96
104
|
In [2]: print(tea.__version__)
|
|
97
|
-
0.
|
|
105
|
+
0.5.9
|
|
98
106
|
```
|
|
99
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,13 +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
|
-
"
|
|
37
|
-
"numpy >= 1.22",
|
|
36
|
+
"numpy >= 2",
|
|
38
37
|
"requests",
|
|
39
38
|
"rich",
|
|
40
39
|
"rich-argparse",
|
|
@@ -43,6 +42,12 @@ dependencies = [
|
|
|
43
42
|
]
|
|
44
43
|
|
|
45
44
|
[project.optional-dependencies]
|
|
45
|
+
# Version with dependencies needed to run the tea-cleanest script
|
|
46
|
+
cleanest = [
|
|
47
|
+
"ccdproc",
|
|
48
|
+
"maskfill",
|
|
49
|
+
]
|
|
50
|
+
|
|
46
51
|
test = [
|
|
47
52
|
"pytest",
|
|
48
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"]
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"""Interactive Cosmic Ray cleaning tool."""
|
|
11
11
|
|
|
12
12
|
import argparse
|
|
13
|
-
from ast import arg
|
|
14
13
|
import tkinter as tk
|
|
15
14
|
from tkinter import filedialog
|
|
16
15
|
from tkinter import simpledialog
|
|
@@ -93,10 +92,10 @@ def main():
|
|
|
93
92
|
exit(1)
|
|
94
93
|
print(f"Selected input FITS file: {args.input_fits}")
|
|
95
94
|
args.extension = simpledialog.askstring(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
"Select Extension",
|
|
96
|
+
f"\nEnter extension number or name for file:\n{Path(args.input_fits).name}",
|
|
97
|
+
initialvalue=args.extension,
|
|
98
|
+
)
|
|
100
99
|
# Ask for auxiliary file if not provided
|
|
101
100
|
if args.auxfile is None:
|
|
102
101
|
use_auxfile = tk.messagebox.askyesno(
|
|
@@ -133,7 +132,13 @@ def main():
|
|
|
133
132
|
exit(1)
|
|
134
133
|
|
|
135
134
|
# Initialize Tkinter root
|
|
136
|
-
|
|
135
|
+
try:
|
|
136
|
+
root = tk.Tk()
|
|
137
|
+
except tk.TclError as e:
|
|
138
|
+
print("Error: Unable to initialize Tkinter. Make sure a display is available.")
|
|
139
|
+
print("Detailed error message:")
|
|
140
|
+
print(e)
|
|
141
|
+
exit(1)
|
|
137
142
|
system = platform.system()
|
|
138
143
|
if system == "Darwin": # macOS
|
|
139
144
|
# Center the window on the screen
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2025 Universidad Complutense de Madrid
|
|
3
|
+
#
|
|
4
|
+
# This file is part of teareduce
|
|
5
|
+
#
|
|
6
|
+
# SPDX-License-Identifier: GPL-3.0+
|
|
7
|
+
# License-Filename: LICENSE.txt
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
"""Ask extension dialog for input FITS files."""
|
|
11
|
+
|
|
12
|
+
from astropy.io import fits
|
|
13
|
+
from tkinter import simpledialog, messagebox
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def ask_extension_input_image(filename, imgshape=None):
|
|
18
|
+
"""Ask the user for the FITS extension to use for the input image.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
filename : str
|
|
23
|
+
The name of the FITS file.
|
|
24
|
+
|
|
25
|
+
Returns
|
|
26
|
+
-------
|
|
27
|
+
ext : int or str
|
|
28
|
+
The selected FITS extension (0-based index or name).
|
|
29
|
+
"""
|
|
30
|
+
# Open the FITS file to get the list of extensions
|
|
31
|
+
try:
|
|
32
|
+
with fits.open(filename) as hdul:
|
|
33
|
+
ext_names = [hdu.name for hdu in hdul]
|
|
34
|
+
ext_indices = list(range(len(hdul)))
|
|
35
|
+
ext_bitpix = [hdu.header["BITPIX"] for hdu in hdul]
|
|
36
|
+
except Exception as e:
|
|
37
|
+
messagebox.showerror("Error", f"Unable to open FITS file '{filename}':\n{str(e)}")
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
if len(ext_indices) == 1:
|
|
41
|
+
ext = 0
|
|
42
|
+
else:
|
|
43
|
+
# ask for the extension number in a dialog
|
|
44
|
+
ext_str = simpledialog.askstring(
|
|
45
|
+
"Select Extension",
|
|
46
|
+
f"\nEnter extension number (0-{len(ext_indices)-1}) for file:\n{Path(filename).name}\n"
|
|
47
|
+
f"Available extensions:\n"
|
|
48
|
+
+ "\n".join(
|
|
49
|
+
[f"{i}: {name} (BITPIX={bitpix})" for i, name, bitpix in zip(ext_indices, ext_names, ext_bitpix)]
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
if ext_str is None:
|
|
53
|
+
return None
|
|
54
|
+
# Validate the input
|
|
55
|
+
try:
|
|
56
|
+
ext = int(ext_str)
|
|
57
|
+
if ext < 0 or ext >= len(ext_indices):
|
|
58
|
+
raise ValueError("Extension number out of range")
|
|
59
|
+
except ValueError as e:
|
|
60
|
+
messagebox.showerror("Invalid Input", f"Error: {str(e)}")
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
# check if ext is a valid array
|
|
64
|
+
with fits.open(filename) as hdul:
|
|
65
|
+
if hdul[ext] is None:
|
|
66
|
+
messagebox.showerror("Invalid Input", f"Extension {ext} does not exist in file '{filename}'")
|
|
67
|
+
return None
|
|
68
|
+
elif hdul[ext].data is None:
|
|
69
|
+
messagebox.showerror("Invalid Input", f"Extension {ext} in file '{filename}' has no data")
|
|
70
|
+
return None
|
|
71
|
+
elif hdul[ext].data.ndim != 2:
|
|
72
|
+
messagebox.showerror("Invalid Input", f"Extension {ext} in file '{filename}' is not 2D")
|
|
73
|
+
return None
|
|
74
|
+
elif hdul[ext].data.size == 0:
|
|
75
|
+
messagebox.showerror("Invalid Input", f"Extension {ext} in file '{filename}' has no data")
|
|
76
|
+
return None
|
|
77
|
+
elif imgshape is not None and (
|
|
78
|
+
hdul[ext].data.shape[0] != imgshape[0] or hdul[ext].data.shape[1] != imgshape[1]
|
|
79
|
+
):
|
|
80
|
+
messagebox.showerror(
|
|
81
|
+
"Invalid Input",
|
|
82
|
+
f"Extension {ext} in file '{filename}' has unexpected shape {hdul[ext].data.shape}, expected {imgshape}",
|
|
83
|
+
)
|
|
84
|
+
return None
|
|
85
|
+
return ext
|