teareduce 0.5.4__tar.gz → 0.5.7__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.
Files changed (60) hide show
  1. {teareduce-0.5.4/src/teareduce.egg-info → teareduce-0.5.7}/PKG-INFO +1 -1
  2. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/__init__.py +3 -1
  3. teareduce-0.5.7/src/teareduce/cleanest/__main__.py +169 -0
  4. teareduce-0.5.7/src/teareduce/cleanest/centerchildparent.py +46 -0
  5. teareduce-0.5.7/src/teareduce/cleanest/cosmicraycleanerapp.py +1049 -0
  6. teareduce-0.5.7/src/teareduce/cleanest/definitions.py +63 -0
  7. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/imagedisplay.py +8 -9
  8. teareduce-0.5.4/src/teareduce/cleanest/cleanest.py → teareduce-0.5.7/src/teareduce/cleanest/interpolate.py +25 -26
  9. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/interpolation_a.py +5 -9
  10. teareduce-0.5.7/src/teareduce/cleanest/interpolationeditor.py +332 -0
  11. teareduce-0.5.7/src/teareduce/cleanest/lacosmicpad.py +57 -0
  12. teareduce-0.5.7/src/teareduce/cleanest/mergemasks.py +58 -0
  13. teareduce-0.5.7/src/teareduce/cleanest/modalprogressbar.py +182 -0
  14. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/parametereditor.py +112 -79
  15. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/reviewcosmicray.py +90 -62
  16. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/tests/test_cleanest.py +11 -11
  17. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/version.py +1 -1
  18. {teareduce-0.5.4 → teareduce-0.5.7/src/teareduce.egg-info}/PKG-INFO +1 -1
  19. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce.egg-info/SOURCES.txt +5 -1
  20. teareduce-0.5.4/src/teareduce/cleanest/__main__.py +0 -61
  21. teareduce-0.5.4/src/teareduce/cleanest/cosmicraycleanerapp.py +0 -764
  22. teareduce-0.5.4/src/teareduce/cleanest/definitions.py +0 -62
  23. teareduce-0.5.4/src/teareduce/cleanest/interpolationeditor.py +0 -211
  24. {teareduce-0.5.4 → teareduce-0.5.7}/LICENSE.txt +0 -0
  25. {teareduce-0.5.4 → teareduce-0.5.7}/README.md +0 -0
  26. {teareduce-0.5.4 → teareduce-0.5.7}/pyproject.toml +0 -0
  27. {teareduce-0.5.4 → teareduce-0.5.7}/setup.cfg +0 -0
  28. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/__init__.py +0 -0
  29. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/avoid_astropy_warnings.py +0 -0
  30. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/dilatemask.py +0 -0
  31. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/find_closest_true.py +0 -0
  32. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/interpolation_x.py +0 -0
  33. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cleanest/interpolation_y.py +0 -0
  34. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cookbook/__init__.py +0 -0
  35. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cookbook/get_cookbook_file.py +0 -0
  36. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/correct_pincushion_distortion.py +0 -0
  37. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/cosmicrays.py +0 -0
  38. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/ctext.py +0 -0
  39. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/draw_rectangle.py +0 -0
  40. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/elapsed_time.py +0 -0
  41. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/histogram1d.py +0 -0
  42. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/imshow.py +0 -0
  43. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/numsplines.py +0 -0
  44. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/peaks_spectrum.py +0 -0
  45. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/polfit.py +0 -0
  46. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/robust_std.py +0 -0
  47. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/sdistortion.py +0 -0
  48. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/simulateccdexposure.py +0 -0
  49. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/sliceregion.py +0 -0
  50. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/statsummary.py +0 -0
  51. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/tests/__init__.py +0 -0
  52. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/tests/test_sliceregion.py +0 -0
  53. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/tests/test_version.py +0 -0
  54. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/wavecal.py +0 -0
  55. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/write_array_to_fits.py +0 -0
  56. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce/zscale.py +0 -0
  57. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce.egg-info/dependency_links.txt +0 -0
  58. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce.egg-info/entry_points.txt +0 -0
  59. {teareduce-0.5.4 → teareduce-0.5.7}/src/teareduce.egg-info/requires.txt +0 -0
  60. {teareduce-0.5.4 → teareduce-0.5.7}/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.4
3
+ Version: 0.5.7
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
@@ -7,4 +7,6 @@
7
7
  # License-Filename: LICENSE.txt
