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.CellSctrandpyharm.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
PointSctrclass 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:
Noneto not initialize array elements (mallocin C),0to set all array elements to zero (callocin C),(lat, lon, r)to define the object’s latitudes, longitudes and spherical radii, respectively. Thelat,lonandrvariables must be numpy floating point arrays of dimension1. The number of elements inlat,lonandrmust match.
Note
Once a
PointSctrclass instance is created, its attributes are not writeable, but all array elements are writeable.- classmethod from_garbage(npoint)#
Returns a
PointSctrclass instance with uninitialized array elements (mallocin C).
- classmethod from_zeros(npoint)#
Returns a
PointSctrclass instance with all array elements initialized to zero (callocin C).
- classmethod from_arrays(lat, lon, r)#
Returns a
PointSctrclass instance with spherical latitudes, longitudes and spherical radii taken fromlat,lonandr, respectively.
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shcfor 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
PointGridclass 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:
Noneto not initialize array elements (mallocin C),0to set all array elements to zero (callocin C),(lat, lon, r)to define the object’s latitudes, longitudes and spherical radii, respectively. Thelat,lonandrvariables must be numpy floating point arrays of the dimension1. The shape oflatandrmust match.
Note
Once a
PointGridclass instance is created, its attributes are not writeable, but all array elements are writeable.- classmethod from_garbage(nlat, nlon)#
Returns a
PointGridclass instance with uninitialized array elements (mallocin C).
- classmethod from_zeros(nlat, nlon)#
Returns a
PointGridclass instance with all array elements initialized to zero (callocin C).
- classmethod from_arrays(lat, lon, r)#
Returns a
PointGridclass instance with spherical latitudes, longitudes and spherical radii taken fromlat,lonandr, respectively.
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shcfor documentation.
- property r#
Spherical radii.
- class pyharm.crd.PointGridGL(nmax, r=np.float64(1.0))#
Class for Gauss–Legendre point grids.
For details, refer to charm_crd.
Create a
PointGridGLclass 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
PointGridGLclass 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.
- static shape(nmax)#
Returns the number of latitudes
nlatand the number of longitudesnlonof the Gauss-Legendre grid that corresponds to the maximum harmonic degreenmax.- Parameters:
nmax (integer) – Maximum harmonic degree of the Gauss-Legendre grid
- Returns:
nlat (integer) – Number of latitudes
nlon (integer) – Number of longitudes
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shcfor documentation.
- property r#
Spherical radii.
- class pyharm.crd.PointGridDH1(nmax, r=np.float64(1.0))#
Class for non-equiangular Driscoll–Healy point grids.
For details, refer to charm_crd.
Create a
PointGridDH1class 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
PointGridDH1class 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.
- static shape(nmax)#
Returns the number of latitudes
nlatand the number of longitudesnlonof the non-equiangular Driscoll-Healy grid that corresponds to the maximum harmonic degreenmax.- Parameters:
nmax (integer) – Maximum harmonic degree of the Driscoll-Healy grid
- Returns:
nlat (integer) – Number of latitudes
nlon (integer) – Number of longitudes
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shcfor documentation.
- property r#
Spherical radii.
- class pyharm.crd.PointGridDH2(nmax, r=np.float64(1.0))#
Class for equiangular Driscoll–Healy point grids.
For details, refer to charm_crd.
Create a
PointGridDH2class 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
PointGridDH2class 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.
- static shape(nmax)#
Returns the number of latitudes
nlatand the number of longitudesnlonof the equiangular Driscoll-Healy grid that corresponds to the maximum harmonic degreenmax.- Parameters:
nmax (integer) – Maximum harmonic degree of the Driscoll-Healy grid
- Returns:
nlat (integer) – Number of latitudes
nlon (integer) – Number of longitudes
- property lat#
Spherical latitudes.
- property lon#
Spherical longitudes.
- property npoint#
Total number of points.
- property owner#
Refer to
pyharm.shc.Shcfor documentation.
- property r#
Spherical radii.
- class pyharm.crd.CellSctr(ncell, data)#
Class for scattered cells.
For details, refer to charm_crd.
To create a
CellSctrclass 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:
Noneto not initialize array elements (mallocin C),0to set all array elements to zero (callocin 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,lonmaxandrvariables must be numpy floating point arrays of dimension1. All arrays must share the same number of elements.
Note
Once a
CellSctrclass instance is created, its attributes are not writeable, but all array elements are writeable.- classmethod from_garbage(ncell)#
Returns a
CellSctrclass instance with uninitialized array elements (mallocin C).
- classmethod from_zeros(ncell)#
Returns a
CellSctrclass instance with all array elements initialized to zero (callocin C).
- classmethod from_arrays(latmin, latmax, lonmin, lonmax, r)#
Returns a
CellSctrclass instance with minimum and maximum spherical cell latitudes, minimum and maximum cell longitudes and spherical radii taken fromlatmin,latmax,lonmin,lonmaxandr, 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 –
CellSctrclass 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.Shcfor 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
CellGridclass 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:
Noneto not initialize array elements (mallocin C),0to set all array elements to zero (callocin 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,lonmaxandrvariables must be numpy floating point arrays of dimension1. Thelatmin,latmaxandrarrays must have the same number of elements, the same is true forlonminandlonmax.
Note
Once a
CellGridclass 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.Shcfor documentation.
- property r#
Spherical radii (constant over each cell).
- classmethod from_garbage(nlat, nlon)#
Returns a
CellGridclass instance with uninitialized array elements (mallocin C).
- classmethod from_zeros(nlat, nlon)#
Returns a
CellGridclass instance with all array elements initialized to zero (callocin C).
- classmethod from_arrays(latmin, latmax, lonmin, lonmax, r)#
Returns a
CellGridclass instance with minimum and maximum spherical cell latitudes, minimum and maximum cell longitudes and spherical radii taken fromlatmin,latmax,lonmin,lonmaxandr, 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 –
CellGridclass instance- Return type: