teareduce 0.2.5__tar.gz → 0.3.0__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.
- {teareduce-0.2.5/src/teareduce.egg-info → teareduce-0.3.0}/PKG-INFO +1 -1
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/__init__.py +1 -0
- teareduce-0.3.0/src/teareduce/correct_pincushion_distortion.py +60 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/sdistortion.py +3 -1
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/version.py +1 -1
- {teareduce-0.2.5 → teareduce-0.3.0/src/teareduce.egg-info}/PKG-INFO +1 -1
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce.egg-info/SOURCES.txt +1 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/LICENSE.txt +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/README.md +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/pyproject.toml +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/setup.cfg +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/avoid_astropy_warnings.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/cosmicrays.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/ctext.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/draw_rectangle.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/elapsed_time.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/imshow.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/peaks_spectrum.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/polfit.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/robust_std.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/sliceregion.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/statsummary.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/wavecal.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce/zscale.py +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce.egg-info/dependency_links.txt +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce.egg-info/requires.txt +0 -0
- {teareduce-0.2.5 → teareduce-0.3.0}/src/teareduce.egg-info/top_level.txt +0 -0
|
@@ -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
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|