From 0c1b7812ec35cd482c0eb45ad7fd044d0f506fa2 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 14 May 2024 13:27:33 -0600 Subject: [PATCH] Avoid the deprecated use of np.complex. --- SL_equation_elastic.py | 2 +- SLcode_py/SL_equation_elastic.py | 2 +- SLcode_py/pyspharm.py | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/SL_equation_elastic.py b/SL_equation_elastic.py index 69476cb..8430d4b 100644 --- a/SL_equation_elastic.py +++ b/SL_equation_elastic.py @@ -329,7 +329,7 @@ def calc_rot(L_in, _k, _k_tide, group='l'): La2m1 = -1 * np.conj(La21) La2m2 = 1 * np.conj(La22) - La_out = np.zeros(L_ml.shape, dtype=np.complex) + La_out = np.zeros(L_ml.shape, dtype=complex) if group == 'l': # NOTE! WILL HAVE TO CHANGE THIS if l,m are switched diff --git a/SLcode_py/SL_equation_elastic.py b/SLcode_py/SL_equation_elastic.py index b02aedf..a870543 100644 --- a/SLcode_py/SL_equation_elastic.py +++ b/SLcode_py/SL_equation_elastic.py @@ -329,7 +329,7 @@ def calc_rot(L_in, _k, _k_tide, group='l'): La2m1 = -1 * np.conj(La21) La2m2 = 1 * np.conj(La22) - La_out = np.zeros(L_ml.shape, dtype=np.complex) + La_out = np.zeros(L_ml.shape, dtype=complex) if group == 'l': # NOTE! WILL HAVE TO CHANGE THIS if l,m are switched diff --git a/SLcode_py/pyspharm.py b/SLcode_py/pyspharm.py index f07c8b5..56bf2ab 100644 --- a/SLcode_py/pyspharm.py +++ b/SLcode_py/pyspharm.py @@ -32,7 +32,7 @@ def __init__(self,nlons,nlats,ntrunc,rsphere,gridtype='gaussian'): self.ntrunc = ntrunc self.nlm = self._shtns.nlm self.degree = self._shtns.l - self.lap = -self.degree*(self.degree+1.0).astype(np.complex) + self.lap = -self.degree*(self.degree+1.0).astype(complex) self.invlap = np.zeros(self.lap.shape, self.lap.dtype) self.invlap[1:] = 1./self.lap[1:] self.rsphere = rsphere @@ -41,7 +41,7 @@ def __init__(self,nlons,nlats,ntrunc,rsphere,gridtype='gaussian'): def grdtospec(self,data,norm='sqrt4pi'): """compute spectral coefficients from gridded data""" data = np.ascontiguousarray(data, dtype=np.float) - dataspec = np.empty(self.nlm, dtype=np.complex) + dataspec = np.empty(self.nlm, dtype=complex) self._shtns.spat_to_SH(data, dataspec) if norm == 'unity': dataspec /= np.sqrt(4*np.pi) # this is for sea-level model @@ -52,7 +52,7 @@ def grdtospec(self,data,norm='sqrt4pi'): return dataspec def spectogrd(self,dataspec,norm='sqrt4pi'): """compute gridded data from spectral coefficients""" - dataspec = np.ascontiguousarray(dataspec, dtype=np.complex) + dataspec = np.ascontiguousarray(dataspec, dtype=complex) if norm == 'unity': dataspec *= np.sqrt(4*np.pi) # this is for sea-level model elif norm == 'sqrt4pi': @@ -64,8 +64,8 @@ def spectogrd(self,dataspec,norm='sqrt4pi'): return data def getuv(self,vrtspec,divspec): """compute wind vector from spectral coeffs of vorticity and divergence""" - vrtspec = np.ascontiguousarray(vrtspec, dtype=np.complex) - divspec = np.ascontiguousarray(divspec, dtype=np.complex) + vrtspec = np.ascontiguousarray(vrtspec, dtype=complex) + divspec = np.ascontiguousarray(divspec, dtype=complex) u = np.empty((self.nlats,self.nlons), dtype=np.float) v = np.empty((self.nlats,self.nlons), dtype=np.float) self._shtns.SHsphtor_to_spat((self.invlap/self.rsphere)*vrtspec,\ @@ -75,14 +75,14 @@ def getvrtdivspec(self,u,v): """compute spectral coeffs of vorticity and divergence from wind vector""" u = np.ascontiguousarray(u, dtype=np.float) v = np.ascontiguousarray(v, dtype=np.float) - vrtspec = np.empty(self.nlm, dtype=np.complex) - divspec = np.empty(self.nlm, dtype=np.complex) + vrtspec = np.empty(self.nlm, dtype=complex) + divspec = np.empty(self.nlm, dtype=complex) self._shtns.spat_to_SHsphtor(u, v, vrtspec, divspec) return self.lap*self.rsphere*vrtspec, self.lap*rsphere*divspec def getgrad(self,divspec): """compute gradient vector from spectral coeffs""" - divspec = np.ascontiguousarray(divspec, dtype=np.complex) - vrtspec = np.zeros(divspec.shape, dtype=np.complex) + divspec = np.ascontiguousarray(divspec, dtype=complex) + vrtspec = np.zeros(divspec.shape, dtype=complex) u = np.empty((self.nlats,self.nlons), dtype=np.float) v = np.empty((self.nlats,self.nlons), dtype=np.float) self._shtns.SHsphtor_to_spat(vrtspec,divspec) @@ -179,9 +179,9 @@ def specdata(self): phispec = x.grdtospec(phig) # initialize spectral tendency arrays - ddivdtspec = np.zeros(vrtspec.shape+(3,), np.complex) - dvrtdtspec = np.zeros(vrtspec.shape+(3,), np.complex) - dphidtspec = np.zeros(vrtspec.shape+(3,), np.complex) + ddivdtspec = np.zeros(vrtspec.shape+(3,), complex) + dvrtdtspec = np.zeros(vrtspec.shape+(3,), complex) + dphidtspec = np.zeros(vrtspec.shape+(3,), complex) nnew = 0; nnow = 1; nold = 2 # time loop.