satpy.cf.coords module

Set CF-compliant spatial and temporal coordinates.

satpy.cf.coords.add_coordinates_attrs_coords(data_arrays: dict[str, DataArray]) dict[str, DataArray][source]

Add to DataArrays the coordinates specified in the ‘coordinates’ attribute.

It deal with the ‘coordinates’ attributes indicating lat/lon coords The ‘coordinates’ attribute is dropped from each DataArray

If the coordinates attribute of a data array links to other dataarrays in the scene, for example coordinates=’lon lat’, add them as coordinates to the data array and drop that attribute.

In the final call to xr.Dataset.to_netcdf() all coordinate relations will be resolved and the coordinates attributes be set automatically.

satpy.cf.coords.add_time_bounds_dimension(ds: Dataset, time: str = 'time') Dataset[source]

Add time bound dimension to xr.Dataset.

satpy.cf.coords.add_xy_coords_attrs(data_arr: DataArray) DataArray[source]

Add relevant attributes to x, y coordinates.

satpy.cf.coords.check_unique_projection_coords(data_arrays: dict[str, DataArray]) None[source]

Check that all datasets share the same projection coordinates x/y.

satpy.cf.coords.ensure_unique_nondimensional_coords(data_arrays: dict[str, DataArray], pretty: bool = False) dict[str, DataArray][source]

Make non-dimensional coordinates unique among all datasets.

Non-dimensional coordinates, such as scanline timestamps, may occur in multiple datasets with the same name and dimension but different values.

In order to avoid conflicts, prepend the dataset name to the coordinate name. If a non-dimensional coordinate is unique among all datasets and pretty=True, its name will not be modified.

Since all datasets must have the same projection coordinates, this is not applied to latitude and longitude.

Parameters:
  • data_arrays – Dictionary of (dataset name, dataset)

  • pretty – Don’t modify coordinate names, if possible. Makes the file prettier, but possibly less consistent.

Returns:

Dictionary holding the updated datasets

satpy.cf.coords.has_projection_coords(data_arrays: dict[str, DataArray]) bool[source]

Check if DataArray collection has a “longitude” or “latitude” DataArray.

satpy.cf.coords.set_cf_time_info(data_arr: DataArray, epoch: str | None) DataArray[source]

Set CF time attributes and encoding.

It expand the DataArray with a time dimension if does not yet exists.

The function assumes

  • that x and y dimensions have at least shape > 1

  • the time coordinate has size 1