From bbfba70f7fb73a82789df40186648bd5d9f1c6c5 Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 27 Sep 2023 15:14:45 -0400 Subject: [PATCH 1/2] numpy 2.0 fixes numpy 2.0 changes the string format of scalars this format was relied on in gridded_library which this commit updates (by first converting the values to builtin floats prior to converting to strings) numpy 2.0 also removes float_ and complex_ this commit replaces their usage with double and cdouble --- webbpsf/gridded_library.py | 2 +- webbpsf/utils.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/webbpsf/gridded_library.py b/webbpsf/gridded_library.py index b78cc0da..da61f3d6 100644 --- a/webbpsf/gridded_library.py +++ b/webbpsf/gridded_library.py @@ -340,7 +340,7 @@ def create_grid(self): if self.fov_pixels % 2 == 0: loc += 0.5 # even arrays must be at a half pixel - meta["DET_YX{}".format(h)] = (str((loc[1], loc[0])), + meta["DET_YX{}".format(h)] = (str((float(loc[1]), float(loc[0]))), "The #{} PSF's (y,x) detector pixel position".format(h)) meta["NUM_PSFS"] = (self.num_psfs, "The total number of fiducial PSFs") diff --git a/webbpsf/utils.py b/webbpsf/utils.py index 047ccdb1..fff9e6d5 100644 --- a/webbpsf/utils.py +++ b/webbpsf/utils.py @@ -263,9 +263,9 @@ def get_webbpsf_data_path(data_version_min=None, return_version=False): *************************************************************** -Floating point type information for numpy.float_: +Floating point type information for numpy.double: {finfo_float} -Floating point type information for numpy.complex: +Floating point type information for numpy.cdouble: {finfo_complex} *************************************************************** @@ -418,8 +418,8 @@ def system_diagnostic(): stsyn=stsynphot_version, pysyn=pysynphot_version, astropy=astropy_version, - finfo_float=numpy.finfo(numpy.float_), - finfo_complex=numpy.finfo(numpy.complex_), + finfo_float=numpy.finfo(numpy.double), + finfo_complex=numpy.finfo(numpy.cdouble), numexpr=numexpr_version, scipy=scipy.__version__, accelerate=accelerate_version, From b87ae3137f2e9783f8ab18441f8d79e5037637db Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 27 Sep 2023 16:01:22 -0400 Subject: [PATCH 2/2] use np.poly1d instead of scipy.poly1d --- webbpsf/optics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webbpsf/optics.py b/webbpsf/optics.py index 7bd26430..c54a1ef7 100644 --- a/webbpsf/optics.py +++ b/webbpsf/optics.py @@ -836,7 +836,7 @@ def get_transmission(self, wave): else: raise NotImplementedError("invalid name for NIRCam wedge occulter") - sigmas = scipy.poly1d(polyfitcoeffs)(scalefact) + sigmas = np.poly1d(polyfitcoeffs)(scalefact) sigmar = sigmas * np.abs(y) # clip sigma: The minimum is to avoid divide by zero @@ -1022,7 +1022,7 @@ def _calc_blc_wedge(deg=4, wavelength=2.1e-6): sigs = [_width_blc(difflim * ri) for ri in r] pcs = scipy.polyfit(r, sigs, deg) - p = scipy.poly1d(pcs) + p = np.poly1d(pcs) plt.plot(r, sigs, 'b') plt.plot(r, p(r), "r--") diffs = (sigs - p(r))