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_geoviews(scn, gvtype=None, datasets=None, kdims=None, vdims=None, dynamic=False)[source]

Convert satpy Scene to geoviews.

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

  • gvtype (gv plot type) – One of gv.Image, gv.LineContours, gv.FilledContours, gv.Points Default to geoviews.Image. See Geoviews documentation for details.

  • datasets (list) – Limit included products to these datasets

  • kdims (list of str) – Key dimensions. See geoviews documentation for more information.

  • vdims (list of str, optional) – Value dimensions. See geoviews documentation for more information. If not given defaults to first data variable

  • dynamic (bool, optional) – Load and compute data on-the-fly during visualization. Default is False. See https://holoviews.org/user_guide/Gridded_Datasets.html#working-with-xarray-data-types for more information. Has no effect when data to be visualized only has 2 dimensions (y/x or longitude/latitude) and doesn’t require grouping via the Holoviews groupby function.

Returns: geoviews object

satpy._scene_converters.to_hvplot(scn, datasets=None, *args, **kwargs)[source]

Convert satpy Scene to Hvplot. The method could not be used with composites of swath data.

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

  • datasets (list) – Limit included products to these datasets.

  • args – Arguments coming from hvplot

  • kwargs – hvplot options dictionary.

Returns:

hvplot object that contains within it the plots of datasets list. As default it contains all Scene datasets plots and a plot title is shown.

Example usage:

scene_list = ['ash','IR_108']
scn = Scene()
scn.load(scene_list)
scn = scn.resample('eurol')
plot = scn.to_hvplot(datasets=scene_list)
plot.ash+plot.IR_108
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.

  • datasets (iterable, optional) – 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 includes all loaded Scene datasets.

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

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

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

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

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

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

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

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

Returns:

A CF-compliant xr.Dataset

Return type:

xr.Dataset