teareduce 0.6.0__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 (59) hide show
  1. {teareduce-0.6.0/src/teareduce.egg-info → teareduce-0.6.1}/PKG-INFO +2 -2
  2. {teareduce-0.6.0 → teareduce-0.6.1}/README.md +1 -1
  3. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/cosmicraycleanerapp.py +8 -10
  4. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/imagedisplay.py +1 -0
  5. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/interpolate.py +14 -0
  6. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/interpolation_a.py +1 -0
  7. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/interpolation_x.py +1 -0
  8. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/interpolation_y.py +1 -0
  9. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/interpolationeditor.py +3 -1
  10. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/lacosmicpad.py +3 -1
  11. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/mergemasks.py +11 -1
  12. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/version.py +1 -1
  13. {teareduce-0.6.0 → teareduce-0.6.1/src/teareduce.egg-info}/PKG-INFO +2 -2
  14. {teareduce-0.6.0 → teareduce-0.6.1}/LICENSE.txt +0 -0
  15. {teareduce-0.6.0 → teareduce-0.6.1}/pyproject.toml +0 -0
  16. {teareduce-0.6.0 → teareduce-0.6.1}/setup.cfg +0 -0
  17. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/__init__.py +0 -0
  18. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/avoid_astropy_warnings.py +0 -0
  19. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/__init__.py +0 -0
  20. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/__main__.py +0 -0
  21. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/askextension.py +0 -0
  22. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/centerchildparent.py +0 -0
  23. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/definitions.py +0 -0
  24. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/dilatemask.py +0 -0
  25. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/find_closest_true.py +0 -0
  26. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/gausskernel2d_elliptical.py +0 -0
  27. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/modalprogressbar.py +0 -0
  28. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/parametereditor.py +0 -0
  29. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/reviewcosmicray.py +0 -0
  30. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cleanest/trackedbutton.py +0 -0
  31. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cookbook/__init__.py +0 -0
  32. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cookbook/get_cookbook_file.py +0 -0
  33. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/correct_pincushion_distortion.py +0 -0
  34. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/cosmicrays.py +0 -0
  35. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/ctext.py +0 -0
  36. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/draw_rectangle.py +0 -0
  37. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/elapsed_time.py +0 -0
  38. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/histogram1d.py +0 -0
  39. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/imshow.py +0 -0
  40. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/numsplines.py +0 -0
  41. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/peaks_spectrum.py +0 -0
  42. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/polfit.py +0 -0
  43. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/robust_std.py +0 -0
  44. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/sdistortion.py +0 -0
  45. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/simulateccdexposure.py +0 -0
  46. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/sliceregion.py +0 -0
  47. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/statsummary.py +0 -0
  48. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/tests/__init__.py +0 -0
  49. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/tests/test_cleanest.py +0 -0
  50. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/tests/test_sliceregion.py +0 -0
  51. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/tests/test_version.py +0 -0
  52. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/wavecal.py +0 -0
  53. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/write_array_to_fits.py +0 -0
  54. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce/zscale.py +0 -0
  55. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce.egg-info/SOURCES.txt +0 -0
  56. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce.egg-info/dependency_links.txt +0 -0
  57. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce.egg-info/entry_points.txt +0 -0
  58. {teareduce-0.6.0 → teareduce-0.6.1}/src/teareduce.egg-info/requires.txt +0 -0
  59. {teareduce-0.6.0 → 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.6.0
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
 
@@ -285,17 +285,21 @@ class CosmicRayCleanerApp(ImageDisplay):
285
285
  sdum = str(num_cr_pixels_after_dilation)
286
286
  else:
287
287
  sdum = str(num_cr_pixels_before_dilation)
288
- print("Number of cosmic ray pixels detected..........: " f"{num_cr_pixels_before_dilation:>{len(sdum)}}")
289
288
  if dilation > 0:
290
289
  print(
291
- f"Number of cosmic ray pixels after dilation....: " f"{num_cr_pixels_after_dilation:>{len(sdum)}}"
290
+ "Number of cosmic ray pixels before dilation.......: "
291
+ f"{num_cr_pixels_before_dilation:>{len(sdum)}}"
292
+ )
293
+ print(
294
+ f"Number of cosmic ray pixels after dilation........: "
295
+ f"{num_cr_pixels_after_dilation:>{len(sdum)}}"
292
296
  )
293
297
  # Label connected components in the mask; note that by default,
294
298
  # structure is a cross [0,1,0;1,1,1;0,1,0], but we want to consider
295
299
  # diagonal connections too, so we define a 3x3 square.
296
300
  structure = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
297
301
  self.cr_labels, self.num_features = ndimage.label(self.mask_crfound, structure=structure)
298
- print(f"Number of cosmic ray features (grouped pixels): {self.num_features:>{len(sdum)}}")
302
+ print(f"Number of cosmic ray features (grouped pixels)....: {self.num_features:>{len(sdum)}}")
299
303
  self.replace_detected_cr_button.config(state=tk.NORMAL)
300
304
  self.review_detected_cr_button.config(state=tk.NORMAL)
301
305
  self.update_cr_overlay()
@@ -886,10 +890,7 @@ class CosmicRayCleanerApp(ImageDisplay):
886
890
  mask_crfound2 = mask_crfound2 & (usefulmask.astype(bool))
887
891
  # Combine results from both runs
888
892
  if np.any(mask_crfound):
889
- print(f"Number of cosmic ray pixels (run1).......: {np.sum(mask_crfound)}")
890
- print(f"Number of cosmic ray pixels (run2).......: {np.sum(mask_crfound2)}")
891
- mask_crfound = merge_peak_tail_masks(mask_crfound, mask_crfound2)
892
- print(f"Number of cosmic ray pixels (run1 & run2): {np.sum(mask_crfound)}")
893
+ mask_crfound = merge_peak_tail_masks(mask_crfound, mask_crfound2, verbose=True)
893
894
  # Use the cleandata from the second run
894
895
  cleandata_lacosmic = cleandata_lacosmic2
895
896
  # Select the image region to process
@@ -936,9 +937,6 @@ class CosmicRayCleanerApp(ImageDisplay):
936
937
  # recalculate labels and number of features
937
938
  structure = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
938
939
  self.cr_labels, self.num_features = ndimage.label(self.mask_crfound, structure=structure)
939
- sdum = str(np.sum(self.mask_crfound))
940
- print(f"Number of cosmic ray pixels detected by L.A.Cosmic...........: {sdum}")
941
- print(f"Number of cosmic rays (grouped pixels) detected by L.A.Cosmic: {self.num_features:>{len(sdum)}}")
942
940
  # Define parameters for L.A.Cosmic from default dictionary
943
941
  editor_window = tk.Toplevel(self.root)
944
942
  center_on_parent(child=editor_window, parent=self.root)
@@ -11,6 +11,7 @@
11
11
 
12
12
  from tkinter import simpledialog
13
13
  import numpy as np
14
+ from rich import print
14
15
 
15
16
  from ..sliceregion import SliceRegion2D
16
17
  from ..zscale import zscale
@@ -18,6 +18,7 @@ except ModuleNotFoundError as e:
18
18
  "`pip install teareduce[cleanest]`."
19
19
  ) from e
