teareduce 0.5.8__py3-none-any.whl → 0.5.9__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.
@@ -7,6 +7,13 @@
7
7
  # License-Filename: LICENSE.txt
8
8
  #
9
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
+
10
15
  from .interpolate import interpolate
11
16
  from .lacosmicpad import lacosmicpad
12
- from .mergemasks import merge_peak_tail_masks
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
@@ -17,7 +17,14 @@ from tkinter import simpledialog
17
17
  import sys
18
18
 
19
19
  from astropy.io import fits
20
- from maskfill import maskfill
20
+ try:
21
+ from maskfill import maskfill
22
+ except ModuleNotFoundError as e:
23
+ raise ModuleNotFoundError(
24
+ "The 'teareduce.cleanest' module requires the 'ccdproc' and 'maskfill' packages. "
25
+ "Please install teareduce with the 'cleanest' extra dependencies: "
26
+ "`pip install teareduce[cleanest]`."
27
+ ) from e
21
28
  import matplotlib.pyplot as plt
22
29
  from matplotlib.backend_bases import key_press_handler
23
30
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
@@ -9,7 +9,14 @@
9
9
 
10
10
  """Execute LACosmic algorithm on a padded image."""
11
11
 
12
- from ccdproc import cosmicray_lacosmic
12
+ try:
13
+ from ccdproc import cosmicray_lacosmic
14
+ except ModuleNotFoundError as e:
15
+ raise ModuleNotFoundError(
16
+ "The 'teareduce.cleanest' module requires the 'ccdproc' and 'maskfill' packages. "
17
+ "Please install teareduce with the 'cleanest' extra dependencies: "
18
+ "`pip install teareduce[cleanest]`."
19
+ ) from e
13
20
  import numpy as np
14
21
 
15
22
 
@@ -13,7 +13,14 @@ import tkinter as tk
13
13
  from tkinter import messagebox
14
14
  from tkinter import simpledialog
15
15
 
16
- from maskfill import maskfill
16
+ try:
17
+ from maskfill import maskfill
18
+ except ModuleNotFoundError as e:
19
+ raise ModuleNotFoundError(
20
+ "The 'teareduce.cleanest' module requires the 'ccdproc' and 'maskfill' packages. "
21
+ "Please install teareduce with the 'cleanest' extra dependencies: "
22
+ "`pip install teareduce[cleanest]`."
23
+ ) from e
17
24
  import matplotlib.pyplot as plt
18
25
  from matplotlib.backend_bases import key_press_handler
19
26
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
@@ -371,16 +378,9 @@ class ReviewCosmicRay(ImageDisplay):
371
378
 
372
379
  def set_buttons_after_cleaning_cr(self):
373
380
  """Set the state of buttons after cleaning a cosmic ray."""
381
+ self.disable_interpolation_buttons()
374
382
  self.restore_cr_button.config(state=tk.NORMAL)
375
383
  self.remove_crosses_button.config(state=tk.DISABLED)
376
- self.interp_x_button.config(state=tk.DISABLED)
377
- self.interp_y_button.config(state=tk.DISABLED)
378
- self.interp_s_button.config(state=tk.DISABLED)
379
- self.interp_d_button.config(state=tk.DISABLED)
380
- self.interp_m_button.config(state=tk.DISABLED)
381
- self.interp_l_button.config(state=tk.DISABLED)
382
- self.interp_maskfill_button.config(state=tk.DISABLED)
383
- self.interp_aux_button.config(state=tk.DISABLED)
384
384
 
385
385
  def interp_x(self):
386
386
  """Perform x-direction interpolation to clean a cosmic ray."""
@@ -506,35 +506,21 @@ class ReviewCosmicRay(ImageDisplay):
506
506
  for iy, ix in zip(ycr_list, xcr_list):
507
507
  self.cr_labels[iy, ix] = 0
508
508
  print(f"Removed all pixels of cosmic ray {self.cr_index}")
