geocat.comp.rgrid2rcm
geocat.comp.rgrid2rcm#
- geocat.comp.rgrid2rcm(lat1d, lon1d, fi, lat2d, lon2d, msg=None, meta=False)#
Interpolates data on a rectilinear lat/lon grid to a curvilinear grid like those used by the RCM, WRF and NARR models/datasets.
- Parameters
lat1d (
xarray.DataArray
,numpy.ndarray
:) – A one-dimensional array that specifies the latitude coordinates of the regular grid. Must be monotonically increasing.Note: It should only be explicitly provided when the input (fi) is numpy.ndarray; otherwise, it should come from fi.coords.
lon1d (
xarray.DataArray
,numpy.ndarray
:) – A one-dimensional array that specifies the longitude coordinates of the regular grid. Must be monotonically increasing.Note: It should only be explicitly provided when the input (fi) is numpy.ndarray; otherwise, it should come from fi.coords.
fi (
xarray.DataArray
,numpy.ndarray
:) – A multi-dimensional array to be interpolated. The rightmost two dimensions (latitude, longitude) are the dimensions to be interpolated.lat2d (
xarray.DataArray
,numpy.ndarray
:) – A two-dimensional array that specifies the latitude locations of the input (fi). Because this array is two-dimensional it is not an associated coordinate variable of fi.lon2d (
xarray.DataArray
,numpy.ndarray
:) – A two-dimensional array that specifies the longitude locations of the input (fi). Because this array is two-dimensional it is not an associated coordinate variable of fi.msg :obj:`numpy.number` – A numpy scalar value that represents a missing value in fi. This argument allows a user to use a missing value scheme other than NaN or masked arrays, similar to what NCL allows.
meta :obj:`bool` – If set to True and the input array is an Xarray, the metadata from the input array will be copied to the output array; default is False. Warning: this option is not currently supported.
- Returns
fo (
xarray.DataArray
,numpy.ndarray
:) – The interpolated grid. A multi-dimensional array of the same size as fi except that the rightmost dimension sizes have been replaced by the sizes of lat2d (or lon2d).Description
-----------
– Interpolates data on a rectilinear lat/lon grid to a curvilinear grid, such as thoseused by the RCM (Regional Climate Model)
,WRF (Weather Research
andForecasting) and
NARR (North American Regional Reanalysis) models/datasets. No extrapolation is
performed beyond the range
ofthe input coordinates. The method used is simple inverse
distance weighting. Missing values are allowed but ignored.
Examples
Example 1: Using rgrid2rcm 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 # input grid and data ds_rect = xr.open_dataset("./DATAFILE_RECT.nc") # [INPUT] Grid & data info on the source rectilinear ht_rect =ds_rect.SOME_FIELD[:] lat1D_rect=ds_rect.gridlat_[:] lon1D_rect=ds_rect.gridlon_[:] # Open a netCDF data file using xarray default engine and load the data stream # for output grid ds_curv = xr.open_dataset("./DATAFILE_CURV.nc") # [OUTPUT] Grid on destination curvilinear grid (or read the 2D lat and lon from # an other .nc file newlat2D_rect=ds_curv.gridlat2D_[:] newlon2D_rect=ds_curv.gridlat2D_[:] ht_curv = geocat.comp.rgrid2rcm(lat1D_rect, lon1D_rect, ht_rect, newlat2D_curv, newlon2D_curv)