satpy.cf.coords module

Set CF-compliant spatial and temporal coordinates.

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

Add declared coordinates to the dataarray if they exist.

satpy.cf.coords._add_xy_geographic_coords_attrs(data_arr: DataArray, x: str = 'x', y: str = 'y') DataArray[source]

Add relevant attributes to x, y coordinates of a geographic CRS.

satpy.cf.coords._add_xy_projected_coords_attrs(data_arr: DataArray, x: str = 'x', y: str = 'y') DataArray[source]

Add relevant attributes to x, y coordinates of a projected CRS.

satpy.cf.coords._get_coordinates_list(data_arr: DataArray) list[str][source]

Return a list with the coordinates names specified in the ‘coordinates’ attribute.

satpy.cf.coords._get_is_nondimensional_coords_dict(data_arrays: dict[str, DataArray]) dict[str, bool][source]
satpy.cf.coords._is_area(data_arr: DataArray) bool[source]
satpy.cf.coords._is_lon_or_lat_dataarray(data_arr: DataArray) bool[source]

Check if the DataArray represents the latitude or longitude coordinate.

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

Guess whether data are projected or not.

satpy.cf.coords._is_swath(data_arr: DataArray) bool[source]
satpy.cf.coords._rename_coords(data_arrays: dict[str, DataArray], coord_name: str) dict[str, DataArray][source]

Rename coordinates in the datasets.

satpy.cf.coords._try_add_coordinate(data_arrays: dict[str, DataArray], dataarray_name: str, coord: str) dict[str, DataArray][source]

Try to add a coordinate to the dataarray, warn if not possible.

satpy.cf.coords._try_get_units_from_coords(data_arr: DataArray) str | None[source]

Try to retrieve coordinate x/y units.

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

Try to get a CRS from attributes.

satpy.cf.coords._warn_if_pretty_but_not_unique(pretty, coord_name)[source]

Warn if coordinates cannot be pretty-formatted due to non-uniqueness.

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