xarray extension¶
-
class
pangaea.
LSMGridReader
(xarray_obj)[source]¶ This is an extension for xarray specifically designed for land surface models.
Read with pangaea example:
import pangaea as pa with pa.open_mfdataset('/path/to/ncfiles/*.nc', lat_var='lat', lon_var='lon', time_var='time', lat_dim='lat', lon_dim='lon', time_dim='time') as xds: print(xds.lsm.projection)
Read with xarray example:
import xarray as xr with pa.open_dataset('/path/to/file.nc') as xds: print(xds.lsm.projection)
-
affine
¶ The affine for the transformation.
Type: Affine()
-
center
¶ Return the geographic center point of this dataset.
-
coords
¶ Returns y, x coordinate arrays
Warning
The grids always be returned with [0,0] as Northeast and [-1,-1] as Southwest.
-
datetime
¶ Get datetime object for time variable
-
getvar
(variable, yslice=slice(None, None, None), xslice=slice(None, None, None), calc_4d_method=None, calc_4d_dim=None)[source]¶ Get variable from model with subset options.
Warning
The grids will always be returned with [0,0] as Northeast and [-1,-1] as Southwest.
Parameters: - variable (
str
) – Name of variable in dataset. - yslice (
slice
, optional) – Slice in y-direction of grid to extract data from. - xslice (
slice
, optional) – Slice in x-direction of grid to extract data from. - calc_4d_method (
str
) – Method to convert 4D variables to 3D variables (Ex. ‘mean’, ‘min’, or ‘max’). - calc_4d_dim (
str
) – Dimension to reduce grid from 4D to 3D (Ex. ‘top_bottom’).
Returns: Return type: xarray.DataArray()
- variable (
-
latlon
¶ Returns lat,lon arrays
Warning
The grids always be returned with [0,0] as Northeast and [-1,-1] as Southwest.
-
projection
¶ osgeo.osr.SpatialReference()
The projection for the dataset.
-
resample
(variable, match_grid)[source]¶ Resample data to grid.
Parameters: - variable (
str
) – Name of variable in dataset. - match_grid (
gdal.Dataset()
orsloot.grid.GDALGrid()
) – Grid you want the data resampled to match resolution. You can also pass the path to the grid.
- variable (
-
to_projection
(variable, projection)[source]¶ Convert Grid to New Projection.
Parameters: - variable (
str
) – Name of variable in dataset. - projection (
osr.SpatialReference()
) – Projection to convert data to.
Returns: Return type: xarray.Dataset()
- variable (
-
to_tif
(variable, time_index, out_path)[source]¶ Dump a variable at a time index to a geotiff.
Parameters:
-
to_utm
(variable)[source]¶ Convert Grid to UTM projection at center of grid.
Parameters: variable ( str
) – Name of variable in dataset.Returns: Return type: xarray.Dataset()
-
y_inverted
¶ Is the y-coord inverted
-