teareduce 0.5.7__py3-none-any.whl → 0.5.8__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.
@@ -17,6 +17,7 @@ from tkinter import simpledialog
17
17
  import sys
18
18
 
19
19
  from astropy.io import fits
20
+ from maskfill import maskfill
20
21
  import matplotlib.pyplot as plt
21
22
  from matplotlib.backend_bases import key_press_handler
22
23
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
@@ -773,6 +774,21 @@ class CosmicRayCleanerApp(ImageDisplay):
773
774
  # upate mask_crfound by eliminating the cleaned pixels
774
775
  self.mask_crfound[mask_crfound_region] = False
775
776
  data_has_been_modified = True
777
+ elif cleaning_method == "maskfill":
778
+ # Replace detected CR pixels with local median values
779
+ smoothed_output, _ = maskfill(
780
+ input_image=self.data,
781
+ mask=mask_crfound_region,
782
+ size=3,
783
+ operator="median",
784
+ smooth=True,
785
+ )
786
+ self.data[mask_crfound_region] = smoothed_output[mask_crfound_region]
787
+ # update mask_fixed to include the newly fixed pixels
788
+ self.mask_fixed[mask_crfound_region] = True
789
+ # upate mask_crfound by eliminating the cleaned pixels
790
+ self.mask_crfound[mask_crfound_region] = False
791
+ data_has_been_modified = True
776
792
  elif cleaning_method == "auxdata":
777
793
  if self.auxdata is None:
778
794
  print("No auxiliary data available. Cleaning skipped!")
@@ -43,7 +43,7 @@ lacosmic_default_dict = {
43
43
  }
44
44
 
45
45
  # Default parameters for cleaning methods
46
- VALID_CLEANING_METHODS = ["x interp.", "y interp.", "surface interp.", "median", "mean", "lacosmic", "auxdata"]
46
+ VALID_CLEANING_METHODS = ["x interp.", "y interp.", "surface interp.", "median", "mean", "lacosmic", "maskfill", "auxdata"]
47
47
 
48
48
  # Maximum pixel distance to consider when finding closest CR pixel
49
49
  MAX_PIXEL_DISTANCE_TO_CR = 15
@@ -97,6 +97,7 @@ class InterpolationEditor:
97
97
  "median": "a-median",
98
98
  "mean": "a-mean",
99
99
  "lacosmic": "lacosmic",
100
+ "maskfill": "maskfill",
100
101
  "auxdata": "auxdata",
101
102
  }
102
103
  self.check_interp_methods()
@@ -13,6 +13,7 @@ import tkinter as tk
13
13
  from tkinter import messagebox
14
14
  from tkinter import simpledialog
15
15
 
16
+ from maskfill import maskfill
16
17
  import matplotlib.pyplot as plt
17
18
  from matplotlib.backend_bases import key_press_handler
18
19
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
@@ -150,7 +151,7 @@ class ReviewCosmicRay(ImageDisplay):
150
151
  self.root.minsize(1000, 700)
151
152
  else:
152
153
  # self.root.geometry("800x700+100+100") # This does not work in Fedora
153
- self.root.minsize(800, 700)
154
+ self.root.minsize(900, 700)
154
155
  self.root.update_idletasks()
155
156
  self.root.geometry("+100+100")
156
157
  self.data = data
@@ -224,6 +225,8 @@ class ReviewCosmicRay(ImageDisplay):
224
225
  self.interp_l_button.config(state=tk.DISABLED)
225
226
  if self.cleandata_lacosmic is None:
226
227
  self.interp_l_button.config(state=tk.DISABLED)
228
+ self.interp_maskfill_button = tk.Button(self.button_frame2, text="mas[k]fill", command=self.use_maskfill)
229
+ self.interp_maskfill_button.pack(side=tk.LEFT, padx=5)
227
230
  self.interp_aux_button = tk.Button(self.button_frame2, text="[a]ux. data", command=self.use_auxdata)
228
231
  self.interp_aux_button.pack(side=tk.LEFT, padx=5)
