satpy.readers.file_handlers module

Interface for BaseFileHandlers.

class satpy.readers.file_handlers.BaseFileHandler(filename, filename_info, filetype_info)[source]

Bases: object

Base file handler.

Initialize file handler.

static _combine(infos, func, *keys)[source]

Get information of available datasets in this file.

This is used for dynamically specifying what datasets are available from a file in addition to what’s configured in a YAML configuration file. Note that this method is called for each file handler for each file type; care should be taken when possible to reduce the amount of redundant datasets produced.

This method should not update values of the dataset information dictionary unless this file handler has a matching file type (the data could be loaded from this object in the future) and at least one satpy.dataset.DataID key is also modified. Otherwise, this file type may override the information provided by a more preferred file type (as specified in the YAML file). It is recommended that any non-ID metadata be updated during the BaseFileHandler.get_dataset() part of loading. This method is not guaranteed that it will be called before any other file type’s handler. The availability “boolean” not being None does not mean that a file handler called later can’t provide an additional dataset, but it must provide more identifying (DataID) information to do so and should yield its new dataset in addition to the previous one.


configured_datasets (list) – Series of (bool or None, dict) in the same way as is returned by this method (see below). The bool is whether the dataset is available from at least one of the current file handlers. It can also be None if no file handler before us knows how to handle it. The dictionary is existing dataset metadata. The dictionaries are typically provided from a YAML configuration file and may be modified, updated, or used as a “template” for additional available datasets. This argument could be the result of a previous file handler’s implementation of this method.


Iterator of (bool or None, dict) pairs where dict is the dataset’s metadata. If the dataset is available in the current file type then the boolean value should be True, False if we know about the dataset but it is unavailable, or None if this file object is not responsible for it.

Example 1 - Supplement existing configured information:

def available_datasets(self, configured_datasets=None):
    "Add information to configured datasets."
    # we know the actual resolution
    res = self.resolution

    # update previously configured datasets
    for is_avail, ds_info in (configured_datasets or []):
        # some other file handler knows how to load this
        # don't override what they've done
        if is_avail is not None:
            yield is_avail, ds_info

        matches = self.file_type_matches(ds_info['file_type'])
        if matches and ds_info.get('resolution') != res:
            # we are meant to handle this dataset (file type matches)
            # and the information we can provide isn't available yet
            new_info = ds_info.copy()
            new_info['resolution'] = res
            yield True, new_info
        elif is_avail is None:
            # we don't know what to do with this
            # see if another future file handler does
            yield is_avail, ds_info

Example 2 - Add dynamic datasets from the file:

def available_datasets(self, configured_datasets=None):
    "Add information to configured datasets."
    # pass along existing datasets
    for is_avail, ds_info in (configured_datasets or []):
        yield is_avail, ds_info

    # get dynamic variables known to this file (that we created)
    for var_name, val in self.dynamic_variables.items():
        ds_info = {
            'file_type': self.filetype_info['file_type'],
            'resolution': 1000,
            'name': var_name,
        yield True, ds_info

Combine metadata for multiple datasets.

When loading data from multiple files it can be non-trivial to combine things like start_time, end_time, start_orbit, end_orbit, etc.

By default this method will produce a dictionary containing all values that were equal across all provided info dictionaries.

Additionally it performs the logical comparisons to produce the following if they exist:

  • start_time

  • end_time

  • start_orbit

  • end_orbit

  • orbital_parameters

  • time_parameters

Also, concatenate the areas.

property end_time

Get end time.


Match file handler’s type to this dataset’s file type.


ds_ftype (str or list) – File type or list of file types that a dataset is configured to be loaded from.


True if this file handler object’s type matches the dataset’s file type(s), None otherwise. None is returned instead of False to follow the convention of the available_datasets() method.


Get area definition.


Get the bounding box of the files, as a (lons, lats) tuple.

The tuple return should a lons and lats list of coordinates traveling clockwise around the points available in the file.

get_dataset(dataset_id, ds_info)[source]

Get dataset.

property sensor_names

List of sensors represented in this file.

property start_time

Get start time.

satpy.readers.file_handlers.open_dataset(filename, *args, **kwargs)[source]

Open a file with xarray.


filename (Union[str, FSFile]) – The path to the file to open. Can be a string or FSFile object which allows using fsspec or s3fs like files.

Return type:



This can be used to enable readers to open remote files.