teareduce 0.3.5__tar.gz → 0.4.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.3.5/src/teareduce.egg-info → teareduce-0.4.0}/PKG-INFO +2 -2
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/__init__.py +5 -1
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/elapsed_time.py +17 -1
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/imshow.py +47 -8
- teareduce-0.4.0/src/teareduce/simulateccdexposure.py +639 -0
- teareduce-0.4.0/src/teareduce/sliceregion.py +263 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/version.py +1 -1
- teareduce-0.4.0/src/teareduce/write_array_to_fits.py +28 -0
- {teareduce-0.3.5 → teareduce-0.4.0/src/teareduce.egg-info}/PKG-INFO +2 -2
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce.egg-info/SOURCES.txt +3 -0
- teareduce-0.3.5/src/teareduce/sliceregion.py +0 -148
- {teareduce-0.3.5 → teareduce-0.4.0}/LICENSE.txt +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/README.md +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/pyproject.toml +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/setup.cfg +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/avoid_astropy_warnings.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/correct_pincushion_distortion.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/cosmicrays.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/ctext.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/draw_rectangle.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/numsplines.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/peaks_spectrum.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/polfit.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/robust_std.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/sdistortion.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/statsummary.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/wavecal.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce/zscale.py +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce.egg-info/dependency_links.txt +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce.egg-info/requires.txt +0 -0
- {teareduce-0.3.5 → teareduce-0.4.0}/src/teareduce.egg-info/top_level.txt +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright 2023-
|
|
2
|
+
# Copyright 2023-2025 Universidad Complutense de Madrid
|
|
3
3
|
#
|
|
4
4
|
# This file is part of teareduce
|
|
5
5
|
#
|
|
@@ -13,7 +13,9 @@ from .cosmicrays import cr2images, apply_cr2images_ccddata, crmedian
|
|
|
13
13
|
from .ctext import ctext
|
|
14
14
|
from .draw_rectangle import draw_rectangle
|
|
15
15
|
from .elapsed_time import elapsed_time
|
|
16
|
+
from .elapsed_time import elapsed_time_since
|
|
16
17
|
from .imshow import imshow
|
|
18
|
+
from .imshow import imshowme
|
|
17
19
|
from .numsplines import AdaptiveLSQUnivariateSpline
|
|
18
20
|
from .peaks_spectrum import find_peaks_spectrum, refine_peaks_spectrum
|
|
19
21
|
from .polfit import polfit_residuals, polfit_residuals_with_sigma_rejection
|
|
@@ -21,8 +23,10 @@ from .robust_std import robust_std
|
|
|
21
23
|
from .sdistortion import fit_sdistortion
|
|
22
24
|
from .sliceregion import SliceRegion1D, SliceRegion2D
|
|
23
25
|
from .statsummary import ifc_statsummary, statsummary
|
|
26
|
+
from .simulateccdexposure import SimulateCCDExposure
|
|
24
27
|
from .version import version
|
|
25
28
|
from .wavecal import TeaWaveCalibration, apply_wavecal_ccddata
|
|
29
|
+
from .write_array_to_fits import write_array_to_fits
|
|
26
30
|
from .zscale import zscale
|
|
27
31
|
|
|
28
32
|
__version__ = version
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
#
|
|
3
|
-
# Copyright 2024 Universidad Complutense de Madrid
|
|
3
|
+
# Copyright 2024-2025 Universidad Complutense de Madrid
|
|
4
4
|
#
|
|
5
5
|
# This file is part of teareduce
|
|
6
6
|
#
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
# License-Filename: LICENSE.txt
|
|
9
9
|
#
|
|
10
10
|
|
|
11
|
+
from datetime import datetime
|
|
11
12
|
import platform
|
|
12
13
|
import sys
|
|
13
14
|
from .version import version
|
|
@@ -39,3 +40,18 @@ def elapsed_time(time_ini, time_end, osinfo=True):
|
|
|
39
40
|
print(f"Initial time.....: {time_ini}")
|
|
40
41
|
print(f"Final time.......: {time_end}")
|
|
41
42
|
print(f"Elapsed time.....: {time_end - time_ini}")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def elapsed_time_since(time_ini, osinfo=True):
|
|
46
|
+
"""Display elapsed time and OS info since a given time.
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
time_ini : datetime instance
|
|
51
|
+
Initial time.
|
|
52
|
+
osinfo : bool
|
|
53
|
+
If True, display OS info.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
time_end = datetime.now()
|
|
57
|
+
elapsed_time(time_ini, time_end)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright 2022-
|
|
2
|
+
# Copyright 2022-2025 Universidad Complutense de Madrid
|
|
3
3
|
#
|
|
4
4
|
# This file is part of teareduce
|
|
5
5
|
#
|
|
@@ -7,12 +7,37 @@
|
|
|
7
7
|
# License-Filename: LICENSE.txt
|
|
8
8
|
#
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
from astropy.units import Unit
|
|
11
|
+
from matplotlib import pyplot as plt
|
|
12
|
+
from matplotlib.figure import Figure
|
|
13
|
+
from matplotlib.axes import Axes
|
|
11
14
|
from mpl_toolkits.axes_grid1 import make_axes_locatable
|
|
12
15
|
|
|
13
16
|
|
|
17
|
+
def imshowme(data, **kwargs):
|
|
18
|
+
"""Simple execution of teareduce.imshow.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
data : numpy.ndarray
|
|
23
|
+
2D array to be displayed
|
|
24
|
+
|
|
25
|
+
Returns
|
|
26
|
+
-------
|
|
27
|
+
fig : matplotlib.figure.Figure
|
|
28
|
+
Instance of Figure.
|
|
29
|
+
ax : matplotlib.axes.Axes
|
|
30
|
+
Instance of Axes.
|
|
31
|
+
img : matplotlib AxesImage
|
|
32
|
+
Instance returned by ax.imshow()
|
|
33
|
+
"""
|
|
34
|
+
fig, ax = plt.subplots()
|
|
35
|
+
img = imshow(fig=fig, ax=ax, data=data, **kwargs)
|
|
36
|
+
return fig, ax, img
|
|
37
|
+
|
|
38
|
+
|
|
14
39
|
def imshow(fig=None, ax=None, data=None,
|
|
15
|
-
crpix1=1, crval1=None, cdelt1=None, cunit1=None, cunitx=
|
|
40
|
+
crpix1=1, crval1=None, cdelt1=None, cunit1=None, cunitx=Unit('Angstrom'),
|
|
16
41
|
xlabel=None, ylabel=None, title=None,
|
|
17
42
|
colorbar=True, cblabel='Number of counts',
|
|
18
43
|
**kwargs):
|
|
@@ -25,9 +50,9 @@ def imshow(fig=None, ax=None, data=None,
|
|
|
25
50
|
Parameters
|
|
26
51
|
----------
|
|
27
52
|
fig : matplotlib.figure.Figure
|
|
28
|
-
Figure
|
|
53
|
+
Instance of Figure.
|
|
29
54
|
ax : matplotlib.axes.Axes
|
|
30
|
-
Axes
|
|
55
|
+
Instance of Axes.
|
|
31
56
|
data : numpy array
|
|
32
57
|
2D array to be displayed.
|
|
33
58
|
crpix1 : astropy.units.Quantity
|
|
@@ -63,6 +88,13 @@ def imshow(fig=None, ax=None, data=None,
|
|
|
63
88
|
|
|
64
89
|
"""
|
|
65
90
|
|
|
91
|
+
# protections
|
|
92
|
+
if not isinstance(fig, Figure):
|
|
93
|
+
raise ValueError("Unexpected 'fig' argument")
|
|
94
|
+
if not isinstance(ax, Axes):
|
|
95
|
+
raise ValueError("Unexpected 'ax' argument")
|
|
96
|
+
|
|
97
|
+
# default labels
|
|
66
98
|
if xlabel is None:
|
|
67
99
|
xlabel = 'X axis (array index)'
|
|
68
100
|
|
|
@@ -77,13 +109,18 @@ def imshow(fig=None, ax=None, data=None,
|
|
|
77
109
|
naxis2, naxis1 = data.shape
|
|
78
110
|
xmin, xmax = -0.5, naxis1 - 0.5
|
|
79
111
|
ymin, ymax = -0.5, naxis2 - 0.5
|
|
80
|
-
|
|
81
|
-
|
|
112
|
+
u_pixel = Unit('pixel')
|
|
113
|
+
xminwv = crval1 + (xmin * u_pixel - crpix1 + 1 * u_pixel) * cdelt1
|
|
114
|
+
xmaxwv = crval1 + (xmax * u_pixel - crpix1 + 1 * u_pixel) * cdelt1
|
|
82
115
|
extent = [xminwv.to(cunitx).value, xmaxwv.to(cunitx).value, ymin, ymax]
|
|
83
116
|
xlabel = f'Wavelength ({cunitx})'
|
|
84
117
|
aspect = 'auto'
|
|
85
118
|
else:
|
|
86
|
-
extent
|
|
119
|
+
if 'extent' in kwargs:
|
|
120
|
+
extent = kwargs['extent']
|
|
121
|
+
del kwargs['extent']
|
|
122
|
+
else:
|
|
123
|
+
extent = None
|
|
87
124
|
if 'aspect' in kwargs:
|
|
88
125
|
aspect = kwargs['aspect']
|
|
89
126
|
del kwargs['aspect']
|
|
@@ -110,3 +147,5 @@ def imshow(fig=None, ax=None, data=None,
|
|
|
110
147
|
divider = make_axes_locatable(ax)
|
|
111
148
|
cax = divider.append_axes("right", size="5%", pad=0.05)
|
|
112
149
|
fig.colorbar(img, cax=cax, label=cblabel)
|
|
150
|
+
|
|
151
|
+
return img
|