teareduce 0.4.2__py3-none-any.whl → 0.4.3__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
@@ -14,6 +14,8 @@ from .ctext import ctext
14
14
  from .draw_rectangle import draw_rectangle
15
15
  from .elapsed_time import elapsed_time
16
16
  from .elapsed_time import elapsed_time_since
17
+ from .histogram1d import hist_step
18
+ from .histogram1d import plot_hist_step
17
19
  from .imshow import imshow
18
20
  from .imshow import imshowme
19
21
  from .numsplines import AdaptiveLSQUnivariateSpline
@@ -21,9 +23,9 @@ from .peaks_spectrum import find_peaks_spectrum, refine_peaks_spectrum
21
23
  from .polfit import polfit_residuals, polfit_residuals_with_sigma_rejection
22
24
  from .robust_std import robust_std
23
25
  from .sdistortion import fit_sdistortion
26
+ from .simulateccdexposure import SimulateCCDExposure
24
27
  from .sliceregion import SliceRegion1D, SliceRegion2D, SliceRegion3D
25
28
  from .statsummary import ifc_statsummary, statsummary
26
- from .simulateccdexposure import SimulateCCDExposure
27
29
  from .version import VERSION
28
30
  from .wavecal import TeaWaveCalibration, apply_wavecal_ccddata
29
31
  from .write_array_to_fits import write_array_to_fits
@@ -0,0 +1,85 @@
1
+ #
2
+ # Copyright 2025 Universidad Complutense de Madrid
3
+ #
4
+ # This file is part of teareduce
5
+ #
6
+ # SPDX-License-Identifier: GPL-3.0-or-later
7
+ # License-Filename: LICENSE.txt
8
+ #
9
+
10
+ """Auxiliary function to display 1D histograms computed with numpy"""
11
+
12
+ import numpy as np
13
+
14
+
15
+ def plot_hist_step(ax, bins, h, color='C0', alpha=1.0, fill_color=None, fill_alpha=0.4):
16
+ """Plot histogram already computed.
17
+
18
+ Parameters
19
+ ----------
20
+ ax : matplotlib.axes.Axes
21
+ Axes to plot on.
22
+ bins : np.ndarray
23
+ Array of bin edges.
24
+ h : np.ndarray
25
+ Array of histogram values.
26
+ color : str, optional
27
+ Color of the histogram line, by default 'C0'.
28
+ alpha : float, optional
29
+ Transparency of the histogram line, by default 1.0.
30
+ fill_color : str, optional
31
+ Color to fill the histogram area, by default None (no fill).
32
+ fill_alpha : float, optional
33
+ Transparency of the filled area, by default 0.4.
34
+ """
35
+ # bin centers
36
+ xdum = (bins[:-1] + bins[1:]) / 2
37
+ ax.step(xdum, h, where='mid')
38
+ # draw vertical lines at the edges
39
+ ax.plot([bins[0], bins[0], xdum[0]], [0, h[0], h[0]], alpha=alpha, color=f'{color}', linestyle='-')
40
+ ax.plot([xdum[-1], bins[-1], bins[-1]], [h[-1], h[-1], 0], alpha=alpha, color=f'{color}', linestyle='-')
41
+ # fill area under the histogram
42
+ if fill_color is not None:
43
+ ax.fill_between(np.concatenate((np.array([bins[0]]), xdum, np.array([bins[-1]]))),
44
+ np.concatenate((np.array([h[0]]), h, np.array([h[-1]]))),
45
+ step='mid', alpha=fill_alpha, color=f'{fill_color}')
46
+
47
+
48
+ def hist_step(ax, data, bins, color='C0', alpha=1.0, fill_color=None, fill_alpha=0.4):
49
+ """Compute and plot histogram of data.
50
+
51
+ Parameters
52
+ ----------
53
+ ax : matplotlib.axes.Axes
54
+ Axes to plot on.
55
+ data : np.ndarray
56
+ Data to compute the histogram from.
57
+ bins : int or np.ndarray
58
+ Number of bins or array of bin edges.
59
+ color : str, optional
60
+ Color of the histogram line, by default 'C0'.
61
+ alpha : float, optional
62
+ Transparency of the histogram line, by default 1.0.
63
+ fill_color : str, optional
64
+ Color to fill the histogram area, by default None (no fill).
65
+ fill_alpha : float, optional
66
+ Transparency of the filled area, by default 0.4.
67
+
68
+ Returns
69
+ -------
70
+ h : np.ndarray
71
+ Histogram values.
72
+ edges : np.ndarray
73
+ Bin edges of the histogram.
74
+ """
75
+
76
+ if isinstance(bins, int):
77
+ bins = np.linspace(np.min(data), np.max(data), bins + 1)
78
+ elif isinstance(bins, np.ndarray):
79
+ pass
80
+ else:
81
+ raise ValueError(f'Unexpected {bins=}')
82
+ h, edges = np.histogram(data, bins=bins)
83
+ plot_hist_step(ax, bins, h, color=color, alpha=alpha, fill_color=fill_color, fill_alpha=fill_alpha)
84
+
85
+ return h, edges
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.4.2'
12
+ VERSION = '0.4.3'
13
13
 
14
14
 
15
15
  def main():
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: teareduce
3
- Version: 0.4.2
3
+ Version: 0.4.3
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
7
7
  Project-URL: Homepage, https://github.com/nicocardiel/teareduce
8
8
  Project-URL: Repository, https://github.com/nicocardiel/teareduce.git
9
- Classifier: Programming Language :: Python :: 3.9
10
9
  Classifier: Programming Language :: Python :: 3.10
11
10
  Classifier: Programming Language :: Python :: 3.11
12
11
  Classifier: Programming Language :: Python :: 3.12
