pyharm.crd#

Module to work with the coordinates of evaluation points/cells:

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 PointGrid 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. The lat, lon and r variables must be numpy floating point arrays of dimension 1. The number of elements in lat, lon and r must match.

Note

Once a PointGrid 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).

Parameters:

npoint (integer) – Number of scattered points

Returns:

outPointSctr class instance

Return type:

PointSctr

classmethod from_zeros(npoint)#

Returns a PointSctr class instance with all array elements initialized to zero (calloc in C).

Parameters:

npoint (integer) – Number of scattered points

Returns:

outPointSctr class instance

Return type:

PointSctr

classmethod from_arrays(lat, lon, r)#

Returns a PointSctr class instance with spherical latitudes, longitudes and spherical radii taken from lat, lon and r, respectively.

Parameters:
  • lat (numpy array of floating points) – Spherical latitudes

  • lon (numpy array of floating points) – Spherical longitudes

  • r (numpy array of floating points) – Spherical radii

Returns:

outPointSctr class instance

Return type:

PointSctr

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. The lat, lon and r variables must be numpy floating point arrays of the dimension 1. The shape of lat and lon as well as the shape of lat and r 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).

Parameters:
  • nlat (integer) – Number of grid latitudes

  • nlon (integer) – Number of grid longitudes

Returns:

outPointGrid class instance

Return type:

PointGrid

classmethod from_zeros(nlat, nlon)#

Returns a PointGrid class instance with all array elements initialized to zero (calloc in C).

Parameters:
  • nlat (integer) – Number of grid latitudes

  • nlon (integer) – Number of grid longitudes

Returns:

outPointGrid class instance

Return type:

PointGrid

classmethod from_arrays(lat, lon, r)#

Returns a PointGrid class instance with spherical latitudes, longitudes and spherical radii taken from lat, lon and r, respectively.

Parameters:
  • lat (numpy array of floating points) – Spherical latitudes

  • lon (numpy array of floating points) – Spherical longitudes

  • r (numpy array of floating points) – Spherical radii

Returns:

outPointGrid class instance

Return type:

PointGrid

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 CellGrid 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. The latmin, latmax, lonmin, lonmax and r variables must be numpy floating point arrays of dimension 1. All arrays must share the same number of elements.

Note

Once a CellGrid 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).

Parameters:

ncell (integer) – Number of scattered cells

Returns:

outCellSctr class instance

Return type:

CellSctr

classmethod from_zeros(ncell)#

Returns a CellSctr class instance with all array elements initialized to zero (calloc in C).

Parameters:

ncell (integer) – Number of scattered cells

Returns:

outCellSctr class instance

Return type:

CellSctr

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 latmin, latmax, lonmin, lonmax and r, 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:

outCellSctr class instance

Return type:

CellSctr

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. The latmin, latmax, lonmin, lonmax and r variables must be numpy floating point arrays of dimension 1. The latmin, latmax and r arrays must have the same number of elements, the same is true for lonmin and lonmax.

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).

Parameters:
  • nlat (integer) – Number of grid latitudes

  • nlon (integer) – Number of grid longitudes

Returns:

outCellGrid class instance

Return type:

CellGrid

classmethod from_zeros(nlat, nlon)#

Returns a CellGrid class instance with all array elements initialized to zero (calloc in C).

Parameters:
  • nlat (integer) – Number of grid latitudes

  • nlon (integer) – Number of grid longitudes

Returns:

outCellGrid class instance

Return type:

CellGrid

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 from latmin latmax, lonmin, lonmax and r, 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:

outCellGrid class instance

Return type:

CellGrid