| |
- can_use_sphere(longitude, latitude)
- Test if can use sphere package.
Calling Sequence:
Result = can_use_sphere(longitude, latitude)
Note that Result is a 3-element tuple, not a scalar. See the
description below for details.
Test if the longitude-latitude domain and Python package configur-
ation allows use of the NCAR SPHEREPACK 3.0 package. Specifically
the function tests:
(1) Can you import sphere?
(2) Is the longitude vector evenly spaced?
(3) Does the longitude vector entirely span the globe, but doesn't
repeat?
(4) Is the latitude vector gaussian? If not, is it evenly spaced
and includes the poles?
If the answer to (1) is no, then there's no use to go through the
other tests and the function return tuple element [0] is 0. If (2)
or (3) is no, return tuple element [0] is 0. If (4) is both not
gaussian and not evenly spaced with the poles, return tuple
element [0] is 0. Otherwise, return tuple element [0] is 1. Note
that (4) uses the latitude checker in the sphere package.
Method Arguments:
* longitude: Vector of longitudes of the domain [deg]. Can be
in any order, and a Numeric array or regular list/tuple.
* latitude: Vector of latitudes of the domain [deg]. Can be in
any order, and a Numeric array or regular list/tuple.
Output Result:
* A 3-element tuple:
[0]: 1 if the longitude-latitude domain and Python package
configuration passes tests to allow use of the NCAR
SPHEREPACK 3.0 package. 0 if does not pass those tests.
[1]: String containing messages written to stdout by calls to
module sphere used for checking latitude (e.g. if it is
gaussian, etc.). If there are no messages or there were
no calls needed to sphere for checking latitude, value is
empty string.
[2]: Same as [1] except contains stderr messages.
Examples:
>>> from can_use_sphere import can_use_sphere
>>> import Numeric as N
>>> lon = N.arange(36)*10
>>> lat = [-90, -60, -30, 0, 30, 60, 90]
>>> can_use_sphere(lon, lat)[0]
1
>>> lat = [-90, -60, -30, 0, 30, 60, 87]
>>> can_use_sphere(lon, lat)[0]
0
>>> can_use_sphere(lon, lat)[1].splitlines()[1]
'CANNOT PROCESS THE DATA - Latitude values are incorrect'
|