geocat.comp.grid2triple¶
-
geocat.comp.
grid2triple
(x, y, z, msg=None, meta=False)¶ - Converts a two-dimensional grid with one-dimensional coordinate variables
to an array where each grid value is associated with its coordinates.
- Parameters
x (
numpy.ndarray
) – Coordinates associated with the right dimension of the variable z. It must be the same dimension size (call it mx) as the right dimension of z.y (
numpy.ndarray
) – Coordinates associated with the left dimension of the variable z. It must be the same dimension size (call it ny) as the left dimension of z.z (
numpy.ndarray
) – Two-dimensional array of size ny x mx containing the data values. Missing values may be present in z, but they are ignored.msg (
numpy.number
) – A numpy scalar value that represent a missing value in z. This argument allows a user to use a missing value scheme other than NaN or masked arrays, similar to what NCL allows.meta (
bool
) –set to True and the input array is an Xarray, the metadata (If) –
the input array will be copied to the output array; (from) –
is False. (default) –
Warning – this option is not currently supported.
- Returns
If any argument is “double” the return type will be “double”; otherwise a “float” is returned.
- Return type
- Description:
The maximum size of the returned array will be 3 x ld where ld <= ny*mx. If no missing values are encountered in z, then ld=ny*mx. If missing values are encountered in z, they are not returned and hence ld will be equal to ny*mx minus the number of missing values found in z. The return array will be double if any of the input arrays are double, and float otherwise.
Examples
Example 1: Using grid2triple with
xarray.DataArray
inputimport numpy as np import xarray as xr import geocat.comp # Open a netCDF data file using xarray default engine and load the data stream ds = xr.open_dataset("./NETCDF_FILE.nc") # [INPUT] Grid & data info on the source curvilinear z=ds.DIST_236_CBL[:] x=ds.gridlat_236[:] y=ds.gridlon_236[:] output = geocat.comp.grid2triple(x, y, z)