229
232
  if self.auxdata is None:
@@ -246,7 +249,7 @@ class ReviewCosmicRay(ImageDisplay):
246
249
  if self.auxdata is not None:
247
250
  self.fig, (self.ax_aux, self.ax) = plt.subplots(ncols=2, figsize=(11, 5.5), constrained_layout=True)
248
251
  else:
249
- self.fig, self.ax = plt.subplots(figsize=(8, 5.5), constrained_layout=True)
252
+ self.fig, self.ax = plt.subplots(figsize=(9, 5.5), constrained_layout=True)
250
253
  self.canvas = FigureCanvasTkAgg(self.fig, master=self.root)
251
254
  self.canvas.get_tk_widget().pack(padx=5, pady=5)
252
255
  # The next two instructions prevent a segmentation fault when pressing "q"
@@ -376,6 +379,7 @@ class ReviewCosmicRay(ImageDisplay):
376
379
  self.interp_d_button.config(state=tk.DISABLED)
377
380
  self.interp_m_button.config(state=tk.DISABLED)
378
381
  self.interp_l_button.config(state=tk.DISABLED)
382
+ self.interp_maskfill_button.config(state=tk.DISABLED)
379
383
  self.interp_aux_button.config(state=tk.DISABLED)
380
384
 
381
385
  def interp_x(self):
@@ -461,6 +465,27 @@ class ReviewCosmicRay(ImageDisplay):
461
465
  self.set_buttons_after_cleaning_cr()
462
466
  self.update_display(cleaned=True)
463
467
 
468
+ def use_maskfill(self):
469
+ """Use maskfill cleaned data to clean a cosmic ray."""
470
+ print(f"Maskfill interpolation of cosmic ray {self.cr_index}")
471
+ ycr_list, xcr_list = np.where(self.cr_labels == self.cr_index)
472
+ mask = np.zeros(self.data.shape, dtype=bool)
473
+ for iy, ix in zip(ycr_list, xcr_list):
474
+ mask[iy, ix] = True
475
+ smoothed_output, _ = maskfill(
476
+ input_image=self.data,
477
+ mask=mask,
478
+ size=3,
479
+ operator="median",
480
+ smooth=True,
481
+ )
482
+ for iy, ix in zip(ycr_list, xcr_list):
483
+ self.data[iy, ix] = smoothed_output[iy, ix]
484
+ self.mask_fixed[iy, ix] = True
485
+ self.num_cr_cleaned += 1
486
+ self.set_buttons_after_cleaning_cr()
487
+ self.update_display(cleaned=True)
488
+
464
489
  def use_auxdata(self):
465
490
  """Use auxiliary data to clean a cosmic ray."""
466
491
  if self.auxdata is None:
@@ -505,6 +530,7 @@ class ReviewCosmicRay(ImageDisplay):
505
530
  if self.cleandata_lacosmic is not None:
506
531
  if self.last_dilation is None or self.last_dilation == 0:
507
532
  self.interp_l_button.config(state=tk.NORMAL)
533
+ self.interp_maskfill_button.config(state=tk.NORMAL)
508
534
  if self.auxdata is not None:
509
535
  self.interp_aux_button.config(state=tk.NORMAL)
510
536
  print(f"Restored all pixels of cosmic ray {self.cr_index}")
@@ -566,6 +592,9 @@ class ReviewCosmicRay(ImageDisplay):
566
592
  elif event.key == "l":
567
593
  if self.interp_l_button.cget("state") != "disabled":
568
594
  self.use_lacosmic()
595
+ elif event.key == "k":
596
+ if self.interp_maskfill_button.cget("state") != "disabled":
597
+ self.use_maskfill()
569
598
  elif event.key == "a":
570
599
  if self.interp_aux_button.cget("state") != "disabled":
571
600
  self.use_auxdata()
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.7'
12
+ VERSION = '0.5.8'
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.7
3
+ Version: 0.5.8
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
@@ -23,6 +23,7 @@ Requires-Dist: astropy
23
23
  Requires-Dist: ccdproc