20
20
  import numpy as np
21
+ from rich import print
21
22
  from scipy import ndimage
22
23
  from tqdm import tqdm
23
24
 
@@ -33,6 +34,19 @@ def interpolate(data, mask_crfound, dilation=0, interp_method=None, npoints=None
33
34
  The original data and mask are not modified. A copy of both
34
35
  arrays are created and returned with the interpolated pixels.
35
36
 
37
+ Cosmic-ray pixels are initially dilated by the specified number
38
+ of pixels. The resulting flagged pixels are grouped into cosmic-ray
39
+ features. Each cosmic-ray feature is then interpolated using the
40
+ specified interpolation method.
41
+
42
+ Note that the interpolation methods `lacosmic` and `auxfile`,
43
+ available in the interactive use of **tea-cleanest** are not
44
+ implemented in this function because both cases are simply
45
+ an inmediate replacement of the cosmic ray pixels in the data
46
+ array by the corresponding pixels in another array using the
47
+ mask array. Therefore, these two methods do not require any
48
+ interpolation algorithm.
49
+
36
50
  Parameters
37
51
  ----------
38
52
  data : 2D numpy.ndarray
@@ -10,6 +10,7 @@
10
10
  """Surface interpolation (plane fit) or median interpolation"""
11
11
 
12
12
  import numpy as np
13
+ from rich import print
13
14
 
14
15
  from .dilatemask import dilatemask
15
16
 
@@ -10,6 +10,7 @@
10
10
  """Polynomial nterpolation in the X direction"""
11
11
 
12
12
  import numpy as np
13
+ from rich import print
13
14
 
14
15
 
15
16
  def interpolation_x(data, mask_fixed, cr_labels, cr_index, npoints, degree):
@@ -10,6 +10,7 @@
10
10
  """Polynomial nterpolation in the Y direction"""
11
11
 
12
12
  import numpy as np
13
+ from rich import print
13
14
 
14
15
 
15
16
  def interpolation_y(data, mask_fixed, cr_labels, cr_index, npoints, degree):
@@ -13,6 +13,8 @@ import tkinter as tk
13
13
  from tkinter import messagebox
14
14
  from tkinter import ttk
15
15
 
16
+ from rich import print
17
+
16
18
  from .centerchildparent import center_on_parent
17
19
  from .definitions import VALID_CLEANING_METHODS
18
20
  from .definitions import MASKFILL_OPERATOR_VALUES
@@ -423,7 +425,7 @@ class InterpolationEditor:
423
425
  def action_on_method_change(self):
424
426
  """Handle changes in the selected cleaning method."""
425
427
  selected_method = self.cleaning_method_var.get()
426
- print(f"Selected cleaning method: {selected_method}")
428
+ print(f"Selected cleaning method: [red bold]{selected_method}[/red bold]")
427
429
  if selected_method in ["x interp.", "y interp."]:
428
430
  self.entry_npoints.config(state="normal")
429
431
  self.entry_degree.config(state="normal")
@@ -18,6 +18,7 @@ except ModuleNotFoundError as e:
18
18
  "`pip install teareduce[cleanest]`."
19
19
  ) from e
