pyharm.crd#
Module to work with the coordinates of evaluation points/cells:
defines the following classes
pyharm.crd.PointSctr
,pyharm.crd.PointGrid
,pyharm.crd.PointGridGL
,pyharm.crd.PointGridDH1
,pyharm.crd.PointGridDH2
,pyharm.crd.CellSctr
andpyharm.crd.CellGrid
,computes Gauss–Legendre and Driscoll–Healy quadrature grids.
Note
This documentation is written for double precision version of PyHarm.
- class pyharm.crd.PointSctr(npoint, data)#
Class for scattered points.
For details, refer to charm_crd.
To create a
PointSctr
class instance, always use one of the following factory methods:Example
Create an instance with 5 scattered points and all array elements initialized to zero:
>>> import pyharm as ph >>> grd = ph.crd.PointSctr.from_zeros(5)
Create an instance with 3 scattered points with latitudes, longitudes and spherical radii taken from numpy arrays:
>>> import numpy as np >>> import pyharm as ph >>> lat = np.array([0.1, 0.2, 0.3]) >>> lon = np.array([0.5, 0.6, 0.7]) >>> r = np.array([1.1, 1.2, 1.3]) >>> sctr = ph.crd.PointGrid.from_arrays(lat, lon, r)
- Parameters:
npoint (integer) – Number of scattered points
data (None, 0 or tuple) –
Determines the way of initializing array elements:
None
to not initialize array elements (malloc
in C),0
to set all array elements to zero (calloc
in C),(lat, lon, r)
to define the object’s latitudes, longitudes and spherical radii, respectively. Thelat
,lon
andr
variables must be numpy floating point arrays of dimension1
. The number of elements inlat
,lon
andr
must match.
Note
Once a
PointSctr
class instance is created, its attributes are not writeable, but all array elements are writeable.- classmethod from_garbage(npoint)#
Returns a
PointSctr
class instance with uninitialized array elements (malloc
in C).
- classmethod from_zeros(npoint)#
Returns a
PointSctr
class instance with all array elements initialized to zero (calloc
in C).
- classmethod from_arrays(lat, lon, r)#
Returns a
PointSctr
class instance with spherical latitudes, longitudes and spherical radii taken fromlat
,lon
andr
, respectively.
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shc
for documentation.
- property r#
Spherical radii.
- class pyharm.crd.PointGrid(nlat, nlon, data)#
Class for custom point grids.
For details, refer to charm_crd.
To create a
PointGrid
class instance, always use one of the following factory methods:Examples
Create an instance with 5 grid latitudes and 10 grid longitudes and initialize all array elements to zero:
>>> import ph >>> grd = ph.crd.PointGrid.from_zeros(5, 10)
Create an instance with grid latitudes, longitudes and spherical radii taken from numpy arrays:
>>> import numpy as np >>> import pyharm as ph >>> lat = np.array([0.1, 0.2, 0.3]) >>> lon = np.array([0.5, 0.6, 0.7, 0.8, 0.9]) >>> r = np.array([1.1, 1.2, 1.3]) >>> grd = ph.crd.PointGrid.from_arrays(lat, lon, r)
- Parameters:
nlat (integer) – Number of grid latitudes
nlon (integer) – Number of grid longitudes
data (None, 0 or tuple) –
Determines the way of initializing array elements:
None
to not initialize array elements (malloc
in C),0
to set all array elements to zero (calloc
in C),(lat, lon, r)
to define the object’s latitudes, longitudes and spherical radii, respectively. Thelat
,lon
andr
variables must be numpy floating point arrays of the dimension1
. The shape oflat
andlon
as well as the shape oflat
andr
must match.
Note
Once a
PointGrid
class instance is created, its attributes are not writeable, but all array elements are writeable.- classmethod from_garbage(nlat, nlon)#
Returns a
PointGrid
class instance with uninitialized array elements (malloc
in C).
- classmethod from_zeros(nlat, nlon)#
Returns a
PointGrid
class instance with all array elements initialized to zero (calloc
in C).
- classmethod from_arrays(lat, lon, r)#
Returns a
PointGrid
class instance with spherical latitudes, longitudes and spherical radii taken fromlat
,lon
andr
, respectively.
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shc
for documentation.
- property r#
Spherical radii.
- class pyharm.crd.PointGridGL(nmax, r=1.0)#
Class for Gauss–Legendre point grids.
For details, refer to charm_crd.
Create a
PointGridGL
class instance like this:>>> import pyharm as ph >>> gl = ph.crd.PointGridGL(10)
- Parameters:
nmax (integer) – Maximum harmonic degree associated with the quadrature grid
r (floating point) – Spherical radius of grid meridians, optional. Default value is
1.0
.
Note
Once a
PointGridGL
class instance is created, neither its attributes nor its array elements are writeable.- property w#
Integration weights on the unit sphere.
- property nmax#
Maximum harmonic degree associated with the quadrature grid points.
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shc
for documentation.
- property r#
Spherical radii.
- class pyharm.crd.PointGridDH1(nmax, r=1.0)#
Class for non-equiangular Driscoll–Healy point grids.
For details, refer to charm_crd.
Create a
PointGridDH1
class instance like this:>>> import pyharm as ph >>> gl = ph.crd.PointGridDH1(10)
- Parameters:
nmax (integer) – Maximum harmonic degree associated with the quadrature grid
r (floating point) – Spherical radius of grid meridians, optional. Default value is
1.0
.
Note
Once a
PointGridDH1
class instance is created, neither its attributes nor its array elements are writeable.- property w#
Integration weights on the unit sphere.
- property nmax#
Maximum harmonic degree associated with the quadrature grid points.
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shc
for documentation.
- property r#
Spherical radii.
- class pyharm.crd.PointGridDH2(nmax, r=1.0)#
Class for equiangular Driscoll–Healy point grids.
For details, refer to charm_crd.
Create a
PointGridDH2
class instance like this:>>> import pyharm as ph >>> gl = ph.crd.PointGridDH2(10)
- Parameters:
nmax (integer) – Maximum harmonic degree associated with the quadrature grid
r (floating point) – Spherical radius of grid meridians, optional. Default value is
1.0
.
Note
Once a
PointGridDH2
class instance is created, neither its attributes nor its array elements are writeable.- property w#
Integration weights on the unit sphere.
- property nmax#
Maximum harmonic degree associated with the quadrature grid points.
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shc
for documentation.
- property r#
Spherical radii.
- class pyharm.crd.CellSctr(ncell, data)#
Class for scattered cells.
For details, refer to charm_crd.
To create a
CellSctr
class instance, always use one of the following factory methods:Examples
Create an instance with 5 scattered cells and all array elements initialized to zero:
>>> import pyharm as ph >>> grd = ph.crd.CellSctr.from_zeros(5)
Create an instance with 3 scattered cells with latitudes, longitudes and spherical radii taken from numpy arrays:
>>> import numpy as np >>> import pyharm as ph >>> latmin = np.array([0.1, 0.2, 0.3]) >>> latmax = latmin + 0.1 >>> lonmin = np.array([0.5, 0.6, 0.7]) >>> lonmax = lonmin + 0.1 >>> r = np.array([1.1, 1.2, 1.3]) >>> sctr = ph.crd.CellSctr.from_arrays(latmin, latmax, >>> lonmin, lonmax, r)
- Parameters:
nlat (integer) – Number of grid latitudes
nlon (integer) – Number of grid longitudes
data (None, 0 or tuple) –
Determines the way of initializing array elements:
None
to not initialize array elements (malloc
in C),0
to set all array elements to zero (calloc
in C),(latmin, latmax, lonmin, lonmax, r)
to define the object’s minimum and maximum cell latitudes, minimum and maximum cell longitudes and spherical radii, respectively. Thelatmin
,latmax
,lonmin
,lonmax
andr
variables must be numpy floating point arrays of dimension1
. All arrays must share the same number of elements.
Note
Once a
CellSctr
class instance is created, its attributes are not writeable, but all array elements are writeable.- classmethod from_garbage(ncell)#
Returns a
CellSctr
class instance with uninitialized array elements (malloc
in C).
- classmethod from_zeros(ncell)#
Returns a
CellSctr
class instance with all array elements initialized to zero (calloc
in C).
- classmethod from_arrays(latmin, latmax, lonmin, lonmax, r)#
Returns a
CellSctr
class instance with minimum and maximum spherical cell latitudes, minimum and maximum cell longitudes and spherical radii taken fromlatmin
,latmax
,lonmin
,lonmax
andr
, respectively.- Parameters:
latmin (numpy array of floating points) – Minimum spherical cell latitudes
latmax (numpy array of floating points) – Maximum spherical cell latitudes
lonmin (numpy array of floating points) – Minimum spherical cell longitudes
lonmax (numpy array of floating points) – Maximum spherical cell longitudes
r (numpy array of floating points) – Spherical radii
- Returns:
out –
CellSctr
class instance- Return type:
- property latmax#
Maximum spherical cell latitudes.
- property latmin#
Minimum spherical cell latitudes.
- property lonmax#
Maximum spherical cell longitudes.
- property lonmin#
Minimum spherical cell longitudes.
- property ncell#
Total number of cells.
- property owner#
Refer to
pyharm.shc.Shc
for documentation.
- property r#
Spherical radii (constant over each cell).
- class pyharm.crd.CellGrid(nlat, nlon, data)#
Class for custom cell grids.
For details, refer to charm_crd.
To create a
CellGrid
class instance, always use one of the following factory methods:Examples
Create an instance with 5 grid latitudes and 10 grid longitudes and initialize all array elements to zero:
>>> import pyharm as ph >>> grd = ph.crd.CellGrid.from_zeros(5, 10)
Create an instance with grid latitudes, longitudes and spherical radii taken from numpy arrays:
>>> import numpy as np >>> import pyharm as ph >>> latmin = np.array([0.1, 0.2, 0.3]) >>> latmax = latmin + 0.1 >>> lonmin = np.array([0.5, 0.6, 0.7, 0.8, 0.9]) >>> lonmax = lonmin + 0.1 >>> r = np.array([1.1, 1.2, 1.3]) >>> grd = ph.crd.CellGrid.from_arrays(latmin, latmax, >>> lonmin, lonmax, r)
- Parameters:
nlat (integer) – Number of grid latitudes
nlon (integer) – Number of grid longitudes
data (None, 0 or tuple) –
Determines the way of initializing array elements:
None
to not initialize array elements (malloc
in C),0
to set all array elements to zero (calloc
in C),(latmin, latmax, lonmin, lonmax, r)
to define the object’s minimum and maximum cell latitudes, minimum and maximum cell longitudes and spherical radii, respectively. Thelatmin
,latmax
,lonmin
,lonmax
andr
variables must be numpy floating point arrays of dimension1
. Thelatmin
,latmax
andr
arrays must have the same number of elements, the same is true forlonmin
andlonmax
.
Note
Once a
CellGrid
class instance is created, its attributes are not writeable, but all array elements are writeable.- property latmax#
Maximum spherical cell latitudes.
- property latmin#
Minimum spherical cell latitudes.
- property lonmax#
Maximum spherical cell longitudes.
- property lonmin#
Minimum spherical cell longitudes.
- property ncell#
Total number of cells.
- property owner#
Refer to
pyharm.shc.Shc
for documentation.
- property r#
Spherical radii (constant over each cell).
- classmethod from_garbage(nlat, nlon)#
Returns a
CellGrid
class instance with uninitialized array elements (malloc
in C).
- classmethod from_zeros(nlat, nlon)#
Returns a
CellGrid
class instance with all array elements initialized to zero (calloc
in C).
- classmethod from_arrays(latmin, latmax, lonmin, lonmax, r)#
Returns a
CellGrid
class instance with minimum and maximum spherical cell latitudes, minimum and maximum cell longitudes and spherical radii taken fromlatmin
,latmax
,lonmin
,lonmax
andr
, respectively.- Parameters:
latmin (numpy array of floating points) – Minimum spherical cell latitudes
latmax (numpy array of floating points) – Maximum spherical cell latitudes
lonmin (numpy array of floating points) – Minimum spherical cell longitudes
lonmax (numpy array of floating points) – Maximum spherical cell longitudes
r (numpy array of floating points) – Spherical radii
- Returns:
out –
CellGrid
class instance- Return type: