Skip to content

Commit 5b754e0

Browse files
author
Daniel Faes
committed
numpy v2 + py3.11 support
1 parent 1d74adc commit 5b754e0

15 files changed

+126
-76
lines changed

README.rst

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ I strongly suggest users to use the ``pip`` plataform:
2222
2323
pip install pyhdust
2424
25+
**pyhdust** dependencies are constantly evolving. If you face an installation problem,
26+
check the `versioning page <https://pyhdust.readthedocs.io/alternative.html>`_. To install a specify version (for example, *1.5.12*):
27+
28+
.. code:: bash
29+
30+
pip install "pyhdust==1.5.12"
31+
2532
If your are not the root of the system, add the flag ``--user`` to the command above. Dependencies (as filters efficiency and stellar evolution models) are included in the subdirectories.
2633

2734
.. warning::

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
# General information about the project.
5555
project = "Python tools for the BeACoN group"
56-
copyright = "2015-2021, D. Moser"
56+
copyright = "2015-2025, D. Moser"
5757

5858
# The version info for the project you're documenting, acts as replacement for
5959
# |version| and |release|, also used in various other places throughout the

docs/index.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Welcome to **pyhdust** documentation!
44
=============================================================
55
**Analysis tools for multi-technique astronomical data and** *hdust* **models**. About the *hdust* code, see Carciofi & Bjorkman (`2006 <http://adsabs.harvard.edu/abs/2006ApJ...639.1081C>`_, `2008 <http://adsabs.harvard.edu/abs/2008ApJ...684.1374C>`_).
66

7-
Pyhdust is currently at **version 1.5.12-1**. |Tests|
7+
Pyhdust is currently at **version 1.6.0**. |Tests|
88

99
.. |Tests| image:: https://github.com/danmoser/pyhdust/actions/workflows/main.yaml/badge.svg
1010
:target: https://github.com/danmoser/pyhdust/actions/workflows/main.yaml
@@ -44,6 +44,13 @@ I strongly suggest users to use the ``pip`` plataform:
4444
4545
pip install pyhdust
4646
47+
**pyhdust** dependencies are constantly evolving. If you face an installation problem,
48+
check the :doc:`versioning <versioning>` page. To install a specify version (for example, *1.5.12*):
49+
50+
.. code:: bash
51+
52+
pip install "pyhdust==1.5.12"
53+
4754
If your are not the root of the system, add the flag ``--user`` to the command above. Dependencies (as filters efficiency and stellar evolution models) are included in the subdirectories.
4855

4956
.. warning::

docs/versioning.rst

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Versioning
2+
=========================================
3+
Legacy versions
4+
------------------
5+
For *numpy < 2*, use *pyhdust < 1.6*.
6+
7+
8+
Version 1.6.0
9+
--------------
10+
**pyhdust** 1.6.0 was tested with the following modules:
11+
12+
.. code::
13+
14+
astropy 7.0.0
15+
emcee 3.1.6
16+
ipython 8.29.0
17+
matplotlib 3.9.2
18+
numpy 2.1.3
19+
packaging 24.2
20+
pandas 2.2.3
21+
pip 24.2
22+
pyhdust 1.6.0
23+
python-dateutil 2.9.0.post0
24+
scipy 1.14.1
25+
setuptools 75.1.0
26+
six 1.16.0
27+
Sphinx 8.1.3
28+
sphinx-rtd-theme 3.0.2
29+
wget 3.2
30+
wheel 0.44.0
31+
xmltodict 0.14.2

pyhdust/__init__.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
except ImportError:
3939
_warn.warn("# matplotlib and/or scipy module not installed!!")
4040

41-
__version__ = "1.5.12-1"
41+
__version__ = "1.6.0"
4242
__release__ = "Stable"
4343
__author__ = "Daniel Moser"
4444
__email__ = "dmfaes@gmail.com"
@@ -2366,7 +2366,7 @@ def obs_ver(hmin, hnas, hmax, hpoe):
23662366
else:
23672367
if debug:
23682368
print(hmin, hnas, hmax, hpoe)
2369-
hnas = hpoe = _np.NaN
2369+
hnas = hpoe = _np.nan
23702370
return (hnas, hpoe)
23712371

