teareduce 0.6.0__py3-none-any.whl → 0.6.1__py3-none-any.whl

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.
@@ -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
teareduce/version.py CHANGED
@@ -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
 
@@ -15,7 +15,7 @@ teareduce/sdistortion.py,sha256=5ZsZn4vD5Sw2aoqO8-NIOH7H89Zmh7ZDkow6YbAotHU,5916
15
15
  teareduce/simulateccdexposure.py,sha256=cdbpca6GVuM3d7R1LGzlIZZvjTq_jzrlkk_Cli7aouQ,24636
16
16
  teareduce/sliceregion.py,sha256=Jdf8XvmGaY_vaY1cneTaRtSOYPxpUsJm9cXJDDMa0YM,18626
17
17
  teareduce/statsummary.py,sha256=VTNAnBV8z6suqiyB2Lhw3YjUUOjlmwUPX3enkOKRF54,5422
18
- teareduce/version.py,sha256=E1uQr8Mx5jXWQL_pejqYQN5pSGxyQT__LkXZ7yPdegY,419
18
+ teareduce/version.py,sha256=RJWCscyH4cJAAqke3NP_StsgFVOL0CjPEjXdsqc_8KI,419
19
19
  teareduce/wavecal.py,sha256=2MewWz5Y3ms41c305UtWOM_LaLNdk1mugDXCtzf-fSw,68586
20
20
  teareduce/write_array_to_fits.py,sha256=kWDrEH9coJ1yIu56oQJpWtDqJL4c8HGmssE9jle4e94,617
21
21
  teareduce/zscale.py,sha256=SDgmcDD2N5GvDn46JADCgTQJPBF_N_jSKMHoeTz9Nsw,1152
@@ -23,19 +23,19 @@ teareduce/cleanest/__init__.py,sha256=1rcfu97uqj3R-OZbU9HHLYaTzWkS-poRFBBy8nuH7p
23
23
  teareduce/cleanest/__main__.py,sha256=KhFJSekko0mz_pVz3gxNnEmqvv4nuRBdhaXB2Nt4aL0,6145
24
24
  teareduce/cleanest/askextension.py,sha256=Q6mGLA6ajUcDU4gsVA4P78GsPei0c7iZK1f7SfK9iVo,3014
25
25
  teareduce/cleanest/centerchildparent.py,sha256=wHxOvNrrQ-KBLZAbtQ9bJAxYhGOzqYBF4LgdIQk7UF8,1285
26
- teareduce/cleanest/cosmicraycleanerapp.py,sha256=MJPdHmEpID4ykGu3o89dLUD0ebhjw3ZlxFUBQDJ_HcY,61768
26
+ teareduce/cleanest/cosmicraycleanerapp.py,sha256=OpBBhgvvGiC8rO_C26Zwc0gIlQ6phDVjSarQNMEfpTY,61327
27
27
  teareduce/cleanest/definitions.py,sha256=Ryreer1ztkk4W3muWGI_SSfm3ZAhyAOQJbZLtdfTJsc,4692
28
28
  teareduce/cleanest/dilatemask.py,sha256=I5tHAv5VEO6V0Wed8Ar20uLt4F9P-tgjmLL5BAaFvgM,1276
29
29
  teareduce/cleanest/find_closest_true.py,sha256=mWdIvhipzAXDRKfePDrP7f0lP4U48cckpHiKwiB4jHI,1320
30
30
  teareduce/cleanest/gausskernel2d_elliptical.py,sha256=f6AT0ZHmLCd83NAIyyJ8ODlihMeeTkmvNnUSK3vjP9I,1606
