Package pygeodesy :: Module utily |
[frames] | no frames]

# Module utily

Geometric and other utility functions and constants.

After (C) Chris Veness 2011-2015 published under the same MIT Licence**, see Latitude/Longitude and Vector-based geodesy.

Version: 20.03.19

Functions
degrees(x) Convert angle x from radians to degrees. |
radians(x) Convert angle x from degrees to radians. |
degrees90(rad) Convert radians to degrees and wrap [-270..+90]. |
degrees180(rad) Convert radians to degrees and wrap [-180..+180]. |
degrees360(rad) Convert radians to degrees and wrap [0..+360). |
degrees2m(deg, radius=6371008.77141, lat=0) Convert angle to distance along the equator or along a parallel at an other latitude. |
false2f(value, name=`'``value``'`, false=True, Error=<type 'exceptions.ValueError'>) Convert a false east-/northing to non-negative float. |
ft2m(feet, usurvey=False) Convert International or US Survey feet to meter. |
isNumpy2(obj) Check for an `Numpy2LatLon` points wrapper. |
isPoints2(obj) Check for an `LatLon2psxy` points wrapper. |
isTuple2(obj) Check for an `Tuple2LatLon` points wrapper. |
iterNumpy2(obj) Iterate over Numpy2 wrappers or other sequences exceeding the threshold. |
iterNumpy2over(n=None) Get or set the iterNumpy2 threshold. |
m2degrees(meter, radius=6371008.77141) Convert distance to angle along equator. |
m2ft(meter, usurvey=False) Convert meter to International or US Survey feet (`ft`). |
m2km(meter) Convert meter to kilo meter (km). |
m2NM(meter) Convert meter to nautical miles (NM). |
m2SM(meter) Convert meter to statute miles (SM). |
radiansPI(deg) Convert and wrap degrees to radians [-PI..+PI]. |
radiansPI2(deg) Convert and wrap degrees to radians [0..+2PI). |
radiansPI_2(deg) Convert and wrap degrees to radians [-3PI/2..+PI/2]. |
sincos2(*rad) Return the `sine` and `cosine` of angle(s). |
sincos2d(*deg) Return the `sine` and `cosine` of angle(s) in `degrees`. |
tan_2(rad) Compute the tangent of half angle. |
tanPI_2_2(rad) Compute the tangent of half angle, 90 degrees rotated. |
unroll180(lon1, lon2, wrap=True) Unroll longitudinal delta and wrap longitude in degrees. |
unrollPI(rad1, rad2, wrap=True) Unroll longitudinal delta and wrap longitude in radians. |
wrap90(deg) Wrap degrees to [-270..+90]. |
wrap180(deg) Wrap degrees to [-180..+180]. |
wrap360(deg) Wrap degrees to [0..+360). |
wrapPI(rad) Wrap radians to [-PI..+PI]. |
wrapPI2(rad) Wrap radians to [0..+2PI). |
wrapPI_2(rad) Wrap radians to [-3PI/2..+PI/2]. |

Variables
| PI = `3.14159265359`
| __all__ = `_ALL_LAZY.utily`
| PI2 = `6.28318530718` Two PI, PI * 2 aka Tau (`float`) # PYCHOK expected
| PI_2 = `1.57079632679` Half PI, PI / 2 (`float`)
| PI_4 = `0.785398163397` Quarter PI, PI / 4 (`float`)

Function Details

### degrees90(rad) |
Convert radians to degrees and wrap [-270..+90]. Parameters: `rad` - Angle (`radians`). Returns: Angle in degrees, wrapped (`degrees90`).

### degrees180(rad) |
Convert radians to degrees and wrap [-180..+180]. Parameters: `rad` - Angle (`radians`). Returns: Angle in degrees, wrapped (`degrees180`).

### degrees360(rad) |
Convert radians to degrees and wrap [0..+360). Parameters: `rad` - Angle (`radians`). Returns: Angle in degrees, wrapped (`degrees360`).

### degrees2m(deg, radius=6371008.77141, lat=0) |
Convert angle to distance along the equator or along a parallel at an other latitude. Parameters: `deg` - Angle (`degrees`). `radius` - Mean earth radius (`meter`). `lat` - Parallel latitude (`degrees90`). Returns: Distance (`meter`, same units as `radius`). Raises: `RangeError` - Latitude `lat` outside valid range and rangerrors set to `True`.

### false2f(value, name=`'``value``'`, false=True, Error=<type 'exceptions.ValueError'>) |
Convert a false east-/northing to non-negative float. Parameters: `value` - Value to convert (`scalar`). `name` - Optional name of the value (`str`). `false` - Optionally, value includes false origin (`bool`). `Error` - Exception to raise (`ValueError`). Returns: The value (`float`). Raises: `Error` - Invalid or negative `value`.

### ft2m(feet, usurvey=False) |
Convert International or US Survey feet to meter. Parameters: `feet` - Value in feet (`scalar`). `usurvery` - Convert US Survey feet (`bool`), International feet otherwise. Returns: Value in `meter` (`float`).

### isNumpy2(obj) |
Check for an `Numpy2LatLon` points wrapper. Parameters: `obj` - The object (any `type`). Returns: `True` if `obj` is an `Numpy2LatLon` instance, `False` otherwise.

