satpy._scene_converters module

Helper functions for converting the Scene object to some other object.

satpy._scene_converters._get_dataarrays_from_identifiers(scn, identifiers)[source]

Return a list of DataArray based on a single or list of identifiers.

An identifier can be a DataID or a string with name of a valid DataID.

satpy._scene_converters.to_xarray(scn, datasets=None, header_attrs=None, exclude_attrs=None, flatten_attrs=False, pretty=True, include_lonlats=True, epoch=None, include_orig_name=True, numeric_name_prefix='CHANNEL_')[source]

Merge all xr.DataArray(s) of a satpy.Scene to a CF-compliant xarray object.

If all Scene DataArrays are on the same area, it returns an xr.Dataset. If Scene DataArrays are on different areas, currently it fails, although in future we might return a DataTree object, grouped by area.

Parameters:
  • scn (satpy.Scene) – Satpy Scene.

  • (iterable) (datasets) – List of Satpy Scene datasets to include in the output xr.Dataset. Elements can be string name, a wavelength as a number, a DataID, or DataQuery object. If None (the default), it include all loaded Scene datasets.

  • header_attrs – Global attributes of the output xr.Dataset.

  • (str) (numeric_name_prefix) – Reference time for encoding the time coordinates (if available). Example format: “seconds since 1970-01-01 00:00:00”. If None, the default reference time is retrieved using “from satpy.cf_writer import EPOCH”

  • (bool) (pretty) – If True, flatten dict-type attributes.

  • (list) (exclude_attrs) – List of xr.DataArray attribute names to be excluded.

  • (bool) – If True, it includes ‘latitude’ and ‘longitude’ coordinates. If the ‘area’ attribute is a SwathDefinition, it always includes latitude and longitude coordinates.

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

  • (bool). (include_orig_name) – Include the original dataset name as a variable attribute in the xr.Dataset.

  • (str) – Prefix to add the each variable with name starting with a digit. Use ‘’ or None to leave this out.

Returns:

A CF-compliant xr.Dataset

Return type:

ds, xr.Dataset