| [2131108] | 1 | # This file was automatically generated by SWIG (http://www.swig.org).
|
|---|
| 2 | # Version 3.0.5
|
|---|
| 3 | #
|
|---|
| 4 | # Do not make changes to this file unless you know what you are doing--modify
|
|---|
| 5 | # the SWIG interface file instead.
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | """
|
|---|
| 11 | Python/NumPy interface to the SHTns spherical harmonic transform library
|
|---|
| 12 | """
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | from sys import version_info
|
|---|
| 16 | if version_info >= (2, 6, 0):
|
|---|
| 17 | def swig_import_helper():
|
|---|
| 18 | from os.path import dirname
|
|---|
| 19 | import imp
|
|---|
| 20 | fp = None
|
|---|
| 21 | try:
|
|---|
| 22 | fp, pathname, description = imp.find_module('_shtns', [dirname(__file__)])
|
|---|
| 23 | except ImportError:
|
|---|
| 24 | import _shtns
|
|---|
| 25 | return _shtns
|
|---|
| 26 | if fp is not None:
|
|---|
| 27 | try:
|
|---|
| 28 | _mod = imp.load_module('_shtns', fp, pathname, description)
|
|---|
| 29 | finally:
|
|---|
| 30 | fp.close()
|
|---|
| 31 | return _mod
|
|---|
| 32 | _shtns = swig_import_helper()
|
|---|
| 33 | del swig_import_helper
|
|---|
| 34 | else:
|
|---|
| 35 | import _shtns
|
|---|
| 36 | del version_info
|
|---|
| 37 | try:
|
|---|
| 38 | _swig_property = property
|
|---|
| 39 | except NameError:
|
|---|
| 40 | pass # Python < 2.2 doesn't have 'property'.
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
|
|---|
| 44 | if (name == "thisown"):
|
|---|
| 45 | return self.this.own(value)
|
|---|
| 46 | if (name == "this"):
|
|---|
| 47 | if type(value).__name__ == 'SwigPyObject':
|
|---|
| 48 | self.__dict__[name] = value
|
|---|
| 49 | return
|
|---|
| 50 | method = class_type.__swig_setmethods__.get(name, None)
|
|---|
| 51 | if method:
|
|---|
| 52 | return method(self, value)
|
|---|
| 53 | if (not static):
|
|---|
| 54 | if _newclass:
|
|---|
| 55 | object.__setattr__(self, name, value)
|
|---|
| 56 | else:
|
|---|
| 57 | self.__dict__[name] = value
|
|---|
| 58 | else:
|
|---|
| 59 | raise AttributeError("You cannot add attributes to %s" % self)
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | def _swig_setattr(self, class_type, name, value):
|
|---|
| 63 | return _swig_setattr_nondynamic(self, class_type, name, value, 0)
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | def _swig_getattr_nondynamic(self, class_type, name, static=1):
|
|---|
| 67 | if (name == "thisown"):
|
|---|
| 68 | return self.this.own()
|
|---|
| 69 | method = class_type.__swig_getmethods__.get(name, None)
|
|---|
| 70 | if method:
|
|---|
| 71 | return method(self)
|
|---|
| 72 | if (not static):
|
|---|
| 73 | return object.__getattr__(self, name)
|
|---|
| 74 | else:
|
|---|
| 75 | raise AttributeError(name)
|
|---|
| 76 |
|
|---|
| 77 | def _swig_getattr(self, class_type, name):
|
|---|
| 78 | return _swig_getattr_nondynamic(self, class_type, name, 0)
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | def _swig_repr(self):
|
|---|
| 82 | try:
|
|---|
| 83 | strthis = "proxy of " + self.this.__repr__()
|
|---|
| 84 | except:
|
|---|
| 85 | strthis = ""
|
|---|
| 86 | return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
|---|
| 87 |
|
|---|
| 88 | try:
|
|---|
| 89 | _object = object
|
|---|
| 90 | _newclass = 1
|
|---|
| 91 | except AttributeError:
|
|---|
| 92 | class _object:
|
|---|
| 93 | pass
|
|---|
| 94 | _newclass = 0
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | import numpy as np
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 | _shtns.sht_orthonormal_swigconstant(_shtns)
|
|---|
| 101 | sht_orthonormal = _shtns.sht_orthonormal
|
|---|
| 102 |
|
|---|
| 103 | _shtns.sht_fourpi_swigconstant(_shtns)
|
|---|
| 104 | sht_fourpi = _shtns.sht_fourpi
|
|---|
| 105 |
|
|---|
| 106 | _shtns.sht_schmidt_swigconstant(_shtns)
|
|---|
| 107 | sht_schmidt = _shtns.sht_schmidt
|
|---|
| 108 |
|
|---|
| 109 | _shtns.SHT_NO_CS_PHASE_swigconstant(_shtns)
|
|---|
| 110 | SHT_NO_CS_PHASE = _shtns.SHT_NO_CS_PHASE
|
|---|
| 111 |
|
|---|
| 112 | _shtns.SHT_REAL_NORM_swigconstant(_shtns)
|
|---|
| 113 | SHT_REAL_NORM = _shtns.SHT_REAL_NORM
|
|---|
| 114 |
|
|---|
| 115 | _shtns.sht_gauss_swigconstant(_shtns)
|
|---|
| 116 | sht_gauss = _shtns.sht_gauss
|
|---|
| 117 |
|
|---|
| 118 | _shtns.sht_auto_swigconstant(_shtns)
|
|---|
| 119 | sht_auto = _shtns.sht_auto
|
|---|
| 120 |
|
|---|
| 121 | _shtns.sht_reg_fast_swigconstant(_shtns)
|
|---|
| 122 | sht_reg_fast = _shtns.sht_reg_fast
|
|---|
| 123 |
|
|---|
| 124 | _shtns.sht_reg_dct_swigconstant(_shtns)
|
|---|
| 125 | sht_reg_dct = _shtns.sht_reg_dct
|
|---|
| 126 |
|
|---|
| 127 | _shtns.sht_quick_init_swigconstant(_shtns)
|
|---|
| 128 | sht_quick_init = _shtns.sht_quick_init
|
|---|
| 129 |
|
|---|
| 130 | _shtns.sht_reg_poles_swigconstant(_shtns)
|
|---|
| 131 | sht_reg_poles = _shtns.sht_reg_poles
|
|---|
| 132 |
|
|---|
| 133 | _shtns.sht_gauss_fly_swigconstant(_shtns)
|
|---|
| 134 | sht_gauss_fly = _shtns.sht_gauss_fly
|
|---|
| 135 |
|
|---|
| 136 | _shtns.SHT_THETA_CONTIGUOUS_swigconstant(_shtns)
|
|---|
| 137 | SHT_THETA_CONTIGUOUS = _shtns.SHT_THETA_CONTIGUOUS
|
|---|
| 138 |
|
|---|
| 139 | _shtns.SHT_PHI_CONTIGUOUS_swigconstant(_shtns)
|
|---|
| 140 | SHT_PHI_CONTIGUOUS = _shtns.SHT_PHI_CONTIGUOUS
|
|---|
| 141 |
|
|---|
| 142 | _shtns.SHT_SOUTH_POLE_FIRST_swigconstant(_shtns)
|
|---|
| 143 | SHT_SOUTH_POLE_FIRST = _shtns.SHT_SOUTH_POLE_FIRST
|
|---|
| 144 |
|
|---|
| 145 | _shtns.SHT_SCALAR_ONLY_swigconstant(_shtns)
|
|---|
| 146 | SHT_SCALAR_ONLY = _shtns.SHT_SCALAR_ONLY
|
|---|
| 147 |
|
|---|
| 148 | _shtns.SHT_LOAD_SAVE_CFG_swigconstant(_shtns)
|
|---|
| 149 | SHT_LOAD_SAVE_CFG = _shtns.SHT_LOAD_SAVE_CFG
|
|---|
| 150 | class sht(_object):
|
|---|
| 151 | """Proxy of C shtns_info struct"""
|
|---|
| 152 | __swig_setmethods__ = {}
|
|---|
| 153 | __setattr__ = lambda self, name, value: _swig_setattr(self, sht, name, value)
|
|---|
| 154 | __swig_getmethods__ = {}
|
|---|
| 155 | __getattr__ = lambda self, name: _swig_getattr(self, sht, name)
|
|---|
| 156 | __repr__ = _swig_repr
|
|---|
| 157 | __swig_getmethods__["nlm"] = _shtns.sht_nlm_get
|
|---|
| 158 | if _newclass:
|
|---|
| 159 | nlm = _swig_property(_shtns.sht_nlm_get)
|
|---|
| 160 | __swig_getmethods__["lmax"] = _shtns.sht_lmax_get
|
|---|
| 161 | if _newclass:
|
|---|
| 162 | lmax = _swig_property(_shtns.sht_lmax_get)
|
|---|
| 163 | __swig_getmethods__["mmax"] = _shtns.sht_mmax_get
|
|---|
| 164 | if _newclass:
|
|---|
| 165 | mmax = _swig_property(_shtns.sht_mmax_get)
|
|---|
| 166 | __swig_getmethods__["mres"] = _shtns.sht_mres_get
|
|---|
| 167 | if _newclass:
|
|---|
| 168 | mres = _swig_property(_shtns.sht_mres_get)
|
|---|
| 169 | __swig_getmethods__["nphi"] = _shtns.sht_nphi_get
|
|---|
| 170 | if _newclass:
|
|---|
| 171 | nphi = _swig_property(_shtns.sht_nphi_get)
|
|---|
| 172 | __swig_getmethods__["nlat"] = _shtns.sht_nlat_get
|
|---|
| 173 | if _newclass:
|
|---|
| 174 | nlat = _swig_property(_shtns.sht_nlat_get)
|
|---|
| 175 | __swig_getmethods__["nspat"] = _shtns.sht_nspat_get
|
|---|
| 176 | if _newclass:
|
|---|
| 177 | nspat = _swig_property(_shtns.sht_nspat_get)
|
|---|
| 178 |
|
|---|
| 179 | def __init__(self, lmax, mmax=-1, mres=1, norm=sht_orthonormal, nthreads=0):
|
|---|
| 180 | """__init__(shtns_info self, int lmax, int mmax=-1, int mres=1, int norm=sht_orthonormal, int nthreads=0) -> sht"""
|
|---|
| 181 | this = _shtns.new_sht(lmax, mmax, mres, norm, nthreads)
|
|---|
| 182 | try:
|
|---|
| 183 | self.this.append(this)
|
|---|
| 184 | except:
|
|---|
| 185 | self.this = this
|
|---|
| 186 | ## array giving the degree of spherical harmonic coefficients.
|
|---|
| 187 | self.l = np.zeros(self.nlm, dtype=np.int32)
|
|---|
| 188 | ## array giving the order of spherical harmonic coefficients.
|
|---|
| 189 | self.m = np.zeros(self.nlm, dtype=np.int32)
|
|---|
| 190 | for mloop in range(0, self.mmax*self.mres+1, self.mres):
|
|---|
| 191 | for lloop in range(mloop, self.lmax+1):
|
|---|
| 192 | ii = self.idx(lloop,mloop)
|
|---|
| 193 | self.m[ii] = mloop
|
|---|
| 194 | self.l[ii] = lloop
|
|---|
| 195 | self.m.flags.writeable = False # prevent writing in m and l arrays
|
|---|
| 196 | self.l.flags.writeable = False
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 | __swig_destroy__ = _shtns.delete_sht
|
|---|
| 201 | __del__ = lambda self: None
|
|---|
| 202 |
|
|---|
| 203 | def set_grid(self, nlat=0, nphi=0, flags=sht_quick_init, polar_opt=1.0e-8, nl_order=1):
|
|---|
| 204 | """set_grid(sht self, int nlat=0, int nphi=0, int flags=sht_quick_init, double polar_opt=1.0e-8, int nl_order=1)"""
|
|---|
| 205 | val = _shtns.sht_set_grid(self, nlat, nphi, flags, polar_opt, nl_order)
|
|---|
| 206 | ## array giving the cosine of the colatitude for the grid.
|
|---|
| 207 | self.cos_theta = self.__ct()
|
|---|
| 208 | self.cos_theta.flags.writeable = False
|
|---|
| 209 | ## shape of a spatial array for the grid (tuple of 2 values).
|
|---|
| 210 | self.spat_shape = tuple(self.__spat_shape())
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 | return val
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 | def print_info(self):
|
|---|
| 217 | """print_info(sht self)"""
|
|---|
| 218 | return _shtns.sht_print_info(self)
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 | def sh00_1(self):
|
|---|
| 222 | """sh00_1(sht self) -> double"""
|
|---|
| 223 | return _shtns.sht_sh00_1(self)
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 | def sh10_ct(self):
|
|---|
| 227 | """sh10_ct(sht self) -> double"""
|
|---|
| 228 | return _shtns.sht_sh10_ct(self)
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 | def sh11_st(self):
|
|---|
| 232 | """sh11_st(sht self) -> double"""
|
|---|
| 233 | return _shtns.sht_sh11_st(self)
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 | def shlm_e1(self, l, m):
|
|---|
| 237 | """shlm_e1(sht self, unsigned int l, unsigned int m) -> double"""
|
|---|
| 238 | return _shtns.sht_shlm_e1(self, l, m)
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 | def __ct(self):
|
|---|
| 242 | """__ct(sht self) -> PyObject *"""
|
|---|
| 243 | return _shtns.sht___ct(self)
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 | def gauss_wts(self):
|
|---|
| 247 | """gauss_wts(sht self) -> PyObject *"""
|
|---|
| 248 | return _shtns.sht_gauss_wts(self)
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 | def mul_ct_matrix(self):
|
|---|
| 252 | """mul_ct_matrix(sht self) -> PyObject *"""
|
|---|
| 253 | return _shtns.sht_mul_ct_matrix(self)
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 | def st_dt_matrix(self):
|
|---|
| 257 | """st_dt_matrix(sht self) -> PyObject *"""
|
|---|
| 258 | return _shtns.sht_st_dt_matrix(self)
|
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 | def __spat_shape(self):
|
|---|
| 262 | """__spat_shape(sht self)"""
|
|---|
| 263 | return _shtns.sht___spat_shape(self)
|
|---|
| 264 |
|
|---|
| 265 | def spec_array(self, im=-1):
|
|---|
| 266 | """return a numpy array of spherical harmonic coefficients (complex). Adress coefficients with index sh.idx(l,m)
|
|---|
| 267 | if optional argument im is given, the spectral array is restricted to order im*mres."""
|
|---|
| 268 | if im<0:
|
|---|
| 269 | return np.zeros(self.nlm, dtype=complex)
|
|---|
| 270 | else:
|
|---|
| 271 | return np.zeros(self.lmax + 1 - im*self.mres, dtype=complex)
|
|---|
| 272 |
|
|---|
| 273 | def spat_array(self):
|
|---|
| 274 | """return a numpy array of 2D spatial field."""
|
|---|
| 275 | if self.nlat == 0: raise RuntimeError("Grid not set. Call .set_grid() mehtod.")
|
|---|
| 276 | return np.zeros(self.spat_shape)
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 | def idx(self, l, m):
|
|---|
| 280 | """idx(sht self, unsigned int l, unsigned int m) -> int"""
|
|---|
| 281 | return _shtns.sht_idx(self, l, m)
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 | def spat_to_SH(self, Vr, Qlm):
|
|---|
| 285 | """spat_to_SH(sht self, PyObject * Vr, PyObject * Qlm)"""
|
|---|
| 286 | return _shtns.sht_spat_to_SH(self, Vr, Qlm)
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 | def SH_to_spat(self, Qlm, Vr):
|
|---|
| 290 | """SH_to_spat(sht self, PyObject * Qlm, PyObject * Vr)"""
|
|---|
| 291 | return _shtns.sht_SH_to_spat(self, Qlm, Vr)
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 | def spat_cplx_to_SH(self, z, alm):
|
|---|
| 295 | """spat_cplx_to_SH(sht self, PyObject * z, PyObject * alm)"""
|
|---|
| 296 | return _shtns.sht_spat_cplx_to_SH(self, z, alm)
|
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 | def SH_to_spat_cplx(self, alm, z):
|
|---|
| 300 | """SH_to_spat_cplx(sht self, PyObject * alm, PyObject * z)"""
|
|---|
| 301 | return _shtns.sht_SH_to_spat_cplx(self, alm, z)
|
|---|
| 302 |
|
|---|
| 303 |
|
|---|
| 304 | def spat_to_SHsphtor(self, Vt, Vp, Slm, Tlm):
|
|---|
| 305 | """spat_to_SHsphtor(sht self, PyObject * Vt, PyObject * Vp, PyObject * Slm, PyObject * Tlm)"""
|
|---|
| 306 | return _shtns.sht_spat_to_SHsphtor(self, Vt, Vp, Slm, Tlm)
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 | def SHsphtor_to_spat(self, Slm, Tlm, Vt, Vp):
|
|---|
| 310 | """SHsphtor_to_spat(sht self, PyObject * Slm, PyObject * Tlm, PyObject * Vt, PyObject * Vp)"""
|
|---|
| 311 | return _shtns.sht_SHsphtor_to_spat(self, Slm, Tlm, Vt, Vp)
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 | def SHsph_to_spat(self, Slm, Vt, Vp):
|
|---|
| 315 | """SHsph_to_spat(sht self, PyObject * Slm, PyObject * Vt, PyObject * Vp)"""
|
|---|
| 316 | return _shtns.sht_SHsph_to_spat(self, Slm, Vt, Vp)
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 | def SHtor_to_spat(self, Tlm, Vt, Vp):
|
|---|
| 320 | """SHtor_to_spat(sht self, PyObject * Tlm, PyObject * Vt, PyObject * Vp)"""
|
|---|
| 321 | return _shtns.sht_SHtor_to_spat(self, Tlm, Vt, Vp)
|
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 | def spat_to_SHqst(self, Vr, Vt, Vp, Qlm, Slm, Tlm):
|
|---|
| 325 | """spat_to_SHqst(sht self, PyObject * Vr, PyObject * Vt, PyObject * Vp, PyObject * Qlm, PyObject * Slm, PyObject * Tlm)"""
|
|---|
| 326 | return _shtns.sht_spat_to_SHqst(self, Vr, Vt, Vp, Qlm, Slm, Tlm)
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 | def SHqst_to_spat(self, Qlm, Slm, Tlm, Vr, Vt, Vp):
|
|---|
| 330 | """SHqst_to_spat(sht self, PyObject * Qlm, PyObject * Slm, PyObject * Tlm, PyObject * Vr, PyObject * Vt, PyObject * Vp)"""
|
|---|
| 331 | return _shtns.sht_SHqst_to_spat(self, Qlm, Slm, Tlm, Vr, Vt, Vp)
|
|---|
| 332 |
|
|---|
| 333 | def synth(self,*arg):
|
|---|
| 334 | """
|
|---|
| 335 | spectral to spatial transform, for scalar or vector data.
|
|---|
| 336 | v = synth(qlm) : compute the spatial representation of the scalar qlm
|
|---|
| 337 | vtheta,vphi = synth(slm,tlm) : compute the 2D spatial vector from its spectral spheroidal/toroidal scalars (slm,tlm)
|
|---|
| 338 | vr,vtheta,vphi = synth(qlm,slm,tlm) : compute the 3D spatial vector from its spectral radial/spheroidal/toroidal scalars (qlm,slm,tlm)
|
|---|
| 339 | """
|
|---|
| 340 | if self.nlat == 0: raise RuntimeError("Grid not set. Call .set_grid() mehtod.")
|
|---|
| 341 | n = len(arg)
|
|---|
| 342 | if (n>3) or (n<1): raise RuntimeError("1,2 or 3 arguments required.")
|
|---|
| 343 | q = list(arg)
|
|---|
| 344 | for i in range(0,n):
|
|---|
| 345 | if q[i].size != self.nlm: raise RuntimeError("spectral array has wrong size.")
|
|---|
| 346 | if q[i].dtype.num != np.dtype('complex128').num: raise RuntimeError("spectral array should be dtype=complex.")
|
|---|
| 347 | if q[i].flags.contiguous == False: q[i] = q[i].copy() # contiguous array required.
|
|---|
| 348 | if n==1: #scalar transform
|
|---|
| 349 | vr = np.empty(self.spat_shape)
|
|---|
| 350 | self.SH_to_spat(q[0],vr)
|
|---|
| 351 | return vr
|
|---|
| 352 | elif n==2: # 2D vector transform
|
|---|
| 353 | vt = np.empty(self.spat_shape) # v_theta
|
|---|
| 354 | vp = np.empty(self.spat_shape) # v_phi
|
|---|
| 355 | self.SHsphtor_to_spat(q[0],q[1],vt,vp)
|
|---|
| 356 | return vt,vp
|
|---|
| 357 | else: # 3D vector transform
|
|---|
| 358 | vr = np.empty(self.spat_shape) # v_r
|
|---|
| 359 | vt = np.empty(self.spat_shape) # v_theta
|
|---|
| 360 | vp = np.empty(self.spat_shape) # v_phi
|
|---|
| 361 | self.SHqst_to_spat(q[0],q[1],q[2],vr,vt,vp)
|
|---|
| 362 | return vr,vt,vp
|
|---|
| 363 |
|
|---|
| 364 | def analys(self,*arg):
|
|---|
| 365 | """
|
|---|
| 366 | spatial to spectral transform, for scalar or vector data.
|
|---|
| 367 | qlm = analys(q) : compute the spherical harmonic representation of the scalar q
|
|---|
| 368 | slm,tlm = analys(vtheta,vphi) : compute the spectral spheroidal/toroidal scalars (slm,tlm) from 2D vector components (vtheta, vphi)
|
|---|
| 369 | qlm,slm,tlm = synth(vr,vtheta,vphi) : compute the spectral radial/spheroidal/toroidal scalars (qlm,slm,tlm) from 3D vector components (vr,vtheta,vphi)
|
|---|
| 370 | """
|
|---|
| 371 | if self.nlat == 0: raise RuntimeError("Grid not set. Call .set_grid() mehtod.")
|
|---|
| 372 | if abs(self.cos_theta[0]) == 1: raise RuntimeError("Analysis not allowed with sht_reg_poles grid.")
|
|---|
| 373 | n = len(arg)
|
|---|
| 374 | if (n>3) or (n<1): raise RuntimeError("1,2 or 3 arguments required.")
|
|---|
| 375 | v = list(arg)
|
|---|
| 376 | for i in range(0,n):
|
|---|
| 377 | if v[i].shape != self.spat_shape: raise RuntimeError("spatial array has wrong shape.")
|
|---|
| 378 | if v[i].dtype.num != np.dtype('float64').num: raise RuntimeError("spatial array should be dtype=float64.")
|
|---|
| 379 | if v[i].flags.contiguous == False: v[i] = v[i].copy() # contiguous array required.
|
|---|
| 380 | if n==1:
|
|---|
| 381 | q = np.empty(self.nlm, dtype=complex)
|
|---|
| 382 | self.spat_to_SH(v[0],q)
|
|---|
| 383 | return q
|
|---|
| 384 | elif n==2:
|
|---|
| 385 | s = np.empty(self.nlm, dtype=complex)
|
|---|
| 386 | t = np.empty(self.nlm, dtype=complex)
|
|---|
| 387 | self.spat_to_SHsphtor(v[0],v[1],s,t)
|
|---|
| 388 | return s,t
|
|---|
| 389 | else:
|
|---|
| 390 | q = np.empty(self.nlm, dtype=complex)
|
|---|
| 391 | s = np.empty(self.nlm, dtype=complex)
|
|---|
| 392 | t = np.empty(self.nlm, dtype=complex)
|
|---|
| 393 | self.spat_to_SHqst(v[0],v[1],v[2],q,s,t)
|
|---|
| 394 | return q,s,t
|
|---|
| 395 |
|
|---|
| 396 | def synth_grad(self,slm):
|
|---|
| 397 | """(vtheta,vphi) = synth_grad(sht self, slm) : compute the spatial representation of the gradient of slm"""
|
|---|
| 398 | if self.nlat == 0: raise RuntimeError("Grid not set. Call .set_grid() mehtod.")
|
|---|
| 399 | if slm.size != self.nlm: raise RuntimeError("spectral array has wrong size.")
|
|---|
| 400 | if slm.dtype.num != np.dtype('complex128').num: raise RuntimeError("spectral array should be dtype=complex.")
|
|---|
| 401 | if slm.flags.contiguous == False: slm = slm.copy() # contiguous array required.
|
|---|
| 402 | vt = np.empty(self.spat_shape)
|
|---|
| 403 | vp = np.empty(self.spat_shape)
|
|---|
| 404 | self.SHsph_to_spat(slm,vt,vp)
|
|---|
| 405 | return vt,vp
|
|---|
| 406 |
|
|---|
| 407 | def synth_cplx(self,alm):
|
|---|
| 408 | """
|
|---|
| 409 | spectral to spatial transform, for complex valued scalar data.
|
|---|
| 410 | z = synth(alm) : compute the spatial representation of the scalar alm
|
|---|
| 411 | """
|
|---|
| 412 | if self.nlat == 0: raise RuntimeError("Grid not set. Call .set_grid() mehtod.")
|
|---|
| 413 | if self.lmax != self.mmax: raise RuntimeError("complex SH requires lmax=mmax and mres=1.")
|
|---|
| 414 | if alm.size != (self.lmax+1)**2: raise RuntimeError("spectral array has wrong size.")
|
|---|
| 415 | if alm.dtype.num != np.dtype('complex128').num: raise RuntimeError("spectral array should be dtype=complex.")
|
|---|
| 416 | if alm.flags.contiguous == False: alm = alm.copy() # contiguous array required.
|
|---|
| 417 | z = np.empty(self.spat_shape, dtype=complex)
|
|---|
| 418 | self.SH_to_spat_cplx(alm,z)
|
|---|
| 419 | return z
|
|---|
| 420 |
|
|---|
| 421 | def analys_cplx(self,z):
|
|---|
| 422 | """
|
|---|
| 423 | spatial to spectral transform, for complex valued scalar data.
|
|---|
| 424 | alm = analys(z) : compute the spherical harmonic representation of the complex scalar z
|
|---|
| 425 | """
|
|---|
| 426 | if self.nlat == 0: raise RuntimeError("Grid not set. Call .set_grid() mehtod.")
|
|---|
| 427 | if self.lmax != self.mmax: raise RuntimeError("complex SH requires lmax=mmax and mres=1.")
|
|---|
| 428 | if z.shape != self.spat_shape: raise RuntimeError("spatial array has wrong shape.")
|
|---|
| 429 | if z.dtype.num != np.dtype('complex128').num: raise RuntimeError("spatial array should be dtype=complex128.")
|
|---|
| 430 | if z.flags.contiguous == False: z = z.copy() # contiguous array required.
|
|---|
| 431 | alm = np.empty((self.lmax+1)**2, dtype=complex)
|
|---|
| 432 | self.spat_cplx_to_SH(z,alm)
|
|---|
| 433 | return alm
|
|---|
| 434 |
|
|---|
| 435 | def zidx(self, l,m):
|
|---|
| 436 | """
|
|---|
| 437 | zidx(sht self, int l, int m) -> int : compute the index l*(l+1)+m in a complex spherical harmonic expansion
|
|---|
| 438 | """
|
|---|
| 439 | l = np.asarray(l)
|
|---|
| 440 | m = np.asarray(m)
|
|---|
| 441 | if (l>self.lmax).any() or (abs(m)>l).any() : raise RuntimeError("invalid range for l,m")
|
|---|
| 442 | return l*(l+1)+m
|
|---|
| 443 |
|
|---|
| 444 | def zlm(self, idx):
|
|---|
| 445 | """
|
|---|
| 446 | zlm(sht self, int idx) -> (int,int) : returns the l and m corresponding to the given index in complex spherical harmonic expansion
|
|---|
| 447 | """
|
|---|
| 448 | idx = np.asarray(idx)
|
|---|
| 449 | if (idx >= (self.lmax+1)**2).any() or (idx < 0).any() : raise RuntimeError("invalid range for l,m")
|
|---|
| 450 | l = np.sqrt(idx).astype(int)
|
|---|
| 451 | m = idx - l*(l+1)
|
|---|
| 452 | return l,m
|
|---|
| 453 |
|
|---|
| 454 | def spec_array_cplx(self):
|
|---|
| 455 | """return a numpy array that can hold the spectral representation of a complex scalar spatial field."""
|
|---|
| 456 | return np.zeros((self.lmax+1)**2, dtype=complex)
|
|---|
| 457 |
|
|---|
| 458 | def spat_array_cplx(self):
|
|---|
| 459 | """return a numpy array of 2D complex spatial field."""
|
|---|
| 460 | if self.nlat == 0: raise RuntimeError("Grid not set. Call .set_grid() mehtod.")
|
|---|
| 461 | return np.zeros(self.spat_shape, dtype=complex128)
|
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 | def SH_to_point(self, Qlm, cost, phi):
|
|---|
| 465 | """SH_to_point(sht self, PyObject * Qlm, double cost, double phi) -> double"""
|
|---|
| 466 | return _shtns.sht_SH_to_point(self, Qlm, cost, phi)
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 | def SH_to_grad_point(self, DrSlm, Slm, cost, phi):
|
|---|
| 470 | """SH_to_grad_point(sht self, PyObject * DrSlm, PyObject * Slm, double cost, double phi)"""
|
|---|
| 471 | return _shtns.sht_SH_to_grad_point(self, DrSlm, Slm, cost, phi)
|
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 | def SHqst_to_point(self, Qlm, Slm, Tlm, cost, phi):
|
|---|
| 475 | """SHqst_to_point(sht self, PyObject * Qlm, PyObject * Slm, PyObject * Tlm, double cost, double phi)"""
|
|---|
| 476 | return _shtns.sht_SHqst_to_point(self, Qlm, Slm, Tlm, cost, phi)
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 | def Zrotate(self, Qlm, alpha):
|
|---|
| 480 | """Zrotate(sht self, PyObject * Qlm, double alpha) -> PyObject *"""
|
|---|
| 481 | return _shtns.sht_Zrotate(self, Qlm, alpha)
|
|---|
| 482 |
|
|---|
| 483 |
|
|---|
| 484 | def Yrotate(self, Qlm, alpha):
|
|---|
| 485 | """Yrotate(sht self, PyObject * Qlm, double alpha) -> PyObject *"""
|
|---|
| 486 | return _shtns.sht_Yrotate(self, Qlm, alpha)
|
|---|
| 487 |
|
|---|
| 488 |
|
|---|
| 489 | def Yrotate90(self, Qlm):
|
|---|
| 490 | """Yrotate90(sht self, PyObject * Qlm) -> PyObject *"""
|
|---|
| 491 | return _shtns.sht_Yrotate90(self, Qlm)
|
|---|
| 492 |
|
|---|
| 493 |
|
|---|
| 494 | def Xrotate90(self, Qlm):
|
|---|
| 495 | """Xrotate90(sht self, PyObject * Qlm) -> PyObject *"""
|
|---|
| 496 | return _shtns.sht_Xrotate90(self, Qlm)
|
|---|
| 497 |
|
|---|
| 498 |
|
|---|
| 499 | def SH_mul_mx(self, mx, Qlm):
|
|---|
| 500 | """SH_mul_mx(sht self, PyObject * mx, PyObject * Qlm) -> PyObject *"""
|
|---|
| 501 | return _shtns.sht_SH_mul_mx(self, mx, Qlm)
|
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 | def spat_to_SH_m(self, Vr, Qlm, im):
|
|---|
| 505 | """spat_to_SH_m(sht self, PyObject * Vr, PyObject * Qlm, PyObject * im)"""
|
|---|
| 506 | return _shtns.sht_spat_to_SH_m(self, Vr, Qlm, im)
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 | def SH_to_spat_m(self, Qlm, Vr, im):
|
|---|
| 510 | """SH_to_spat_m(sht self, PyObject * Qlm, PyObject * Vr, PyObject * im)"""
|
|---|
| 511 | return _shtns.sht_SH_to_spat_m(self, Qlm, Vr, im)
|
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 | def spat_to_SHsphtor_m(self, Vt, Vp, Slm, Tlm, im):
|
|---|
| 515 | """spat_to_SHsphtor_m(sht self, PyObject * Vt, PyObject * Vp, PyObject * Slm, PyObject * Tlm, PyObject * im)"""
|
|---|
| 516 | return _shtns.sht_spat_to_SHsphtor_m(self, Vt, Vp, Slm, Tlm, im)
|
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 | def SHsphtor_to_spat_m(self, Slm, Tlm, Vt, Vp, im):
|
|---|
| 520 | """SHsphtor_to_spat_m(sht self, PyObject * Slm, PyObject * Tlm, PyObject * Vt, PyObject * Vp, PyObject * im)"""
|
|---|
| 521 | return _shtns.sht_SHsphtor_to_spat_m(self, Slm, Tlm, Vt, Vp, im)
|
|---|
| 522 |
|
|---|
| 523 |
|
|---|
| 524 | def SHsph_to_spat_m(self, Slm, Vt, Vp, im):
|
|---|
| 525 | """SHsph_to_spat_m(sht self, PyObject * Slm, PyObject * Vt, PyObject * Vp, PyObject * im)"""
|
|---|
| 526 | return _shtns.sht_SHsph_to_spat_m(self, Slm, Vt, Vp, im)
|
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 | def SHtor_to_spat_m(self, Tlm, Vt, Vp, im):
|
|---|
| 530 | """SHtor_to_spat_m(sht self, PyObject * Tlm, PyObject * Vt, PyObject * Vp, PyObject * im)"""
|
|---|
| 531 | return _shtns.sht_SHtor_to_spat_m(self, Tlm, Vt, Vp, im)
|
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 | def spat_to_SHqst_m(self, Vr, Vt, Vp, Qlm, Slm, Tlm, im):
|
|---|
| 535 | """spat_to_SHqst_m(sht self, PyObject * Vr, PyObject * Vt, PyObject * Vp, PyObject * Qlm, PyObject * Slm, PyObject * Tlm, PyObject * im)"""
|
|---|
| 536 | return _shtns.sht_spat_to_SHqst_m(self, Vr, Vt, Vp, Qlm, Slm, Tlm, im)
|
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 | def SHqst_to_spat_m(self, Qlm, Slm, Tlm, Vr, Vt, Vp, im):
|
|---|
| 540 | """SHqst_to_spat_m(sht self, PyObject * Qlm, PyObject * Slm, PyObject * Tlm, PyObject * Vr, PyObject * Vt, PyObject * Vp, PyObject * im)"""
|
|---|
| 541 | return _shtns.sht_SHqst_to_spat_m(self, Qlm, Slm, Tlm, Vr, Vt, Vp, im)
|
|---|
| 542 |
|
|---|
| 543 | sht_swigregister = _shtns.sht_swigregister
|
|---|
| 544 | sht_swigregister(sht)
|
|---|
| 545 |
|
|---|
| 546 |
|
|---|
| 547 | def nlm_calc(lmax, mmax, mres):
|
|---|
| 548 | """nlm_calc(long lmax, long mmax, long mres) -> long"""
|
|---|
| 549 | return _shtns.nlm_calc(lmax, mmax, mres)
|
|---|
| 550 |
|
|---|
| 551 | def set_verbosity(arg1):
|
|---|
| 552 | """set_verbosity(int arg1)"""
|
|---|
| 553 | return _shtns.set_verbosity(arg1)
|
|---|
| 554 |
|
|---|
| 555 | def print_version():
|
|---|
| 556 | """print_version()"""
|
|---|
| 557 | return _shtns.print_version()
|
|---|
| 558 | # This file is compatible with both classic and new-style classes.
|
|---|
| 559 |
|
|---|
| 560 |
|
|---|