cedar.preard module

Convert “pre-ARD” to ARD

cedar.preard.ard_netcdf_encoding(ard_ds, metadata, **encoding_kwds)[source]

Return encoding for ARD NetCDF4 files

Parameters
  • ard_ds (xr.Dataset) – ARD as a XArray Dataset

  • metadata (dict) – Metadata about ARD

Returns

NetCDF encoding to use with xarray.Dataset.to_netcdf()

Return type

dict

cedar.preard.find_preard(path, metadata_pattern='*.json')[source]

Match pre-ARD metadata with imagery in some location

Parameters
  • path (str or Path) – Path to a metadata file or directory of files (returning matches inside the directory)

  • metadata_pattern (str, optional) – If path is a directory, this value is used as a glob inside path to locate metadata files

Returns

Pairs of metadata filename to image filename(s)

Return type

dict[str, list[str]]

cedar.preard.preard_to_ard(xarr, time, bands)[source]

Convert a “pre-ARD” DataArray to an ARD xr.Dataset

Parameters
  • xarr (xarray.DataArray) – DataArray containing observations from all bands and time

  • time (np.ndarray) – Time information for each observation

  • bands (Sequence[str]) – Band names

Returns

Dataset containing all observations split into subdatasets according to band

Return type

xr.Dataset

Raises

ValueError – Raised if the number of bands and times specified do not match the number of “bands” in the input DataArray

cedar.preard.process_preard(metadata, images, chunks=None)[source]

Open and process pre-ARD data to ARD

Parameters
  • metadata (dict) – Image metadata

  • images (Sequence[str or Path]) – Path(s) to pre-ARD imagery

  • chunks (dict, optional) – Chunks to use when opening pre-ARD GeoTIFF files. If None, defaults to {'x': 256, 'y': 256, 'band': -1}

Returns

pre-ARD processed to (in memory) ARD format that can be written to disk

Return type

xr.Dataset

cedar.preard.read_metadata(filename)[source]

Read pre-ARD image metadata from a file

cedar.preard.read_preard(filenames, chunks=None)[source]

Read pre-ARD file(s) into a single DataArray

Parameters
  • filenames (Sequence[str or Path]) – Pre-ARD file name(s)

  • chunks (dict, optional) – Chunks to use when opening pre-ARD GeoTIFF files. If None, defaults to {'x': 256, 'y': 256, 'band': -1}

Returns

Pre-ARD joined together as a single DataArray

Return type

xr.DataArray