- Notifications
You must be signed in to change notification settings - Fork17
Python library for optimized interpolation.
License
CNES/pangeo-pyinterp
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Python library for optimized geo-referenced interpolation.
The motivation of this project is to provide tools for interpolatinggeo-referenced data used in the field of geosciences. Other libraries cover thisproblem, but written entirely in Python, the performance of these projects wasnot quite sufficient for our needs. That is why this project started.
With this library, you can interpolate2D,3D,or4Dfields usingn-variate
andbicubic
interpolatorsandunstructured grids.You can also apply for a databinning on thebivariate area by simple or linear binning.
The library core is written in C++ using theBoost C++ Libraries,Eigen3 andpybind11 libraries.
This software also usesCMake to configure the projectandGoogletest to perform unit testingof the library kernel.
The undefined values in the grids do not allow interpolation of values locatedin the neighborhood. This behavior is a concern when you need to interpolatevalues near the mask of some fields. The library provides utilities to fill theundefined values:
- loessto fill the undefined values on the boundary between the defined/undefinedvalues using local regression.
- gauss_seidelto fill all undefined values in a grid using the Gauss-Seidel method byrelaxation.
N-dimensional grid is a grid defined by a matrix, in a 2D space, by a cube in a3D space, etc. Each dimension of the grid is associated with a vectorcorresponding to its coordinates or axes. Axes used to locate a pixel in thegrid from the coordinates of a point. These axes are either:
- regular: a vector of 181 latitudes spaced a degree from -90 to 90 degrees;
- irregular: a vector of 109 latitudes irregularly spaced from -90 to89.940374 degrees.
These objects are manipulated by the classpyinterp.Axis,which will choose, according to Axis definition, the best implementation. Thisobject will allow you to find the two indexes framing a given value. Thisoperating mode allows better performance when searching for a regular axis (asimple calculation will enable you to see the index of a point immediately). Incontrast, in the case of an irregular axis, the search will be performed using abinary search.
Finally, this class can define a circular axis from a vector to correctlylocate a value on the circle. This type of Axis will is used for handlinglongitudes.
Thepyinterp.TemporalAxisclass handles temporal axes, i.e., axes defined by 64-bit integer vectors, whichis the encoding used bynumpy to controldates. This class allows you to process dates using integer arithmetic to ensurethat no information is lost during calculations. These objects are used byspatiotemporal grids to perform temporal interpolations.
In the case of unstructured grids, the index used is aR*Tree. These treeshave better performance than theKDTree generally found in Python libraryimplementations.
The tree used here is the implementation provided by theC++ Boost library.
An adaptation has been introduced to address spherical equatorial coordinateseffectively. Although the Boost library allows these coordinates to manipulatenatively, the performance is lower than in the case of Cartesian space. Thus, wehave chosen to implement a conversion of Longitude Latitude Altitude (LLA)coordinates into Earth-Centered, Earth-Fixed (ECEF) coordinates transparentlyfor the user to ensure that we can preserve excellent performance. Thedisadvantage of this implementation is that it requires fairly more memory, asone more element gets used to index the value of the Cartesian space.
The management of theLLA/ECEFcoordinate conversion is managed to use theOlson, D.K. algorithm. It has an excellentperformance with the accuracy of 1e-8 meters for altitude.
Geohashing is a geocoding method used to encode geographic coordinates(latitude and longitude) into a short string of digits and letters delineatingan area on a map, which is called a cell, with varying resolutions. The morecharacters in the string, the more precise the location.
Geohashes use Base-32 alphabet encoding (characters can be0
to9
andA
toZ
, exclA
,I
,L
andO
).
The geohash is a compact way of representing a location, and is useful forstoring a location in a database, or for indexing a location in a database.
About
Python library for optimized interpolation.