23722372
# equinocio set 2011 (djsol)
@@ -2495,8 +2495,8 @@ def obs_ver(hmin, hnas, hmax, hpoe):
24952495
if dt > 12:
24962496
dt = dt - 24
24972497
if dt < 3 / 4.0:
2498-
hnas = _np.NaN
2499-
hpoe = _np.NaN
2498+
hnas = _np.nan
2499+
hpoe = _np.nan
25002500

25012501
# procura posicao nas efemerides (pef)
25022502
if _os.path.exists("{0}refs/obs_ef.txt".format(hdtpath())):
@@ -2550,8 +2550,8 @@ def obs_ver(hmin, hnas, hmax, hpoe):
25502550
fase_inc = ((djnas - T0) % per) / per
25512551
fase_fim = ((djpoe - T0) % per) / per
25522552
else:
2553-
fase_inc = _np.NaN
2554-
fase_fim = _np.NaN
2553+
fase_inc = _np.nan
2554+
fase_fim = _np.nan
25552555

25562556
# tempos locais
25572557
hlmin = hnas - hz

pyhdust/beatlas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ def interpolBA(params, ctrlarr, lparams, minfo, models, param=True):
802802
803803
| -params = from emcee minimization
804804
| -ctrlarr = the fixed value of M, ob(W), Z, H, sig, Rd, h, *n*, cos(i).
805-
| If it is not fixed, use np.NaN.
805+
| If it is not fixed, use np.nan.
806806
| -Parametric disk model default (`param` == True).
807807
808808
This function always returns a valid result (i.e., extrapolations from the
@@ -823,7 +823,7 @@ def interpolBA(params, ctrlarr, lparams, minfo, models, param=True):
823823
parlims = _np.zeros((len(params), 2))
824824
j = 0
825825
for i in range(nq):
826-
if ctrlarr[i] is _np.NaN:
826+
if ctrlarr[i] is _np.nan:
827827
parlims[j] = [
828828
_phc.find_nearest(lparams[i], params[j], bigger=False),
829829
_phc.find_nearest(lparams[i], params[j], bigger=True),

pyhdust/fieldstars.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3188,7 +3188,7 @@ def run_emcee(sampler, p0):
31883188
), # truths=[p_mcmc[0], l_mcmc[0]], \
31893189
# extents=[(p_range[0],l_range[0]),(p_range[1],l_range[1])], \
31903190
quantiles=[0.16075, 0.50, 0.83925],
3191-
labels=["$P_{max}\,($%$)$", "$\lambda_{max}\,(\mu m)$"],
3191+
labels=[r"$P_{max}\,($%$)$", r"$\lambda_{max}\,(\mu m)$"],
31923192
verbose=False,
31933193
)
31943194
fig.savefig("{0}_correl.{1}".format(star, extens))
@@ -3199,7 +3199,7 @@ def run_emcee(sampler, p0):
31993199
), # truths=[p_mcmc[0], l_mcmc[0]], \
32003200
# extents=[(p_range[0],l_range[0]),(p_range[1],l_range[1])], \
32013201
quantiles=[0.16075, 0.50, 0.83925],
3202-
labels=["$P_{max}\,($%$)$", "$\lambda_{max}\,(\mu m)$"],
3202+
labels=[r"$P_{max}\,($%$)$", r"$\lambda_{max}\,(\mu m)$"],
32033203
verbose=False,
32043204
)
32053205
fig1.show()
@@ -3379,7 +3379,7 @@ def run_emcee(sampler, p0):
33793379
), # truths=[p_mcmc[0], l_mcmc[0]], \
33803380
# extents=[(p_range[0],l_range[0]),(p_range[1],l_range[1])], \
33813381
quantiles=[0.16075, 0.50, 0.83925],
3382-
labels=["$P_{max}\,($%$)$", "$\lambda_{max}\,(\mu m)$"],
3382+
labels=[r"$P_{max}\,($%$)$", r"$\lambda_{max}\,(\mu m)$"],
33833383
verbose=False,
33843384
)
33853385
fig.savefig("{0}_correl_cut.{1}".format(star, extens))
@@ -3401,7 +3401,7 @@ def plot_samples_hist(sampler):
34013401
Plot two figures with the histograms
34023402
"""
34033403
samples = [sampler.flatchain[:, i] for i in (0, 1)]
3404-
par = ["$P_{max}$", "$\lambda_{max}$"]
3404+
par = ["$P_{max}$", r"$\lambda_{max}$"]
34053405

34063406
fig = []
34073407
for i, sample in enumerate(samples):
@@ -3426,7 +3426,7 @@ def plot_conv(sampler, param):
34263426
axes[1].plot(sampler.chain[:, :, 1].T, color="k", alpha=0.4)
34273427
axes[1].yaxis.set_major_locator(MaxNLocator(5))
34283428
axes[1].axhline(param[1], color="#888888", lw=2)
3429-
axes[1].set_ylabel("$\lambda_{max}$")
3429+
axes[1].set_ylabel(r"$\lambda_{max}$")
34303430
axes[1].set_xlabel("Step number")
34313431

34323432
fig.tight_layout(h_pad=0.0)

pyhdust/interftools.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def log_transform(im):
8282
_np.log(imax) - _np.log(imin)
8383
)
8484
idx = _np.where(im == 0)
85-
im[idx] = _np.NaN
85+
im[idx] = _np.nan
8686
return im
8787
except:
8888
_warn.warn("# Warning! Wrong input at log_transform !!!")
@@ -865,7 +865,7 @@ def add_model(self, imgs, rpx, PAdisk=90, modid=None, lbm=None):
865865
)
866866
tlist.extend([v**2])
867867
self.v2 = _np.array(tlist)
868-
self.v2e = _np.zeros(_np.shape(tlist)) * _np.NaN
868+
self.v2e = _np.zeros(_np.shape(tlist)) * _np.nan
869869
#
870870
tlist = []
871871
for i in range(len(self.t3B1)):
@@ -881,7 +881,7 @@ def add_model(self, imgs, rpx, PAdisk=90, modid=None, lbm=None):
881881
)
882882
tlist.extend([p])
883883
self.t3p = _np.array(tlist)
884-
self.t3pe = _np.zeros(_np.shape(tlist)) * _np.NaN
884+
self.t3pe = _np.zeros(_np.shape(tlist)) * _np.nan
885885
#
886886
elif self.oitype.upper().startswith("AMB"):
887887
if lbm is not None:
@@ -902,9 +902,9 @@ def add_model(self, imgs, rpx, PAdisk=90, modid=None, lbm=None):
902902
tlist_v.extend([v])
903903
tlist_vp.extend([vp])
904904
self.v = _np.array(tlist_v)
905-
self.ve = _np.zeros(_np.shape(tlist_v)) * _np.NaN
905+
self.ve = _np.zeros(_np.shape(tlist_v)) * _np.nan
906906
self.vp = _np.array(tlist_vp)
907-
self.vpe = _np.zeros(_np.shape(tlist_vp)) * _np.NaN
907+
self.vpe = _np.zeros(_np.shape(tlist_vp)) * _np.nan
908908
return
909909

910910

pyhdust/phc.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def find_nearest_pt(x0, y0, x, y, z, case=1):
121121
_np.average(d[idx]),
122122
)
123123
else:
124-
return _np.NaN, _np.NaN, _np.NaN, _np.NaN
124+
return _np.nan, _np.nan, _np.nan, _np.nan
125125

126126

127127
def baricent_calc(x0, y0, x, y, z, fullrange=False):
@@ -171,7 +171,7 @@ def baricent_calc(x0, y0, x, y, z, fullrange=False):
171171
ds = _np.array([d1, d2, d3, d4])[idx][:3]
172172
return _np.sum(zs / ds) / _np.sum(1 / ds)
173173
else:
174-
return _np.NaN
174+
return _np.nan
175175

176176

177177
def baricent_map(x, y, z, res=100, fullrange=False, xfact=1.0, yfact=1.0):
@@ -426,9 +426,9 @@ def interLinND(X, X0, X1, Fx, disablelog=False):
426426
F = 0
427427
for prod in _product(*DX):
428428
if disablelog:
429-
F += Fx[i] * _np.product(prod)
429+
F += Fx[i] * _np.prod(prod)
430430
else:
431-
F += _np.log(Fx[i]) * _np.product(prod)
431+
F += _np.log(Fx[i]) * _np.prod(prod)
432432
i += 1
433433
#
434434
if not disablelog:
@@ -812,7 +812,7 @@ def fltTxtOccur(s, lines, n=1, seq=1, after=True, asstr=False):
812812
occur = [x[x.find(s) + len(s) :] for x in lines if x.find(s) > -1]
813813
else:
814814
occur = [x for x in lines if x.find(s) > -1]
815-
out = _np.NaN
815+
out = _np.nan
816816
if len(occur) >= n:
817817
occur = occur[n - 1]
818818
out = _re.findall(fltregex, occur)[seq - 1]
@@ -1846,8 +1846,8 @@ def gbf(T, lbd):
18461846
else:
18471847
i = _np.where(
18481848
vals[:, 0] == find_nearest(vals[:, 0], _np.log10(T), bigger=False)
1849-
)[0]
1850-
# print i, vals[i,0]
1849+
)[0][0]
1850+
# print(i, vals, type(i), type(vals))
18511851
g0 = interLinND(
18521852
[_np.log10(T)], [vals[i, 0]], [vals[i + 1, 0]], vals[i : i + 2, 1]
18531853
)

pyhdust/poltools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def eprint(*args, **kwargs):
4343
import matplotlib.pyplot as _plt
4444
from matplotlib.transforms import offset_copy as _offset_copy
4545
from scipy.optimize import curve_fit as _curve_fit
46-
from scipy.integrate import simps as _simps
46+
from scipy.integrate import simpson as _simps
4747
from scipy.interpolate import interp1d as _interp1d
4848
import matplotlib as _mpl
4949

pyhdust/releases.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
55
History
66
============
7+
v.1.6.0 @ 2024-12-02
8+
---------------------
9+
- numpy v2 + Py3.11+ support
10+
711
v1.5.12 @ 2024-04-10
812
---------------------
913
- oifits compatible w/ Python3.8+

pyhdust/rotstars.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def sigma4b_cranmer(M, wfrac):
510510
# H = 0.3 core
511511
# For ob=1.10, i.e., one *CAN'T* apply 4*pi*R^2...
512512
# SpType Tpole Teff Mass Rp Lum
513-
["B0.0", _np.NaN, _np.NaN, _np.NaN, _np.NaN, _np.NaN],
513+
["B0.0", _np.nan, _np.nan, _np.nan, _np.nan, _np.nan],
514514
["B0.5", 28905.8, 26765.7, 14.6, 7.50, 31183.26],
515515
["B1.0", 26945.8, 24950.9, 12.5, 6.82, 19471.38],
516516
["B1.5", 25085.2, 23228.2, 10.8, 6.23, 12204.70],
@@ -540,7 +540,7 @@ def sigma4b_cranmer(M, wfrac):
540540
["B6.0", 14300.3, 13241.6, 04.2, 3.72, 00459.55],
541541
["B7.0", 13329.9, 12343.0, 03.8, 3.55, 00315.96],
542542
["B8.0", 12307.1, 11395.9, 03.4, 3.37, 00206.89],
543-
["B9.0", _np.NaN, _np.NaN, _np.NaN, _np.NaN, _np.NaN],
543+
["B9.0", _np.nan, _np.nan, _np.nan, _np.nan, _np.nan],
544544
]
545545

546546

0 commit comments

Comments
 (0)