Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SL_equation_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion SLcode_py/SL_equation_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions SLcode_py/pyspharm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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':
Expand All @@ -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,\
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down