24
24
  Requires-Dist: lmfit
25
25
  Requires-Dist: matplotlib
26
+ Requires-Dist: maskfill
26
27
  Requires-Dist: numpy>=1.22
27
28
  Requires-Dist: requests
28
29
  Requires-Dist: rich
@@ -15,15 +15,15 @@ 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=oqn_gabhd81ghdha2yfonHK150M_SY20r86f1CEW9bg,419
18
+ teareduce/version.py,sha256=G40b1Oo_cwqV4sHca8L26xY3VpGjlKvOFDTnZdytrtg,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
22
  teareduce/cleanest/__init__.py,sha256=hHFtV6uBx6HAI8LFUDli0urznTUzMotCW9J_4EKGCXc,293
23
23
  teareduce/cleanest/__main__.py,sha256=cMzvNWNe2fuTGHLtT3hOc9-NAcMXDZUqHN0SSHWWDnc,5977
24
24
  teareduce/cleanest/centerchildparent.py,sha256=wHxOvNrrQ-KBLZAbtQ9bJAxYhGOzqYBF4LgdIQk7UF8,1285
25
- teareduce/cleanest/cosmicraycleanerapp.py,sha256=FKeQYCUhvod6HDSOqZN79QhVoujhC2_iQsyP1tF3P9o,49726
26
- teareduce/cleanest/definitions.py,sha256=HLv41cuhUOUyEicRHea0LRTv4Wagm24miSxFt4cZN3g,2546
25
+ teareduce/cleanest/cosmicraycleanerapp.py,sha256=gugC79tdQFhT7plOWKqm5uTtjJCiWIeDpNmaCiE7aA4,50584
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
29
29
  teareduce/cleanest/imagedisplay.py,sha256=820Vn-Q0bJyHicOBsxDmfAZxuGOFepEEsm0LTxlPJjc,5848
@@ -31,21 +31,21 @@ teareduce/cleanest/interpolate.py,sha256=qlz4SHw89ahBRx1VHBMkd0IEpFkd96P6FVfsw_L
31
31
  teareduce/cleanest/interpolation_a.py,sha256=zE4VIrC41vapf0Vx9qmh1oacw2qkJwcuMnV3JpSDW8Y,4007
32
32
  teareduce/cleanest/interpolation_x.py,sha256=D5hKbobT6lJk18XktP3PXhzEN12zqed6U18yfQ-reLQ,3744
33
33
  teareduce/cleanest/interpolation_y.py,sha256=O6yw5nKKlTdV6qsP1Ku6CwGhXB6o3j0_YQirXyILi8c,3759
34
- teareduce/cleanest/interpolationeditor.py,sha256=EksuNwKOM79MyGlAgxb9j-v7pIFXV8QOcyZDLVQlQjU,13221
34
+ teareduce/cleanest/interpolationeditor.py,sha256=J5vrioLTwUSMbUeY0ezqNqm3CvLJgKFe7gvZ44Z62sc,13257
35
35
  teareduce/cleanest/lacosmicpad.py,sha256=xWaxifoF_B82Gm5czuJmL7Y4Cv0W___LlvcpH633bAo,2047
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=_qO9ifkAMqB4Wuvq2wIYZ8_DUniB2lWcxn9l404hXnY,28210
39
+ teareduce/cleanest/reviewcosmicray.py,sha256=yTY9vNyYSuh_AZsIJAEtJ50mgIKhjgTe-LQob4xQx9U,29497
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.7.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
47
- teareduce-0.5.7.dist-info/METADATA,sha256=q725fGixcsrRvW2iS9-QRgBPi54dZqjOILxmzEDBShs,3113
48
- teareduce-0.5.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
- teareduce-0.5.7.dist-info/entry_points.txt,sha256=6yBvig5jTL2ugqz5SF767AiszzrHKGRASsX1II84kqA,66
50
- teareduce-0.5.7.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
51
- teareduce-0.5.7.dist-info/RECORD,,
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,,