8
8
  #
9
9
 
10
- from .cleanest import cleanest
10
+ from .interpolate import interpolate
11
+ from .lacosmicpad import lacosmicpad
12
+ from .mergemasks import merge_peak_tail_masks
@@ -0,0 +1,169 @@
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
+ """Interactive Cosmic Ray cleaning tool."""
11
+
12
+ import argparse
13
+ from ast import arg
14
+ import tkinter as tk
15
+ from tkinter import filedialog
16
+ from tkinter import simpledialog
17
+ import os
18
+ from pathlib import Path
19
+ import platform
20
+ from rich import print
21
+ from rich_argparse import RichHelpFormatter
22
+
23
+ from .definitions import DEFAULT_FONT_FAMILY
24
+ from .definitions import DEFAULT_FONT_SIZE
25
+ from .definitions import DEFAULT_TK_WINDOW_SIZE_X
26
+ from .definitions import DEFAULT_TK_WINDOW_SIZE_Y
27
+ from .cosmicraycleanerapp import CosmicRayCleanerApp
28
+ from ..version import VERSION
29
+
30
+ import matplotlib
31
+
32
+ matplotlib.use("TkAgg")
33
+
34
+
35
+ def main():
36
+ parser = argparse.ArgumentParser(
37
+ description="Interactive cosmic ray cleaner for FITS images.",
38
+ formatter_class=RichHelpFormatter,
39
+ )
40
+ parser.add_argument("input_fits", nargs="?", default=None, help="Path to the FITS file to be cleaned.")
41
+ parser.add_argument("--extension", type=str, default="0", help="FITS extension to use (default: 0).")
42
+ parser.add_argument("--auxfile", type=str, default=None, help="Auxiliary FITS file")
43
+ parser.add_argument(
44
+ "--extension_auxfile",
45
+ type=str,
46
+ default="0",
47
+ help="FITS extension for auxiliary file (default: 0).",
48
+ )
49
+ parser.add_argument(
50
+ "--fontfamily",
51
+ type=str,
52
+ default=DEFAULT_FONT_FAMILY,
53
+ help=f"Font family for the GUI (default: {DEFAULT_FONT_FAMILY}).",
54
+ )
55
+ parser.add_argument(
56
+ "--fontsize",
57
+ type=int,
58
+ default=DEFAULT_FONT_SIZE,
59
+ help=f"Font size for the GUI (default: {DEFAULT_FONT_SIZE}).",
60
+ )
61
+ parser.add_argument(
62
+ "--width",
63
+ type=int,
64
+ default=DEFAULT_TK_WINDOW_SIZE_X,
65
+ help=f"Width of the GUI window in pixels (default: {DEFAULT_TK_WINDOW_SIZE_X}).",
66
+ )
67
+ parser.add_argument(
68
+ "--height",
69
+ type=int,
70
+ default=DEFAULT_TK_WINDOW_SIZE_Y,
71
+ help=f"Height of the GUI window in pixels (default: {DEFAULT_TK_WINDOW_SIZE_Y}).",
72
+ )
73
+ parser.add_argument("--version", action="version", version=f"%(prog)s {VERSION}")
74
+ parser.add_argument("--verbose", "-v", action="store_true", help="Enable verbose output.")
75
+ args = parser.parse_args()
76
+
77
+ # Welcome message
78
+ print("[bold green]Cosmic Ray Cleaner[/bold green]")
79
+ print("Interactive tool to clean cosmic rays from FITS images.")
80
+ print("teareduce version: " + VERSION)
81
+ print(f"https://nicocardiel.github.io/teareduce-cookbook/docs/cleanest/cleanest.html\n")
82
+
83
+ # If input_file is not provided, ask for it using a file dialog
84
+ if args.input_fits is None:
85
+ root = tk.Tk()
86
+ root.withdraw() # Hide the root window
87
+ args.input_fits = filedialog.askopenfilename(
88
+ title="Select FITS file to be cleaned",
89
+ filetypes=[("FITS files", "*.fits *.fit *.fts"), ("All files", "*.*")],
90
+ )
91
+ if not args.input_fits:
92
+ print("No input FITS file selected. Exiting.")
93
+ exit(1)
94
+ print(f"Selected input FITS file: {args.input_fits}")
95
+ args.extension = simpledialog.askstring(
96
+ "Select Extension",
97
+ f"\nEnter extension number or name for file:\n{Path(args.input_fits).name}",
98
+ initialvalue=args.extension,
99
+ )
100
+ # Ask for auxiliary file if not provided
101
+ if args.auxfile is None:
102
+ use_auxfile = tk.messagebox.askyesno(
103
+ "Auxiliary File",
104
+ "Do you want to use an auxiliary FITS file?",
105
+ default=tk.messagebox.NO,
106
+ )
107
+ if use_auxfile:
108
+ args.auxfile = filedialog.askopenfilename(
109
+ title="Select Auxiliary FITS file",
110
+ filetypes=[("FITS files", "*.fits *.fit *.fts"), ("All files", "*.*")],
111
+ initialfile=args.auxfile,
112
+ )
113
+ if not args.auxfile:
114
+ print("No auxiliary FITS file selected. Exiting.")
115
+ exit(1)
116
+ else:
117
+ use_auxfile = True
118
+ if use_auxfile:
119
+ print(f"Selected auxiliary FITS file: {args.auxfile}")
120
+ args.extension_auxfile = simpledialog.askstring(
121
+ "Select Extension for Auxiliary File",
122
+ f"\nEnter extension number or name for auxiliary file:\n{Path(args.auxfile).name}",
123
+ initialvalue=args.extension_auxfile,
124
+ )
125
+ root.destroy()
126
+
127
+ # Check that input files, and the corresponding extensions, exist
128
+ if not os.path.isfile(args.input_fits):
129
+ print(f"Error: File '{args.input_fits}' does not exist.")
130
+ exit(1)
131
+ if args.auxfile is not None and not os.path.isfile(args.auxfile):
132
+ print(f"Error: Auxiliary file '{args.auxfile}' does not exist.")
133
+ exit(1)
134
+
135
+ # Initialize Tkinter root
136
+ root = tk.Tk()
137
+ system = platform.system()
138
+ if system == "Darwin": # macOS
139
+ # Center the window on the screen
140
+ xoffset = root.winfo_screenwidth() // 2 - args.width // 2
141
+ yoffset = root.winfo_screenheight() // 2 - args.height // 2
142
+ else:
143
+ # Note that geometry("XxY+Xoffset+Yoffset") does not work properly on Fedora Linux
144
+ xoffset = 0
145
+ yoffset = 0
146
+ root.geometry(f"+{xoffset}+{yoffset}")
147
+ root.focus_force() # Request focus
148
+ root.lift() # Bring to front
149
+
150
+ # Create and run the application
151
+ CosmicRayCleanerApp(
152
+ root=root,
153
+ input_fits=args.input_fits,
154
+ extension=args.extension,
155
+ auxfile=args.auxfile,
156
+ extension_auxfile=args.extension_auxfile,
157
+ fontfamily=args.fontfamily,
158
+ fontsize=args.fontsize,
159
+ width=args.width,
160
+ height=args.height,
161
+ verbose=args.verbose,
162
+ )
163
+
164
+ # Execute
165
+ root.mainloop()
166
+
167
+
168
+ if __name__ == "__main__":
169
+ main()
@@ -0,0 +1,46 @@
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
+ """Function to center a tk child window on its parent."""
11
+
12
+
13
+ def center_on_parent(child, parent, offset_x=0, offset_y=0):
14
+ """Center child window on parent window.
15
+
16
+ Parameters
17
+ ----------
18
+ child : tk.Toplevel or tk.Tk
19
+ The child window to be centered.
20
+ parent : tk.Toplevel or tk.Tk
21
+ The parent window.
22
+ offset_x : int, optional
23
+ Horizontal offset from center position (default is 0).
24
+ offset_y : int, optional
25
+ Vertical offset from center position (default is 0).
26
+ """
27
+ # Update to get accurate dimensions
28
+ child.update_idletasks()
29
+ parent.update_idletasks()
30
+
31
+ # Get parent position and size
32
+ parent_x = parent.winfo_x()
33
+ parent_y = parent.winfo_y()
34
+ parent_width = parent.winfo_width()
35
+ parent_height = parent.winfo_height()
36
+
37
+ # Get child size
38
+ child_width = child.winfo_width()
39
+ child_height = child.winfo_height()
40
+
41
+ # Calculate center position
42
+ x = parent_x + (parent_width - child_width) // 2
43
+ y = parent_y + (parent_height - child_height) // 2
44
+
45
+ # Set child position
46
+ child.geometry(f"+{x + offset_x}+{y + offset_y}")