20
20
  import numpy as np
21
+ from rich import print
21
22
 
22
23
  from .definitions import VALID_LACOSMIC_PSFMODEL_VALUES
23
24
  from .gausskernel2d_elliptical import gausskernel2d_elliptical
@@ -28,7 +29,8 @@ def lacosmicpad(pad_width, show_arguments=False, **kwargs):
28
29
 
29
30
  This function pads the input image array before applying the LACosmic
30
31
  cosmic ray cleaning algorithm. After processing, the padding is removed
31
- to return an array of the original size.
32
+ to return an array of the original size. If `inbkg` or `invar` arrays
33
+ are provided, they are also padded accordingly.
32
34
 
33
35
  The padding helps to mitigate edge effects that can occur during the
34
36
  cosmic ray detection and cleaning process.
@@ -11,9 +11,10 @@
11
11
 
12
12
  import numpy as np
13
13
  from scipy import ndimage
14
+ from rich import print
14
15
 
15
16
 
16
- def merge_peak_tail_masks(mask_peaks, mask_tails):
17
+ def merge_peak_tail_masks(mask_peaks, mask_tails, verbose=False):
17
18
  """Merge peak and tail masks for cosmic ray cleaning.
18
19
 
19
20
  Tail pixels are preserved only if they correspond to CR features
@@ -25,6 +26,8 @@ def merge_peak_tail_masks(mask_peaks, mask_tails):
25
26
  Boolean array indicating the pixels identified as cosmic ray peaks.
26
27
  mask_tails : ndarray
27
28
  Boolean array indicating the pixels identified as cosmic ray tails.
29
+ verbose: bool
30
+ If True, print additional information during processing.
28
31
 
29
32
  Returns
30
33
  -------
@@ -41,6 +44,10 @@ def merge_peak_tail_masks(mask_peaks, mask_tails):
41
44
  if mask_peaks.dtype != bool or mask_tails.dtype != bool:
42
45
  raise TypeError("Input masks must be boolean arrays.")
43
46
 
47
+ if verbose:
48
+ ndigits = np.max([len(str(np.sum(mask_peaks))), len(str(np.sum(mask_tails)))])
49
+ print(f"Number of cosmic ray pixels (peaks)...............: {np.sum(mask_peaks):{ndigits}d}")
50
+ print(f"Number of cosmic ray pixels (tails)...............: {np.sum(mask_tails):{ndigits}d}")
44
51
  # find structures in tail mask
45
52
  structure = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
46
53
  cr_labels_tails, num_crs_tails = ndimage.label(mask_tails, structure=structure)
@@ -55,4 +62,7 @@ def merge_peak_tail_masks(mask_peaks, mask_tails):
55
62
  if icr > 0:
56
63
  merged_mask[cr_labels_tails == icr] = True
57
64
 
65
+ if verbose:
66
+ print(f"Number of cosmic ray pixels (merged peaks & tails): {np.sum(merged_mask):{ndigits}d}")
67
+
58
68
  return merged_mask
@@ -9,7 +9,7 @@
9
9
  #
10
10
  """Module to define the version of the teareduce package."""
11
11
 
12
- VERSION = '0.6.0'
12
+ VERSION = '0.6.1'
13
13
 
14
14
 
15
15
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: teareduce
3
- Version: 0.6.0
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
 
File without changes
File without changes
File without changes