509
- self.remove_crosses_button.config(state=tk.DISABLED)
510
- self.interp_x_button.config(state=tk.DISABLED)
511
- self.interp_y_button.config(state=tk.DISABLED)
512
- self.interp_s_button.config(state=tk.DISABLED)
513
- self.interp_d_button.config(state=tk.DISABLED)
514
- self.interp_m_button.config(state=tk.DISABLED)
515
- self.interp_l_button.config(state=tk.DISABLED)
516
- self.interp_aux_button.config(state=tk.DISABLED)
509
+ self.disable_interpolation_buttons()
517
510
  self.update_display()
518
511
 
519
512
  def restore_cr(self):
520
513
  """Restore all pixels of the current cosmic ray to their original values."""
521
514
  ycr_list, xcr_list = np.where(self.cr_labels == self.cr_index)
515
+ if len(xcr_list) == 0:
516
+ print(f"No pixels to restore for cosmic ray {self.cr_index}")
517
+ return
522
518
  for iy, ix in zip(ycr_list, xcr_list):
523
519
  self.data[iy, ix] = self.data_original[iy, ix]
524
520
  self.mask_fixed[iy, ix] = False
525
- self.interp_x_button.config(state=tk.NORMAL)
526
- self.interp_y_button.config(state=tk.NORMAL)
527
- self.interp_s_button.config(state=tk.NORMAL)
528
- self.interp_d_button.config(state=tk.NORMAL)
529
- self.interp_m_button.config(state=tk.NORMAL)
530
- if self.cleandata_lacosmic is not None:
531
- if self.last_dilation is None or self.last_dilation == 0:
532
- self.interp_l_button.config(state=tk.NORMAL)
533
- self.interp_maskfill_button.config(state=tk.NORMAL)
534
- if self.auxdata is not None:
535
- self.interp_aux_button.config(state=tk.NORMAL)
536
521
  print(f"Restored all pixels of cosmic ray {self.cr_index}")
537
522
  self.num_cr_cleaned -= 1
523
+ self.enable_interpolation_buttons()
538
524
  self.remove_crosses_button.config(state=tk.NORMAL)
539
525
  self.restore_cr_button.config(state=tk.DISABLED)
540
526
  self.update_display()
@@ -550,16 +536,7 @@ class ReviewCosmicRay(ImageDisplay):
550
536
  return # important: do not remove (to avoid errors)
551
537
  self.first_plot = True
552
538
  self.restore_cr_button.config(state=tk.DISABLED)
553
- self.interp_x_button.config(state=tk.NORMAL)
554
- self.interp_y_button.config(state=tk.NORMAL)
555
- self.interp_s_button.config(state=tk.NORMAL)
556
- self.interp_d_button.config(state=tk.NORMAL)
557
- self.interp_m_button.config(state=tk.NORMAL)
558
- if self.cleandata_lacosmic is not None:
559
- if self.last_dilation is None or self.last_dilation == 0:
560
- self.interp_l_button.config(state=tk.NORMAL)
561
- if self.auxdata is not None:
562
- self.interp_aux_button.config(state=tk.NORMAL)
539
+ self.enable_interpolation_buttons()
563
540
  self.remove_crosses_button.config(state=tk.NORMAL)
564
541
  self.update_display()
565
542
 
@@ -624,25 +601,35 @@ class ReviewCosmicRay(ImageDisplay):
624
601
  print(f"Pixel ({ix+1}, {iy+1}), with signal {self.data[iy, ix]}, marked as cosmic ray.")
625
602
  xcr_list, ycr_list = np.where(self.cr_labels == self.cr_index)
626
603
  if len(xcr_list) == 0:
627
- self.interp_x_button.config(state=tk.DISABLED)
628
- self.interp_y_button.config(state=tk.DISABLED)
629
- self.interp_s_button.config(state=tk.DISABLED)
630
- self.interp_d_button.config(state=tk.DISABLED)
631
- self.interp_m_button.config(state=tk.DISABLED)
632
- self.interp_l_button.config(state=tk.DISABLED)
633
- self.interp_aux_button.config(state=tk.DISABLED)
604
+ self.disable_interpolation_buttons()
634
605
  self.remove_crosses_button.config(state=tk.DISABLED)
635
606
  else:
636
- self.interp_x_button.config(state=tk.NORMAL)
637
- self.interp_y_button.config(state=tk.NORMAL)
638
- self.interp_s_button.config(state=tk.NORMAL)
639
- self.interp_d_button.config(state=tk.NORMAL)
640
- self.interp_m_button.config(state=tk.NORMAL)
641
- if self.cleandata_lacosmic is not None:
642
- if self.last_dilation is None or self.last_dilation == 0:
643
- self.interp_l_button.config(state=tk.NORMAL)
644
- if self.auxdata is not None:
645
- self.interp_aux_button.config(state=tk.NORMAL)
607
+ self.enable_interpolation_buttons()
646
608
  self.remove_crosses_button.config(state=tk.NORMAL)
647
609
  # Update the display to reflect the change
648
610
  self.update_display()
611
+
612
+ def disable_interpolation_buttons(self):
613
+ """Disable all interpolation buttons."""
614
+ self.interp_x_button.config(state=tk.DISABLED)
615
+ self.interp_y_button.config(state=tk.DISABLED)
616
+ self.interp_s_button.config(state=tk.DISABLED)
617
+ self.interp_d_button.config(state=tk.DISABLED)
618
+ self.interp_m_button.config(state=tk.DISABLED)
619
+ self.interp_l_button.config(state=tk.DISABLED)
620
+ self.interp_maskfill_button.config(state=tk.DISABLED)
621
+ self.interp_aux_button.config(state=tk.DISABLED)
622
+
623
+ def enable_interpolation_buttons(self):
624
+ """Enable all interpolation buttons."""
625
+ self.interp_x_button.config(state=tk.NORMAL)
626
+ self.interp_y_button.config(state=tk.NORMAL)
627
+ self.interp_s_button.config(state=tk.NORMAL)
628
+ self.interp_d_button.config(state=tk.NORMAL)
629
+ self.interp_m_button.config(state=tk.NORMAL)
630
+ if self.cleandata_lacosmic is not None:
631
+ if self.last_dilation is None or self.last_dilation == 0:
632
+ self.interp_l_button.config(state=tk.NORMAL)
633
+ self.interp_maskfill_button.config(state=tk.NORMAL)
634
+ if self.auxdata is not None:
635
+ self.interp_aux_button.config(state=tk.NORMAL)
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.5.8'
12
+ VERSION = '0.5.9'
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.5.8
3
+ Version: 0.5.9
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: maskfill
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.4.3
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.
@@ -15,14 +15,14 @@ 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=G40b1Oo_cwqV4sHca8L26xY3VpGjlKvOFDTnZdytrtg,419
18
+ teareduce/version.py,sha256=Tab2zphBGQslnQsUawX1hJaJWEF6qYbHq13JXc12qms,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
22
- teareduce/cleanest/__init__.py,sha256=hHFtV6uBx6HAI8LFUDli0urznTUzMotCW9J_4EKGCXc,293
23
- teareduce/cleanest/__main__.py,sha256=cMzvNWNe2fuTGHLtT3hOc9-NAcMXDZUqHN0SSHWWDnc,5977
22
+ teareduce/cleanest/__init__.py,sha256=NEJ7JETeZFaKl8yW9gjLHIwfkI3F3B0TWQeCY3ESSrk,548
23
+ teareduce/cleanest/__main__.py,sha256=muijsFmB4kd0E5fn5ZhRHUH2bIPSRgykEUq3yg0K05c,5957
24
24
  teareduce/cleanest/centerchildparent.py,sha256=wHxOvNrrQ-KBLZAbtQ9bJAxYhGOzqYBF4LgdIQk7UF8,1285
25
- teareduce/cleanest/cosmicraycleanerapp.py,sha256=gugC79tdQFhT7plOWKqm5uTtjJCiWIeDpNmaCiE7aA4,50584
25
+ teareduce/cleanest/cosmicraycleanerapp.py,sha256=5z3tjfhoOQox3_NHi1oH2SudgPM_EjqMtz9nw6BKyqk,50882
26
26
  teareduce/cleanest/definitions.py,sha256=L7VXT0SAjv96zgZ_VhMMV1vcf-oxdwefvlmPclBA-ug,2558