@@ -14,16 +13,16 @@ Classifier: Programming Language :: Python :: 3.13
14
13
  Classifier: Development Status :: 3 - Alpha
15
14
  Classifier: Environment :: Console
16
15
  Classifier: Intended Audience :: Science/Research
17
- Classifier: License :: OSI Approved :: GNU General Public License (GPL)
16
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
18
17
  Classifier: Operating System :: OS Independent
19
18
  Classifier: Topic :: Scientific/Engineering :: Astronomy
20
- Requires-Python: >=3.9
19
+ Requires-Python: >=3.10
21
20
  Description-Content-Type: text/markdown
22
21
  License-File: LICENSE.txt
23
22
  Requires-Dist: astropy
24
23
  Requires-Dist: lmfit
25
24
  Requires-Dist: matplotlib
26
- Requires-Dist: numpy>=1.20
25
+ Requires-Dist: numpy>=1.22
27
26
  Requires-Dist: scipy
28
27
  Requires-Dist: tqdm
29
28
  Provides-Extra: test
@@ -1,10 +1,11 @@
1
- teareduce/__init__.py,sha256=s3CE0R7rKhqBL_KJQD8Gzro_YzzWYZWZvTTKsJxCwBs,1229
1
+ teareduce/__init__.py,sha256=u-6eZ9oz2reoSWxm1kf-9uj2VB4yERhh7fuE5gd4-RA,1304
2
2
  teareduce/avoid_astropy_warnings.py,sha256=2YgQ47pxsKYWDxUtzyEOfh3Is3aAHHmjJkuOa1JCDN4,648
3
3
  teareduce/correct_pincushion_distortion.py,sha256=Xpt03jtmJMyqik4ta95zMRE3Z6dVfzzHI2z5IDbtnMk,1685
4
4
  teareduce/cosmicrays.py,sha256=gLHgq9LdfNHmZ5n_FYxvxcGI2245TXGV-rFHSIogxPE,26877
5
5
  teareduce/ctext.py,sha256=8QP_KW7ueJ34IUyduVpy7nk-x0If5eilawf87icDMJA,2084
6
6
  teareduce/draw_rectangle.py,sha256=xlwcKIkl7e0U6sa9zWZr8t_WuWAte_UKIqCwZQ41x4Q,1922
7
7
  teareduce/elapsed_time.py,sha256=QWakPeiOUA__WpjjFREnodKqW1FZzVGWstab0N3Ro6k,1418
8
+ teareduce/histogram1d.py,sha256=3hlvcI8XPRmZ27H_sFmyL26gIcbJozk07ELBKWtngQk,2835
8
9
  teareduce/imshow.py,sha256=5j5RFoZOWBkF8CzUSLTR8-fNuuZHOFCMgH2CMOaDu50,4878
9
10
  teareduce/numsplines.py,sha256=1PpG-frdc9Qz3VRbC7XyZFWKmhus05ID4REtFnWDmUo,8049
10
11
  teareduce/peaks_spectrum.py,sha256=YPCJz8skJmIjWYqT7ZhBJGhnqPayFwy5xb7I9OHlUZI,9890
@@ -14,14 +15,14 @@ teareduce/sdistortion.py,sha256=5ZsZn4vD5Sw2aoqO8-NIOH7H89Zmh7ZDkow6YbAotHU,5916
14
15
  teareduce/simulateccdexposure.py,sha256=cdbpca6GVuM3d7R1LGzlIZZvjTq_jzrlkk_Cli7aouQ,24636
15
16
  teareduce/sliceregion.py,sha256=0h1xYcNG4mkJhR6bdaDe9pF2_MCuGeLJC7WVbbMZy8E,14977
16
17
  teareduce/statsummary.py,sha256=mtaM21d5aHvtLjCt_SSDMvD_fjI5nK21ZqxuDtcvldI,5426
17
- teareduce/version.py,sha256=wjxC_ZqjyEt9M9ZWw8WzCFiL0HIKJb6sqwgoZWMffL4,419
18
+ teareduce/version.py,sha256=SH9n_ZVdY2JuLjfax6Is4ri1SsZNjB9mWwd__OBJx0Y,419
18
19
  teareduce/wavecal.py,sha256=iiKG_RPW2CllwZxG5fTsyckE0Ec_IeZ6v7v2cQt6OeU,68706
19
20
  teareduce/write_array_to_fits.py,sha256=kWDrEH9coJ1yIu56oQJpWtDqJL4c8HGmssE9jle4e94,617
20
21
  teareduce/zscale.py,sha256=HuPYagTW55D7RtjPGc7HcibQlCx5oqLYHKoM6WEHG2g,1161
21
22
  teareduce/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
23
  teareduce/tests/test_sliceregion.py,sha256=25dhS7yJ1z_3tgFLw21uOkNKuugyVA-8L1ehafSQjFg,1769
23
- teareduce-0.4.2.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
24
- teareduce-0.4.2.dist-info/METADATA,sha256=w4ubiClALKYDUznLttU83_EakmzY2xD2oEwK_js0h0U,2290
25
- teareduce-0.4.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- teareduce-0.4.2.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
27
- teareduce-0.4.2.dist-info/RECORD,,
24
+ teareduce-0.4.3.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
25
+ teareduce-0.4.3.dist-info/METADATA,sha256=xj4Kdw08405olw1sdCcZ1ybcK65YPlOA9qxk6ou9sTk,2246
26
+ teareduce-0.4.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ teareduce-0.4.3.dist-info/top_level.txt,sha256=7OkwtX9zNRkGJ7ACgjk4ESgC74qUYcS5O2qcO0v-Si4,10
28
+ teareduce-0.4.3.dist-info/RECORD,,