teareduce 0.5.9__tar.gz → 0.6.1__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 (63) hide show
  1. {teareduce-0.5.9/src/teareduce.egg-info → teareduce-0.6.1}/PKG-INFO +2 -2
  2. {teareduce-0.5.9 → teareduce-0.6.1}/README.md +1 -1
  3. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/__init__.py +2 -2
  4. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/__main__.py +11 -5
  5. teareduce-0.6.1/src/teareduce/cleanest/askextension.py +85 -0
  6. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/cosmicraycleanerapp.py +294 -71
  7. teareduce-0.6.1/src/teareduce/cleanest/definitions.py +109 -0
  8. teareduce-0.6.1/src/teareduce/cleanest/gausskernel2d_elliptical.py +54 -0
  9. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/imagedisplay.py +1 -0
  10. teareduce-0.6.1/src/teareduce/cleanest/interpolate.py +169 -0
  11. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/interpolation_a.py +1 -0
  12. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/interpolation_x.py +1 -0
  13. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/interpolation_y.py +1 -0
  14. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/interpolationeditor.py +199 -53
  15. teareduce-0.6.1/src/teareduce/cleanest/lacosmicpad.py +157 -0
  16. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/mergemasks.py +11 -1
  17. teareduce-0.6.1/src/teareduce/cleanest/parametereditor.py +557 -0
  18. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/reviewcosmicray.py +245 -30
  19. teareduce-0.6.1/src/teareduce/cleanest/trackedbutton.py +73 -0
  20. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/version.py +1 -1
  21. {teareduce-0.5.9 → teareduce-0.6.1/src/teareduce.egg-info}/PKG-INFO +2 -2
  22. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce.egg-info/SOURCES.txt +3 -0
  23. teareduce-0.5.9/src/teareduce/cleanest/definitions.py +0 -63
  24. teareduce-0.5.9/src/teareduce/cleanest/interpolate.py +0 -138
  25. teareduce-0.5.9/src/teareduce/cleanest/lacosmicpad.py +0 -64
  26. teareduce-0.5.9/src/teareduce/cleanest/parametereditor.py +0 -329
  27. {teareduce-0.5.9 → teareduce-0.6.1}/LICENSE.txt +0 -0
  28. {teareduce-0.5.9 → teareduce-0.6.1}/pyproject.toml +0 -0
  29. {teareduce-0.5.9 → teareduce-0.6.1}/setup.cfg +0 -0
  30. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/__init__.py +0 -0
  31. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/avoid_astropy_warnings.py +0 -0
  32. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/centerchildparent.py +0 -0
  33. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/dilatemask.py +0 -0
  34. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/find_closest_true.py +0 -0
  35. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cleanest/modalprogressbar.py +0 -0
  36. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cookbook/__init__.py +0 -0
  37. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cookbook/get_cookbook_file.py +0 -0
  38. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/correct_pincushion_distortion.py +0 -0
  39. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/cosmicrays.py +0 -0
  40. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/ctext.py +0 -0
  41. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/draw_rectangle.py +0 -0
  42. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/elapsed_time.py +0 -0
  43. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/histogram1d.py +0 -0
  44. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/imshow.py +0 -0
  45. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/numsplines.py +0 -0
  46. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/peaks_spectrum.py +0 -0
  47. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/polfit.py +0 -0
  48. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/robust_std.py +0 -0
  49. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/sdistortion.py +0 -0
  50. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/simulateccdexposure.py +0 -0
  51. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/sliceregion.py +0 -0
  52. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/statsummary.py +0 -0
  53. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/tests/__init__.py +0 -0
  54. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/tests/test_cleanest.py +0 -0
  55. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/tests/test_sliceregion.py +0 -0
  56. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/tests/test_version.py +0 -0
  57. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/wavecal.py +0 -0
  58. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/write_array_to_fits.py +0 -0
  59. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce/zscale.py +0 -0
  60. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce.egg-info/dependency_links.txt +0 -0
  61. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce.egg-info/entry_points.txt +0 -0
  62. {teareduce-0.5.9 → teareduce-0.6.1}/src/teareduce.egg-info/requires.txt +0 -0
  63. {teareduce-0.5.9 → teareduce-0.6.1}/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.9
3
+ Version: 0.6.1
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
@@ -51,7 +51,7 @@ practical for use in Master’s level classes.
51
51
  ## Documentation
52
52
 
53
53
  The documentation for this package is available at [this
54
- link](https://guaix.fis.ucm.es/~tea/teareduce-cookbook/_build/html/intro.html).
54
+ link](https://nicocardiel.github.io/teareduce-cookbook/intro.html).
55
55
  It includes Juypter notebooks that can be easily downloaded and demonstrate the
56
56
  practical use of the defined functionality.
57
57
 
@@ -14,7 +14,7 @@ practical for use in Master’s level classes.
14
14
  ## Documentation
15
15
 
16
16
  The documentation for this package is available at [this
17
- link](https://guaix.fis.ucm.es/~tea/teareduce-cookbook/_build/html/intro.html).
17
+ link](https://nicocardiel.github.io/teareduce-cookbook/intro.html).
18
18
  It includes Juypter notebooks that can be easily downloaded and demonstrate the
19
19
  practical use of the defined functionality.
20
20
 
@@ -8,7 +8,7 @@
8
8
  #
9
9
 
10
10
  """Module providing functions for cleaning astronomical images.
11
- Includes functions for interpolating over bad pixels,
11
+ Includes functions for interpolating over bad pixels,
12
12
  applying the L.A.Cosmic algorithm to detect cosmic ray pixels.
13
13
  """
14
14
 
@@ -16,4 +16,4 @@ from .interpolate import interpolate
16
16
  from .lacosmicpad import lacosmicpad
17
17
  from .mergemasks import merge_peak_tail_masks
18
18
 
19
- __all__ = ['interpolate', 'lacosmicpad', 'merge_peak_tail_masks']
19
+ __all__ = ["interpolate", "lacosmicpad", "merge_peak_tail_masks"]
@@ -92,10 +92,10 @@ def main():
92
92
  exit(1)
93
93
  print(f"Selected input FITS file: {args.input_fits}")
94
94
  args.extension = simpledialog.askstring(
95
- "Select Extension",
96
- f"\nEnter extension number or name for file:\n{Path(args.input_fits).name}",
97
- initialvalue=args.extension,
98
- )
95
+ "Select Extension",
96
+ f"\nEnter extension number or name for file:\n{Path(args.input_fits).name}",
97
+ initialvalue=args.extension,
98
+ )
99
99
  # Ask for auxiliary file if not provided
100
100
  if args.auxfile is None:
101
101
  use_auxfile = tk.messagebox.askyesno(
@@ -132,7 +132,13 @@ def main():
132
132
  exit(1)
133
133
 
134
134
  # Initialize Tkinter root
135
- root = tk.Tk()
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)
136
142
  system = platform.system()
137
143
  if system == "Darwin": # macOS
138
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