teareduce 0.2.5__py3-none-any.whl → 0.3.0__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.
teareduce/__init__.py CHANGED
@@ -8,6 +8,7 @@
8
8
  #
9
9
 
10
10
  from .avoid_astropy_warnings import avoid_astropy_warnings
11
+ from .correct_pincushion_distortion import correct_pincushion_distortion
11
12
  from .cosmicrays import cr2images, apply_cr2images_ccddata, crmedian
12
13
  from .ctext import ctext
13
14
  from .draw_rectangle import draw_rectangle
@@ -0,0 +1,60 @@
1
+ #
2
+ # Copyright 2024 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
+ from astropy.io import fits
11
+ import numpy as np
12
+ from numpy.polynomial import Polynomial
13
+
14
+
15
+ def correct_pincushion_distortion(coeff_filename, data):
16
+ """Correct pincushion distortion.
17
+
18
+ Parameters
19
+ ----------
20
+ coeff_filename : str
21
+ Name of the FITS file containing the polynomial coefficients
22
+ of the transformation between the Y-coordinates of the central
23
+ image column and the measured Y-coordinates (for each image
24
+ column).
25
+ data : `~numpy.ndarray`
26
+ Array containing the image to be corrected.
27
+
28
+ Returns
29
+ -------
30
+ data_rectified : `~numpy.ndarray`
31
+ Rectified image.
32
+ """
33
+
34
+ # read FITS file with polynomial coefficients
35
+
36
+ with fits.open(coeff_filename) as hdul:
37
+ table = hdul[1].data
38
+
39
+ # check dimensions
40
+ naxis2, naxis1 = data.shape
41
+ if naxis1 != len(table):
42
+ raise ValueError(f'Incompatible dimensions: naxis1:{naxis1} != len(table): {len(table)}')
43
+
44
+ # rectify image
45
+ accum_flux = np.zeros((naxis2 + 1, naxis1))
46
+ accum_flux[1:, :] = np.cumsum(data, axis=0)
47
+ new_y_borders = np.arange(naxis2 + 1) - 0.5
48
+ data_rectified = np.zeros((naxis2, naxis1))
49
+ for i in range(naxis1):
50
+ poly = Polynomial(coef=table[i])
51
+ flux_borders = np.interp(
52
+ x=new_y_borders,
53
+ xp=poly(new_y_borders),
54
+ fp=accum_flux[:, i],
55
+ left=0,
56
+ right=accum_flux[-1, i]
57
+ )
58
+ data_rectified[:, i] = flux_borders[1:] - flux_borders[:-1]
59
+
60
+ return data_rectified
teareduce/sdistortion.py CHANGED
@@ -54,6 +54,8 @@ def fit_sdistortion(data, ns_min, ns_max, nc_min, nc_max,
54
54
  -------
55
55
  data_straight : numpy array
56
56
  2D spectroscopic image corrected from S distortion.
57
+ poly_funct_peaks : `~numpy.polynomial.polynomial.Polynomial`
58
+ Fitted polynomial.
57
59
 
58
60
  """
59
61
 
@@ -177,4 +179,4 @@ def fit_sdistortion(data, ns_min, ns_max, nc_min, nc_max,
177
179
  plt.show()
178
180
 
179
181
  # return result
180
- return data_straight
182
+ return data_straight, poly_funct_peaks
teareduce/version.py CHANGED
@@ -8,7 +8,7 @@
8
8
  # License-Filename: LICENSE.txt
9
9
  #
10
10
 
11
- version = '0.2.5'
11
+ version = '0.3.0'
12
12
 
13
13
 
14
14
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: teareduce
3
- Version: 0.2.5
3
+ Version: 0.3.0
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
@@ -1,5 +1,6 @@
1
- teareduce/__init__.py,sha256=NVBoSQQ4L2yeGSde9ZSowcSimYq2aFIaLWkIEMzRZdI,909
1
+ teareduce/__init__.py,sha256=kAUSGwgPx3jjWFxHz_Nd1axOGv6tug6utent6WB2tQ4,982
2
2
  teareduce/avoid_astropy_warnings.py,sha256=2YgQ47pxsKYWDxUtzyEOfh3Is3aAHHmjJkuOa1JCDN4,648
3
+ teareduce/correct_pincushion_distortion.py,sha256=Xpt03jtmJMyqik4ta95zMRE3Z6dVfzzHI2z5IDbtnMk,1685
3
4
  teareduce/cosmicrays.py,sha256=y8f5KLUsiOeOkArGnZVi_q11chsgnYlwtxbSD_a9EAQ,24209
4
5
  teareduce/ctext.py,sha256=8QP_KW7ueJ34IUyduVpy7nk-x0If5eilawf87icDMJA,2084
5
6
  teareduce/draw_rectangle.py,sha256=xlwcKIkl7e0U6sa9zWZr8t_WuWAte_UKIqCwZQ41x4Q,1922
@@ -8,14 +9,14 @@ teareduce/imshow.py,sha256=PbQiOGjr3uKk7gkQDjIl5VLMxcGu7Ezu4rEs-oMysiM,3852
8
9
  teareduce/peaks_spectrum.py,sha256=YPCJz8skJmIjWYqT7ZhBJGhnqPayFwy5xb7I9OHlUZI,9890
9
10
  teareduce/polfit.py,sha256=CGsrRsz_Du2aKxOcgXi36lpAZO04JyqCCUaxhC0C-Mk,14281
10
11
  teareduce/robust_std.py,sha256=dk1G3VgiplZzmSfL7qWniEZ-5c3novHnBpRPCM77u84,1084
11
- teareduce/sdistortion.py,sha256=uGz_LSEGlTLB5m_MzE7GRvu-BwzQxbPiFrr0OWWXDVY,5806
12
+ teareduce/sdistortion.py,sha256=5ZsZn4vD5Sw2aoqO8-NIOH7H89Zmh7ZDkow6YbAotHU,5916
12
13
  teareduce/sliceregion.py,sha256=ACMfl5jDL0Bw2fnhZBzhvyDRiI7RoD5ut-xZ8sgnz8Q,5104
13
14
  teareduce/statsummary.py,sha256=mtaM21d5aHvtLjCt_SSDMvD_fjI5nK21ZqxuDtcvldI,5426
14
- teareduce/version.py,sha256=yjIBjM08UpfJ9I_cr0DQb8IqdCEHktVpqJ97BYudqag,303
15
+ teareduce/version.py,sha256=lGfmM62wUELqVGMKXx5GeQkRf5tGpuhjbZ_xEp5S5pI,303
15
16
  teareduce/wavecal.py,sha256=iiKG_RPW2CllwZxG5fTsyckE0Ec_IeZ6v7v2cQt6OeU,68706
16
17
  teareduce/zscale.py,sha256=HuPYagTW55D7RtjPGc7HcibQlCx5oqLYHKoM6WEHG2g,1161
17
- teareduce-0.2.5.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
18
- teareduce-0.2.5.dist-info/METADATA,sha256=ouUdTEEI75npkM3X_gTmXVs71NBbarV7D6nwOMRwRvM,2283
19
- teareduce-0.2.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
20
- teareduce-0.2.5.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
21
- teareduce-0.2.5.dist-info/RECORD,,
18
+ teareduce-0.3.0.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
19
+ teareduce-0.3.0.dist-info/METADATA,sha256=DxNiP1qngg725QTdznJf0nOazd63V2i77SeVlnWdDo0,2283
20
+ teareduce-0.3.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
21
+ teareduce-0.3.0.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
22
+ teareduce-0.3.0.dist-info/RECORD,,