Skip to content

Commit

Permalink
numpy v2 + py3.11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Faes committed Dec 2, 2024
1 parent 1d74adc commit 5b754e0
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 76 deletions.
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ I strongly suggest users to use the ``pip`` plataform:
pip install pyhdust
**pyhdust** dependencies are constantly evolving. If you face an installation problem,
check the `versioning page <https://pyhdust.readthedocs.io/alternative.html>`_. To install a specify version (for example, *1.5.12*):

.. code:: bash
pip install "pyhdust==1.5.12"
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.

.. warning::
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

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

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
9 changes: 8 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Welcome to **pyhdust** documentation!
=============================================================
**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>`_).

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

.. |Tests| image:: https://github.com/danmoser/pyhdust/actions/workflows/main.yaml/badge.svg
:target: https://github.com/danmoser/pyhdust/actions/workflows/main.yaml
Expand Down Expand Up @@ -44,6 +44,13 @@ I strongly suggest users to use the ``pip`` plataform:
pip install pyhdust
**pyhdust** dependencies are constantly evolving. If you face an installation problem,
check the :doc:`versioning <versioning>` page. To install a specify version (for example, *1.5.12*):

.. code:: bash
pip install "pyhdust==1.5.12"
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.

.. warning::
Expand Down
31 changes: 31 additions & 0 deletions docs/versioning.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Versioning
=========================================
Legacy versions
------------------
For *numpy < 2*, use *pyhdust < 1.6*.


Version 1.6.0
--------------
**pyhdust** 1.6.0 was tested with the following modules:

.. code::
astropy 7.0.0
emcee 3.1.6
ipython 8.29.0
matplotlib 3.9.2
numpy 2.1.3
packaging 24.2
pandas 2.2.3
pip 24.2
pyhdust 1.6.0
python-dateutil 2.9.0.post0
scipy 1.14.1
setuptools 75.1.0
six 1.16.0
Sphinx 8.1.3
sphinx-rtd-theme 3.0.2
wget 3.2
wheel 0.44.0
xmltodict 0.14.2
12 changes: 6 additions & 6 deletions pyhdust/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
except ImportError:
_warn.warn("# matplotlib and/or scipy module not installed!!")

__version__ = "1.5.12-1"
__version__ = "1.6.0"
__release__ = "Stable"
__author__ = "Daniel Moser"
__email__ = "[email protected]"
Expand Down Expand Up @@ -2366,7 +2366,7 @@ def obs_ver(hmin, hnas, hmax, hpoe):
else:
if debug:
print(hmin, hnas, hmax, hpoe)
hnas = hpoe = _np.NaN
hnas = hpoe = _np.nan
return (hnas, hpoe)

# equinocio set 2011 (djsol)
Expand Down Expand Up @@ -2495,8 +2495,8 @@ def obs_ver(hmin, hnas, hmax, hpoe):
if dt > 12:
dt = dt - 24
if dt < 3 / 4.0:
hnas = _np.NaN
hpoe = _np.NaN
hnas = _np.nan
hpoe = _np.nan

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

# tempos locais
hlmin = hnas - hz
Expand Down
4 changes: 2 additions & 2 deletions pyhdust/beatlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def interpolBA(params, ctrlarr, lparams, minfo, models, param=True):
| -params = from emcee minimization
| -ctrlarr = the fixed value of M, ob(W), Z, H, sig, Rd, h, *n*, cos(i).
| If it is not fixed, use np.NaN.
| If it is not fixed, use np.nan.
| -Parametric disk model default (`param` == True).
This function always returns a valid result (i.e., extrapolations from the
Expand All @@ -823,7 +823,7 @@ def interpolBA(params, ctrlarr, lparams, minfo, models, param=True):
parlims = _np.zeros((len(params), 2))
j = 0
for i in range(nq):
if ctrlarr[i] is _np.NaN:
if ctrlarr[i] is _np.nan:
parlims[j] = [
_phc.find_nearest(lparams[i], params[j], bigger=False),
_phc.find_nearest(lparams[i], params[j], bigger=True),
Expand Down
10 changes: 5 additions & 5 deletions pyhdust/fieldstars.py
Original file line number Diff line number Diff line change
Expand Up @@ -3188,7 +3188,7 @@ def run_emcee(sampler, p0):
), # truths=[p_mcmc[0], l_mcmc[0]], \
# extents=[(p_range[0],l_range[0]),(p_range[1],l_range[1])], \
quantiles=[0.16075, 0.50, 0.83925],
labels=["$P_{max}\,($%$)$", "$\lambda_{max}\,(\mu m)$"],
labels=[r"$P_{max}\,($%$)$", r"$\lambda_{max}\,(\mu m)$"],
verbose=False,
)
fig.savefig("{0}_correl.{1}".format(star, extens))
Expand All @@ -3199,7 +3199,7 @@ def run_emcee(sampler, p0):
), # truths=[p_mcmc[0], l_mcmc[0]], \
# extents=[(p_range[0],l_range[0]),(p_range[1],l_range[1])], \
quantiles=[0.16075, 0.50, 0.83925],
labels=["$P_{max}\,($%$)$", "$\lambda_{max}\,(\mu m)$"],
labels=[r"$P_{max}\,($%$)$", r"$\lambda_{max}\,(\mu m)$"],
verbose=False,
)
fig1.show()
Expand Down Expand Up @@ -3379,7 +3379,7 @@ def run_emcee(sampler, p0):
), # truths=[p_mcmc[0], l_mcmc[0]], \
# extents=[(p_range[0],l_range[0]),(p_range[1],l_range[1])], \
quantiles=[0.16075, 0.50, 0.83925],
labels=["$P_{max}\,($%$)$", "$\lambda_{max}\,(\mu m)$"],
labels=[r"$P_{max}\,($%$)$", r"$\lambda_{max}\,(\mu m)$"],
verbose=False,
)
fig.savefig("{0}_correl_cut.{1}".format(star, extens))
Expand All @@ -3401,7 +3401,7 @@ def plot_samples_hist(sampler):
Plot two figures with the histograms
"""
samples = [sampler.flatchain[:, i] for i in (0, 1)]
par = ["$P_{max}$", "$\lambda_{max}$"]
par = ["$P_{max}$", r"$\lambda_{max}$"]

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

fig.tight_layout(h_pad=0.0)
Expand Down
10 changes: 5 additions & 5 deletions pyhdust/interftools.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def log_transform(im):
_np.log(imax) - _np.log(imin)
)
idx = _np.where(im == 0)
im[idx] = _np.NaN
im[idx] = _np.nan
return im
except:
_warn.warn("# Warning! Wrong input at log_transform !!!")
Expand Down Expand Up @@ -865,7 +865,7 @@ def add_model(self, imgs, rpx, PAdisk=90, modid=None, lbm=None):
)
tlist.extend([v**2])
self.v2 = _np.array(tlist)
self.v2e = _np.zeros(_np.shape(tlist)) * _np.NaN
self.v2e = _np.zeros(_np.shape(tlist)) * _np.nan
#
tlist = []
for i in range(len(self.t3B1)):
Expand All @@ -881,7 +881,7 @@ def add_model(self, imgs, rpx, PAdisk=90, modid=None, lbm=None):
)
tlist.extend([p])
self.t3p = _np.array(tlist)
self.t3pe = _np.zeros(_np.shape(tlist)) * _np.NaN
self.t3pe = _np.zeros(_np.shape(tlist)) * _np.nan
#
elif self.oitype.upper().startswith("AMB"):
if lbm is not None:
Expand All @@ -902,9 +902,9 @@ def add_model(self, imgs, rpx, PAdisk=90, modid=None, lbm=None):
tlist_v.extend([v])
tlist_vp.extend([vp])
self.v = _np.array(tlist_v)
self.ve = _np.zeros(_np.shape(tlist_v)) * _np.NaN
self.ve = _np.zeros(_np.shape(tlist_v)) * _np.nan
self.vp = _np.array(tlist_vp)
self.vpe = _np.zeros(_np.shape(tlist_vp)) * _np.NaN
self.vpe = _np.zeros(_np.shape(tlist_vp)) * _np.nan
return


Expand Down
14 changes: 7 additions & 7 deletions pyhdust/phc.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def find_nearest_pt(x0, y0, x, y, z, case=1):
_np.average(d[idx]),
)
else:
return _np.NaN, _np.NaN, _np.NaN, _np.NaN
return _np.nan, _np.nan, _np.nan, _np.nan


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


def baricent_map(x, y, z, res=100, fullrange=False, xfact=1.0, yfact=1.0):
Expand Down Expand Up @@ -426,9 +426,9 @@ def interLinND(X, X0, X1, Fx, disablelog=False):
F = 0
for prod in _product(*DX):
if disablelog:
F += Fx[i] * _np.product(prod)
F += Fx[i] * _np.prod(prod)
else:
F += _np.log(Fx[i]) * _np.product(prod)
F += _np.log(Fx[i]) * _np.prod(prod)
i += 1
#
if not disablelog:
Expand Down Expand Up @@ -812,7 +812,7 @@ def fltTxtOccur(s, lines, n=1, seq=1, after=True, asstr=False):
occur = [x[x.find(s) + len(s) :] for x in lines if x.find(s) > -1]
else:
occur = [x for x in lines if x.find(s) > -1]
out = _np.NaN
out = _np.nan
if len(occur) >= n:
occur = occur[n - 1]
out = _re.findall(fltregex, occur)[seq - 1]
Expand Down Expand Up @@ -1846,8 +1846,8 @@ def gbf(T, lbd):
else:
i = _np.where(
vals[:, 0] == find_nearest(vals[:, 0], _np.log10(T), bigger=False)
)[0]
# print i, vals[i,0]
)[0][0]
# print(i, vals, type(i), type(vals))
g0 = interLinND(
[_np.log10(T)], [vals[i, 0]], [vals[i + 1, 0]], vals[i : i + 2, 1]
)
Expand Down
2 changes: 1 addition & 1 deletion pyhdust/poltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def eprint(*args, **kwargs):
import matplotlib.pyplot as _plt
from matplotlib.transforms import offset_copy as _offset_copy
from scipy.optimize import curve_fit as _curve_fit
from scipy.integrate import simps as _simps
from scipy.integrate import simpson as _simps
from scipy.interpolate import interp1d as _interp1d
import matplotlib as _mpl

Expand Down
4 changes: 4 additions & 0 deletions pyhdust/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
History
============
v.1.6.0 @ 2024-12-02
---------------------
- numpy v2 + Py3.11+ support
v1.5.12 @ 2024-04-10
---------------------
- oifits compatible w/ Python3.8+
Expand Down
4 changes: 2 additions & 2 deletions pyhdust/rotstars.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def sigma4b_cranmer(M, wfrac):
# H = 0.3 core
# For ob=1.10, i.e., one *CAN'T* apply 4*pi*R^2...
# SpType Tpole Teff Mass Rp Lum
["B0.0", _np.NaN, _np.NaN, _np.NaN, _np.NaN, _np.NaN],
["B0.0", _np.nan, _np.nan, _np.nan, _np.nan, _np.nan],
["B0.5", 28905.8, 26765.7, 14.6, 7.50, 31183.26],
["B1.0", 26945.8, 24950.9, 12.5, 6.82, 19471.38],
["B1.5", 25085.2, 23228.2, 10.8, 6.23, 12204.70],
Expand Down Expand Up @@ -540,7 +540,7 @@ def sigma4b_cranmer(M, wfrac):
["B6.0", 14300.3, 13241.6, 04.2, 3.72, 00459.55],
["B7.0", 13329.9, 12343.0, 03.8, 3.55, 00315.96],
["B8.0", 12307.1, 11395.9, 03.4, 3.37, 00206.89],
["B9.0", _np.NaN, _np.NaN, _np.NaN, _np.NaN, _np.NaN],
["B9.0", _np.nan, _np.nan, _np.nan, _np.nan, _np.nan],
]


Expand Down
Loading

0 comments on commit 5b754e0

Please sign in to comment.