31
- teareduce/cleanest/imagedisplay.py,sha256=820Vn-Q0bJyHicOBsxDmfAZxuGOFepEEsm0LTxlPJjc,5848
32
- teareduce/cleanest/interpolate.py,sha256=upk6OxIIfoV1PetogwI8PUmdwM6TiKvHu9XNUwG1Dac,6380
33
- teareduce/cleanest/interpolation_a.py,sha256=zE4VIrC41vapf0Vx9qmh1oacw2qkJwcuMnV3JpSDW8Y,4007
34
- teareduce/cleanest/interpolation_x.py,sha256=D5hKbobT6lJk18XktP3PXhzEN12zqed6U18yfQ-reLQ,3744
35
- teareduce/cleanest/interpolation_y.py,sha256=O6yw5nKKlTdV6qsP1Ku6CwGhXB6o3j0_YQirXyILi8c,3759
36
- teareduce/cleanest/interpolationeditor.py,sha256=ZcqQl_iG-0eH-1PdtnJppRI9zKiSK6S7OCQz7XUvAno,19888
37
- teareduce/cleanest/lacosmicpad.py,sha256=aZp-2NZJKRnu1NmjC_SHnL0EVy0jDXWULgo0Pe7tq3U,6817
38
- teareduce/cleanest/mergemasks.py,sha256=1Vq6Wqn6DClxSAvHwy6QrJGszA8nkmoMHITyprSykHI,2072
31
+ teareduce/cleanest/imagedisplay.py,sha256=m8wmQ7CSDywABxkra2G4dFD06CVP1KvIYIdnZqoVdrI,5871
32
+ teareduce/cleanest/interpolate.py,sha256=EZGxiRDh8i5jL5_fK_iTLDt96TaK1ILsiFXV5m6g2J4,7068
33
+ teareduce/cleanest/interpolation_a.py,sha256=iyAEbh0Bf74OfAVhZjSvP3cO7pDC8eVDrVnDUd18FZQ,4030
34
+ teareduce/cleanest/interpolation_x.py,sha256=MZhtlZZuMLvLnOK0EsLkJM3_dpyNHsxQL_BU1vLt9Lw,3767
35
+ teareduce/cleanest/interpolation_y.py,sha256=ZX1Uv3FOxoLHtuR_yspcSA5B81CK_J0oNJ1ztzp0l5g,3782
36
+ teareduce/cleanest/interpolationeditor.py,sha256=mIy-25dylQnqC91tLny4iZWS4d_bJ4sDDs-kNOWM-yE,19933
37
+ teareduce/cleanest/lacosmicpad.py,sha256=IXwHAHeh4rQlQjMw2lfKSzjzmoo3HdSt0Qj0nhK_nHU,6921
38
+ teareduce/cleanest/mergemasks.py,sha256=TdbfQl5ETxtyFfod0WCD7Czzmgt-WxYOk3hpLqGNOTQ,2620
39
39
  teareduce/cleanest/modalprogressbar.py,sha256=uwd-p92PvOVJnbXd-B8DRcBZ--keKpr4ZN9PLeqm1Ws,6449
40
40
  teareduce/cleanest/parametereditor.py,sha256=V8twAQzR0vjd68PB92PfdQBmTRDR04xx2mb4SLSV68Y,24530
41
41
  teareduce/cleanest/reviewcosmicray.py,sha256=8jUaJCHVvZqlQ57A9eCDNIfBCKQ0IqFADq8C1H7T7ko,36518
@@ -46,9 +46,9 @@ teareduce/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  teareduce/tests/test_cleanest.py,sha256=6dRqkw1RQMKsFrC8cEweMvTD6wXhiDv3P4PS57-HEqI,5598
47
47
  teareduce/tests/test_sliceregion.py,sha256=S7Zoh2eEBFIEbfsXgWBEMCf7pottjw2oLhqlZJQkAwg,3785
48
48
  teareduce/tests/test_version.py,sha256=mKLnbXyvVNc1pATq5PxR8qeoFMPAFL_GilFV6IHLOi0,172
49
- teareduce-0.6.0.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
50
- teareduce-0.6.0.dist-info/METADATA,sha256=ZL_ioffCU8ICr6DsuohcYHR3tvJLWkG1gJePxH61Pgk,3640
51
- teareduce-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
- teareduce-0.6.0.dist-info/entry_points.txt,sha256=6yBvig5jTL2ugqz5SF767AiszzrHKGRASsX1II84kqA,66
53
- teareduce-0.6.0.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
54
- teareduce-0.6.0.dist-info/RECORD,,
49
+ teareduce-0.6.1.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
50
+ teareduce-0.6.1.dist-info/METADATA,sha256=tYpScu331TcUdNsSurzVythnm0_NHdEQe9CijpaOiCw,3628
51
+ teareduce-0.6.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
+ teareduce-0.6.1.dist-info/entry_points.txt,sha256=6yBvig5jTL2ugqz5SF767AiszzrHKGRASsX1II84kqA,66
53
+ teareduce-0.6.1.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
54
+ teareduce-0.6.1.dist-info/RECORD,,