fcollections.geometry#
Functions
|
Determine angle of satellite track with respect the meridian passing the track. |
|
Compute the distances point to point along a given axis. |
Guess the convention used in an array of longitudes, either (-180/180) or (0/360) |
|
|
Expand a geohash box with a given precision. |
|
Polygon simplification with visvalingam algorithm. |
|
Query the geometries of the given half orbits. |
|
Query half orbits that intersect the bbox. |
|
Given a vector v rotate its derivatives from the (I, J) from to the (i, j) frame. |
|
Project a vector from (I, J) to (i, j) coordinates. |
Classes
|
Longitude convention. |
|
|
|
- class fcollections.geometry.LongitudeConvention(lon_min: float, lon_max: float)[source]#
Bases:
objectLongitude convention.
- normalize(lon: array, inplace: bool = False) array[source]#
Normalize a longitude array and keep it even if it’s not monotonous.
- Parameters:
lon (np.array) – an array of longitudes
inplace (bool) – edit input array (True) or return a copy (False)
- Return type:
an array of longitudes converted in the current convention
- normalize_and_split(lon: array, inplace: bool = False) list[array][source]#
Normalize a longitude array and split it in two parts if its not monotonous.
- Parameters:
lon (np.array) – an array of longitudes
inplace (bool) – edit input array (True) or return a copy (False)
- Return type:
an list of array of longitudes converted in the current convention
- class fcollections.geometry.StandardLongitudeConvention(*values)[source]#
Bases:
Enum- CONV_180 = [-180,180[#
- CONV_360 = [0,360[#
- class fcollections.geometry.SwathGeometriesBuilder(longitude_variable: 'str' = 'longitude', latitude_variable: 'str' = 'latitude')[source]#
Bases:
object
- fcollections.geometry.distances_along_axis(longitudes: ndarray, latitudes: ndarray, axis: int = 0, return_full: bool = True, spherical_approximation: bool = True, **kwargs)[source]#
Compute the distances point to point along a given axis.
In case the spherical approximation is used, the great circle distance is computed, with the earth radius being deduced from the spheroid model (mean_radius).
Else, the distance will be computed using the ellipsoid model.
- Parameters:
longitudes – Longitudes in degrees
latitudes – Latitudes in degrees
axis – Axis along which the distance will be computed
return_full – True to return an array of the same shape as the input. If set to True, the distances vector is averaged with an offset of one element, then padded with edge values to have a the same number of elements as the input
spherical_approximation – Whether to use a spherical earth or an ellipsoid earth model
- Returns:
Distance between points along the given axis in meters.
- Return type:
distances_along_axis
- fcollections.geometry.expand_box(box: Box, precision: int) Box[source]#
Expand a geohash box with a given precision.
The method looks for the geohashes of the input box’s corners with a given precision. From these two geohashes, it computes the associated bounding boxes and find the bigger box that covers them both.
- Parameters:
box (pyinterp.geodetic.Box) – the box to expand
precision (int) – the precision to expand the box to
- Return type:
a pyinterp.geodetic.Box expanded to a lower precision
- fcollections.geometry.guess_longitude_convention(lon: array) StandardLongitudeConvention[source]#
Guess the convention used in an array of longitudes, either (-180/180) or (0/360)
- Parameters:
lon (np.array) – an array of longitudes
- Return type:
the detected StandardLongitudeConvention enum
- Raises:
ValueError – In case the input longitudes span over multiple intervals. ex: [-170, 0, 310] uses both [-180, 180] and [0, 360] conventions and will trigger an exception
- fcollections.geometry.query_geometries(half_orbit_numbers: int | list[int], phase: Phase | str = MissionsPhases.science.value) GeoDataFrame[source]#
Query the geometries of the given half orbits.
- Parameters:
- Raises:
KeyError – In case none of the requested half orbit numbers exist.
- Returns:
A Geopandas dataframe containing half orbits number and geometry as Polygon
- Return type:
gpd.GeoDataFrame
- fcollections.geometry.query_half_orbits_intersect(bbox: tuple[float, float, float, float], phase: Phase | str = MissionsPhases.science.value) GeoDataFrame[source]#
Query half orbits that intersect the bbox.
- Parameters:
bbox (tuple[float, float, float, float]) – the tuple (lon_min, lat_min, lon_max, lat_max) representing the bounding box for geographical selection Longitude coordinates can be provided in [-180, 180[ or [0, 360[ convention. If bbox’s longitude crosses the -180/180 of longitude, half orbits around the crossing and matching the bbox will be selected. (e.g. longitude interval: [170, -170] -> half orbits in [170, 180[ and [-180, -170] will be retrieved)
phase (str) – requested phase (‘science’, ‘calval’). Default: ‘science’
- Returns:
A Geopandas dataframe containing intersecting half orbits numbers and geometries
- Return type:
gpd.GeoDataFrame
- fcollections.geometry.rotate_derivatives(dvX_dX: float | np_t.NDArray[np.float64], dvY_dY: float | np_t.NDArray[np.float64], dvX_dY: float | np_t.NDArray[np.float64], dvY_dX: float | np_t.NDArray[np.float64], angles_I_i: float | np_t.NDArray[np.float64]) tuple[float | np_t.NDArray[np.float64], float | np_t.NDArray[np.float64], float | np_t.NDArray[np.float64], float | np_t.NDArray[np.float64]][source]#
Given a vector v rotate its derivatives from the (I, J) from to the (i, j) frame.
Let’s note R the rotation between rx=(x, y) and rX=(X, Y): rx=R.rX drx = R.drX so drX/drx = R-1
Let’s note Ji the derivatives of vi in the (i, j) frame, and JI the derivatives of vI in the (I, J) frame. We want to return Ji, but the only available input is JI, the derivation of the vector vI in the (I, J) frame. Ji = dvi/dri = d(R.vI)/dri = R.dvI/dri = R.dvI/drI.drI/dr = R.JI.R-1
Beware, the input vector vI should be expressed in the (I, J) frame, not (i, j)
- Parameters:
dvX_dX – X component of the derivative of VI along X direction
dvY_dY – Y component of the derivative of VI along Y direction
dvX_dY – X component of the derivative of VI along Y direction
dvY_dX – Y component of the derivative of VI along X direction
angles_I_i – The rotation angle of the R matrix: angle between the source frame (I, J) and the destination frame (I, J)
- Returns:
The rotated derivatives dvx_dx, dvy_dy, dvy_dx, dvx_dy
See also
rotate_vectorcan rotate a vector to express it in the proper frame
- fcollections.geometry.rotate_vector(v_I: float | np_t.NDArray[np.float64], v_J: float | np_t.NDArray[np.float64], angles_I_i: float | np_t.NDArray[np.float64]) tuple[float | np_t.NDArray[np.float64], float | np_t.NDArray[np.float64]][source]#
Project a vector from (I, J) to (i, j) coordinates.
The two frames must be direct.
- v_I
Vector component over the I direction
- v_J
Vector component over the J direction
- angles_I_i
Angles between (I, i) (radians)
- Returns:
v_i – Vector component over the i direction
v_j – Vector component over the j direction
- fcollections.geometry.track_orientation(latitude: ndarray, longitude: ndarray, along_track_axis: int = 0, half_width: int = 1, spheroid: Spheroid = Spheroid())[source]#
Determine angle of satellite track with respect the meridian passing the track.
This method relies on the approximation of the track direction using neighbour points. The better the localisation, the better precision for the angle. When latitudes and longitudes are not very robust, it is possible to increase the half-width to smoothen the speed direction.
SWOT remark: there will be a field computed by the ground segment in the L2 products (although it is computed for nadir only)
- Parameters:
latitude – Latitudes of the nadir track in degrees
longitude – Longitudes of the nadir track in degree
along_track_axis – Axis for the along track direction
half_width – Half-width of the finite difference calculation. Set higher to smooth the signal if lats and lons are not smooth.
spheroid – Earth representation (defaults to WGS84)
- Returns:
angles_zonal_along – Angle between the equator and the along track direction (in radians) Positive angles follow the anti-clockwise direction
- Return type:
np.ndarray
- fcollections.geometry.visvalingam(x, y, fixed_size=18)[source]#
Polygon simplification with visvalingam algorithm.
X, Y are considered like a polygon, the next point after the last one is the first one
- Parameters:
x (array)
y (array)
fixed_size (int) – array size of out
- Returns:
New (x, y) array, last position will be equal to first one, if array size is 6, there is only 5 point.
- Return type:
array,array