geocontour.grid module

Functions for operations involving grid values and dimensions

geocontour.grid.spacing(dimension)

Calculate the grid spacing for a given input dimension

Parameters:

dimension (ndarray) – 1D Nx1 array of longitude or latitude points (degrees)

Returns:

spacing – value specifying the spacing of the input dimension (degrees)

Return type:

float

geocontour.grid.lonlens(latitudes, lonspacing=1)

Calculate the lengths of a degree (default) of longitude over a range of latitudes

Parameters:
  • latitudes (ndarray) – 1D Nx1 array of latitude points (degrees)

  • lonspacing (float, default=1) – value specifying longitude spacing [e.g. for lengths of a half degree of longitude at the given latitudes, lonspacing = 0.5]

Returns:

lonlens – 1D Nx1 array of longitude lengths (m)

Return type:

ndarray

See also

latlens, lonlen, latlen

References

Osborne, P. (2013). The Mercator Projections. Zenodo. <https://doi.org/10.5281/zenodo.35392>

geocontour.grid.latlens(latitudes)

Calculate the lengths of a defined range of latitudes

Parameters:

latitudes (ndarray) – 1D Nx1 array of latitude points (degrees)

Returns:

latlens – 1D Nx1 array of latitude lengths (m)

Return type:

ndarray

See also

lonlens, lonlen, latlen

References

Osborne, P. (2013). The Mercator Projections. Zenodo. <https://doi.org/10.5281/zenodo.35392>

geocontour.grid.lonlen(latitude)

Calculate the length(s) of a degree of longitude at the input latitude(s)

Parameters:

latitude (ndarray/float) – float or 1D Nx1 array of latitude point(s) (degrees)

Returns:

lonlen – float or 1D Nx1 array of longitude length(s) (m)

Return type:

ndarray/float

See also

lonlens, latlens, latlen

References

Osborne, P. (2013). The Mercator Projections. Zenodo. <https://doi.org/10.5281/zenodo.35392>

geocontour.grid.latlen(latitude)

Calculate the length(s) of a degree of latitude at the input latitude(s)

Parameters:

latitude (ndarray/float) – float or 1D Nx1 array of latitude point(s) (degrees)

Returns:

lonlen – float or 1D Nx1 array of latitude length(s) (m)

Return type:

ndarray/float

See also

lonlens, latlens, lonlen

References

Osborne, P. (2013). The Mercator Projections. Zenodo. <https://doi.org/10.5281/zenodo.35392>

geocontour.grid.areas(latitudes, longitudes, units=1)

Calculate the cell areas of a grid defined by a range of latitudes and longitudes

Parameters:
  • latitudes (ndarray) – 1D Nx1 array of latitude points (degrees)

  • longitudes (ndarray) – 1D Nx1 array of longitude points (degrees)

  • units (float, default=1 (m^2)) – unit multiplier for areas [e.g. for km^2, mult = 1000m x 1000m = 1e6]

Returns:

areas – 2D MxN array of areas (default in m^2) where M=len(latitudes) and N=len(longitudes)

Return type:

ndarray

See also

lonlens, latlens

References

Osborne, P. (2013). The Mercator Projections. Zenodo. <https://doi.org/10.5281/zenodo.35392>

geocontour.grid.clonrng(longitudes)

Find the range of a set of longitude points

  • negative (-180 to 180)

  • positive (0 to 360)

  • indeterminate (0 to 180)

Parameters:

longitudes (ndarray) – 1D Nx1 array of longitude points (degrees)

Returns:

longituderange

descriptor for the range of the input longitudes

neg

-180 to 180 degrees

pos

0 to 360 degrees

ind

0 to 180 degrees

Return type:

{‘neg’, ‘pos’, ‘ind’}

See also

switchlon, switchind

geocontour.grid.clatdir(latitudes)
Find the directionality of a set of latitude points
  • increasing (lowest to highest)

  • decreasing (highest to lowest)

Parameters:

latitudes (ndarray) – 1D Nx1 array of latitude points (degrees)

Returns:

latitudedirection

descriptor for the direction of the input latitudes

inc

lowest to highest latitudes

dec

highest to lowest latitudes

Return type:

{‘inc’, ‘dec’}

geocontour.grid.switchlon(longitudes, outrange, print_output=False)

Switch a set of longitude points place between negative (-180 to 180) and positive (0 to 360)

Parameters:
  • longitudes (ndarray) – 1D Nx1 array of longitude points (degrees)

  • outrange ({'pos', 'neg'}) – select range for longitude outputs [i.e. positive (0 to 360) or negative (-180 to 180)]

  • print_output (bool, default=False) – flag to print out whether input was altered

Returns:

switchlon – 1D Nx1 array of longitude points equal to input longitudes, but altered (if necessary) to be consistent with selected output range

Return type:

ndarray

See also

clonrng, switchind

geocontour.grid.switchind(longitudes)

Find the index where a longitude array crosses either 0 or 180 degrees

Parameters:

longitudes (ndarray) – 1D Nx1 array of longitude points (degrees)

Returns:

switchind – index for where input longitudes crosses 0 or 180 degrees, or 0 if no such point exists

Return type:

int

See also

clonrng, switchlon