### isPoints2(obj) |
Check for an `LatLon2psxy` points wrapper. Parameters: `obj` - The object (any `type`). Returns: `True` if `obj` is an `LatLon2psxy` instance, `False` otherwise.

### isTuple2(obj) |
Check for an `Tuple2LatLon` points wrapper. Parameters: `obj` - The object (any). Returns: `True` if `obj` is an `Tuple2LatLon` instance, `False` otherwise.

### iterNumpy2(obj) |
Iterate over Numpy2 wrappers or other sequences exceeding the threshold. Parameters: `obj` - Points array, list, sequence, set, etc. (any). Returns: `True` do, `False` don't iterate.

### iterNumpy2over(n=None) |
Get or set the iterNumpy2 threshold. Parameters: `n` - Optional, new threshold (`int`). Returns: Previous threshold (`int`). Raises: `ValueError` - Invalid `n`.

### m2degrees(meter, radius=6371008.77141) |
Convert distance to angle along equator. Parameters: `meter` - Distance (`meter`, same units as `radius`). `radius` - Mean earth radius (`meter`). Returns: Angle (`degrees`). Raises: `ValueError` - Invalid `radius`.

### m2ft(meter, usurvey=False) |
Convert meter to International or US Survey feet (`ft`). Parameters: `meter` - Value in meter (`scalar`). `usurvery` - Convert to US Survey feet (`bool`), International feet otherwise. Returns: Value in `feet` (`float`).

### m2km(meter) |
Convert meter to kilo meter (km). Parameters: `meter` - Value in meter (`scalar`). Returns: Value in km (`float`).

### m2NM(meter) |
Convert meter to nautical miles (NM). Parameters: `meter` - Value in meter (`scalar`). Returns: Value in NM (`float`).

### m2SM(meter) |
Convert meter to statute miles (SM). Parameters: `meter` - Value in meter (`scalar`). Returns: Value in SM (`float`).

### radiansPI(deg) |
Convert and wrap degrees to radians [-PI..+PI]. Parameters: `deg` - Angle (`degrees`). Returns: Radians, wrapped (`radiansPI`)

### radiansPI2(deg) |
Convert and wrap degrees to radians [0..+2PI). Parameters: `deg` - Angle (`degrees`). Returns: Radians, wrapped (`radiansPI2`)

### radiansPI_2(deg) |
Convert and wrap degrees to radians [-3PI/2..+PI/2]. Parameters: `deg` - Angle (`degrees`). Returns: Radians, wrapped (`radiansPI_2`)

### sincos2(*rad) |
Return the `sine` and `cosine` of angle(s). Parameters: `rad` - One or more angles (`radians`). Returns: The `sin(rad)` and `cos(rad)` for each angle. See Also: GeographicLib function sincosd and C++ sincosd.

### sincos2d(*deg) |
Return the `sine` and `cosine` of angle(s) in `degrees`. Parameters: `deg` - One or more angles (`degrees`). Returns: The `sin(rad)` and `cos(rad)` for each angle. See Also: GeographicLib function sincosd and C++ sincosd.

### tan_2(rad) |
Compute the tangent of half angle. Parameters: `rad` - Angle (`radians`). Returns: tan(rad / 2) (`float`).

### tanPI_2_2(rad) |
Compute the tangent of half angle, 90 degrees rotated. Parameters: `rad` - Angle (`radians`). Returns: tan((rad + PI/2) / 2) (`float`).

### unroll180(lon1, lon2, wrap=True) |
Unroll longitudinal delta and wrap longitude in degrees. Parameters: `lon1` - Start longitude (`degrees`). `lon2` - End longitude (`degrees`). `wrap` - Wrap and unroll to the (-180..+180] range (`bool`). Returns: 2-Tuple (`lon2-lon1`, `lon2`) unrolled (`degrees`, `degrees`). See Also: Capability `LONG_UNROLL` in GeographicLib.

### unrollPI(rad1, rad2, wrap=True) |
Unroll longitudinal delta and wrap longitude in radians. Parameters: `rad1` - Start longitude (`radians`). `rad2` - End longitude (`radians`). `wrap` - Wrap and unroll to the (-PI..+PI] range (`bool`). Returns: 2-Tuple (`rad2 - rad1`, `rad2`) unrolled (`radians`, `radians`). See Also: Capability `LONG_UNROLL` in GeographicLib.

### wrap90(deg) |
Wrap degrees to [-270..+90]. Parameters: `deg` - Angle (`degrees`). Returns: Degrees, wrapped (`degrees90`).

### wrap180(deg) |
Wrap degrees to [-180..+180]. Parameters: `deg` - Angle (`degrees`). Returns: Degrees, wrapped (`degrees180`).

### wrap360(deg) |
Wrap degrees to [0..+360). Parameters: `deg` - Angle (`degrees`). Returns: Degrees, wrapped (`degrees360`).

### wrapPI(rad) |
Wrap radians to [-PI..+PI]. Parameters: `rad` - Angle (`radians`). Returns: Radians, wrapped (`radiansPI`).

### wrapPI2(rad) |
Wrap radians to [0..+2PI). Parameters: `rad` - Angle (`radians`). Returns: Radians, wrapped (`radiansPI2`).

### wrapPI_2(rad) |
Wrap radians to [-3PI/2..+PI/2]. Parameters: `rad` - Angle (`radians`). Returns: Radians, wrapped (`radiansPI_2`).