27
27
  teareduce/cleanest/dilatemask.py,sha256=I5tHAv5VEO6V0Wed8Ar20uLt4F9P-tgjmLL5BAaFvgM,1276
28
28
  teareduce/cleanest/find_closest_true.py,sha256=mWdIvhipzAXDRKfePDrP7f0lP4U48cckpHiKwiB4jHI,1320
@@ -32,20 +32,20 @@ teareduce/cleanest/interpolation_a.py,sha256=zE4VIrC41vapf0Vx9qmh1oacw2qkJwcuMnV
32
32
  teareduce/cleanest/interpolation_x.py,sha256=D5hKbobT6lJk18XktP3PXhzEN12zqed6U18yfQ-reLQ,3744
33
33
  teareduce/cleanest/interpolation_y.py,sha256=O6yw5nKKlTdV6qsP1Ku6CwGhXB6o3j0_YQirXyILi8c,3759
34
34
  teareduce/cleanest/interpolationeditor.py,sha256=J5vrioLTwUSMbUeY0ezqNqm3CvLJgKFe7gvZ44Z62sc,13257
35
- teareduce/cleanest/lacosmicpad.py,sha256=xWaxifoF_B82Gm5czuJmL7Y4Cv0W___LlvcpH633bAo,2047
35
+ teareduce/cleanest/lacosmicpad.py,sha256=K_SU2YBds9I3eN0vJLkrbTLcdRpB2bMRf90_3Rk5ZIk,2345
36
36
  teareduce/cleanest/mergemasks.py,sha256=1Vq6Wqn6DClxSAvHwy6QrJGszA8nkmoMHITyprSykHI,2072
37
37
  teareduce/cleanest/modalprogressbar.py,sha256=uwd-p92PvOVJnbXd-B8DRcBZ--keKpr4ZN9PLeqm1Ws,6449
38
38
  teareduce/cleanest/parametereditor.py,sha256=_0baFbkIUcPyF-teFIRMt1MpA4IzDZc7VHNh1h0qN4A,14229
39
- teareduce/cleanest/reviewcosmicray.py,sha256=yTY9vNyYSuh_AZsIJAEtJ50mgIKhjgTe-LQob4xQx9U,29497
39
+ teareduce/cleanest/reviewcosmicray.py,sha256=QQaGMl_P9uWYBmDlPFIw7vEg_TI5DUJUhzBMdIShHC0,28297
40
40
  teareduce/cookbook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  teareduce/cookbook/get_cookbook_file.py,sha256=vde-iNii2lm1QII8GmLRsFsKNxkdsd7njCBE-8Z7io0,1088
42
42
  teareduce/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  teareduce/tests/test_cleanest.py,sha256=6dRqkw1RQMKsFrC8cEweMvTD6wXhiDv3P4PS57-HEqI,5598
44
44
  teareduce/tests/test_sliceregion.py,sha256=S7Zoh2eEBFIEbfsXgWBEMCf7pottjw2oLhqlZJQkAwg,3785
45
45
  teareduce/tests/test_version.py,sha256=mKLnbXyvVNc1pATq5PxR8qeoFMPAFL_GilFV6IHLOi0,172
46
- teareduce-0.5.8.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
47
- teareduce-0.5.8.dist-info/METADATA,sha256=Xm0x4wiGEoHvS_3tIk7gmaLHZbN0HDuN_Iec_wdQg84,3137
48
- teareduce-0.5.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
- teareduce-0.5.8.dist-info/entry_points.txt,sha256=6yBvig5jTL2ugqz5SF767AiszzrHKGRASsX1II84kqA,66
50
- teareduce-0.5.8.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
51
- teareduce-0.5.8.dist-info/RECORD,,
46
+ teareduce-0.5.9.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
47
+ teareduce-0.5.9.dist-info/METADATA,sha256=lk-aBMRThZ2tRIPajrP6yKD40TIow1WgzJ56ymTcOjU,3640
48
+ teareduce-0.5.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ teareduce-0.5.9.dist-info/entry_points.txt,sha256=6yBvig5jTL2ugqz5SF767AiszzrHKGRASsX1II84kqA,66
50
+ teareduce-0.5.9.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
51
+ teareduce-0.5.9.dist-info/RECORD,,