#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
from s2d2.unit_conversion import deg2arg
[docs]
def zenit_angle_check(θ):
""" check if the solar zenit angle is within range
Parameters
----------
θ : np.ndarray, dtype=float, unit=degrees, range=-90...+90
solar zenith angle
Notes
-----
The angles related to the sun are as follows:
.. code-block:: text
* * sun
^ / ^ /|
| / | / | nadir
|-- zenith angle | / v
| / | /|
|/ |/ | elevation angle
└----- surface └------
"""
θ = np.maximum(θ, 0.)
θ = np.minimum(θ, 90.)
return θ
[docs]
def lat_lon_angle_check(ϕ,λ):
"""
Parameters
----------
ϕ : np.ndarray, dtype=float, unit=degrees, range=-90...+90
latitude
λ : float, unit=degrees, unit=degrees, range=-180...+180
longitude
Returns
-------
ϕ,λ : float
latitude and longitude
See Also
--------
.deg2arg : transform angle to range of -180...+180
"""
ϕ = np.maximum(ϕ, -90.)
ϕ = np.minimum(ϕ, +90.)
λ = deg2arg(λ)
return ϕ, λ
[docs]
def is_crs_an_srs(crs):
""" is the coordinate reference system given in degrees, or a spatial
reference system (with a metric scale).
Parameters
----------
crs : string
osr.SpatialReference in well known text
Returns
-------
verdict : bool
is the reference system a mapping system
See Also
--------
s2d2.image_coordinate_tools.create_local_crs
"""
if not isinstance(crs, str): crs = crs.ExportToWkt()
return crs.find('"metre"')!=-1