processing_functions

log_example_ds(example_ds)

Writes some metadata about a example_ds to the logger.

Parameters

example_ds (xr.Dataset) – Dataset for which to log information.

adjust_timelim_dtype(timelim)

Convert different time formats to datetime.datetime.

Parameters

timelim (list) – List defining a period.

Returns

List defining a period using datetime.datetime objects.

Return type

list

remove_ds(ds)

Delete a dataset-file from disk, assuring it’s closed properly before doing so.

Parameters

ds (xr.Dataset | str) – Either a xr.Dataset (in which case its source as defined in the encoding attribute will be used) or a str in which case it must be a path to a file.

process_ds(ds, coords, variables, crs=None)

Apply some rioxarray related transformations to a dataset.

Parameters
  • ds (xr.Dataset) – Dataset to be processed.

  • coords (dict) – Dictionary describing the names of the spatial coordinates.

  • variables (list) – List of variables to keep.

  • crs (rasterio.CRS.crs, optional) – Coordinate reference system to assign (no reprojection is done), by default None.

Returns

Dataset with some attributes corrected.

Return type

xr.Dataset

make_example_ds(ds, folder, target_crs, bb=None, example_ds_fp=None)

Make an dataset suitable to use as an example for matching with other datasets.

Parameters
  • ds (xr.Dataset) – Input dataset.

  • folder (str) – Path to folder in which to save the example_ds.

  • target_crs (rasterio.CRS.crs) – Coordinate reference system of the example_ds.

  • bb (list, optional) – Boundingbox of the example_ds ([xmin, ymin, xmax, ymax]), by default None.

Returns

Example dataset.

Return type

xr.Dataset

open_ds(fp, decode_coords='all', chunks='auto', **kwargs)

Open a file using xarray.

Parameters
  • fp (str) – Path to file.

  • decode_coords (str, optional) – Whether or not to decode coordinates, by default “all”.

  • chunks (str | dict, optional) – Chunks to use, by default “auto”.

Returns

Opened file.

Return type

xr.Dataset

transform_bb(src_crs, dst_crs, bb)

Transforms coordinates from one CRS to another.

Parameters
  • src_crs (rasterio.CRS.crs) – Source CRS.

  • dst_crs (rasterio.CRS.crs) – Target CRS.

  • bb (list) – Coordinates to be transformed.

Returns

Transformed coordinates.

Return type

list