stems.io.xarray_ module

xarray IO standards and helpers

stems.io.xarray_.open_dataset(paths, chunks='auto', concat_dim=None, crs=None, **kwds)[source]

Open an xarray dataset (somewhat) intelligently

Parameters
  • paths (str or List[str]) – Either a string glob in the form “path/to/my/files/*.nc” or an explicit list of files to open.

  • chunks ('auto', int or dict) – Number of chunks or the chunk size for each dimension. If ‘auto’, reads chunks from first file in paths and uses plants.io.chunking_.best_chunksizes() to guess an appropriate chunksize based on the most frequently used chunksize per dimension. Otherwise, pass chunks onto xr.open_mfdataset().

  • concat_dim (None, str, DataArray or Index, optional) – Dimension to concatenate files along. This argument is passed on to xarray.auto_combine() along with the dataset objects. You only need to provide this argument if the dimension along which you want to concatenate is not a dimension in the original datasets, e.g., if you want to stack a collection of 2D arrays along a third dimension. By default, xarray attempts to infer this argument by examining component files. Set concat_dim=None explicitly to disable concatenation.

  • crs (rasterio.crs.CRS, int, or str, optional) – Coordinate reference system to assign, if not already georeferenced. If type is not CRS, will be converted using plants.gis.convert.to_crs().

  • kwds (optional) – Options passed to xarray.open_mfdataset()

Returns

Multi-file dataset

Return type

xarray.Dataset

Raises

IOError – Raise if paths does not parse into any filenames (e.g., a bad glob)

stems.io.xarray_.xarray_map(y, x, count, dtype, crs=None, nodata=-9999, dim_band='band')[source]

A raster map with count bands :param y: Y coordinates :type y: array-like :param x: X coordinates :type x: array-like :param count: Number of bands :type count: int :param dtype: Data type :type dtype: np.dtype :param crs: Optionally, give the raster a CRS :type crs: CRS, optional :param nodata: No Data Value to initialize data with :type nodata: float or int

Returns

3D (band, y, x,) “map” to write data into

Return type

xr.DataArray