Discrete provider

pansat.download.providers.discrete_provider

This module providers the DiscreteProvider class, which is a base class for providers where available cannot be determined a priori but need to be looked up on a per-day basis.

class pansat.download.providers.discrete_provider.DiscreteProvider(product)

The DiscreteProvider class acts as a template class for discrete data providers, which lookup files on a per-day basis. It only requires a get_files_by_day and the download_file function to be implemented and the extends the functionality to match the general DataProvider interface.

__init__(product)
download(start_time, end_time, destination=None)

This method downloads data for a given time range from respective the data provider.

Parameters:
  • start (datetime.datetime) – date and time for start

  • end (datetime.datetime) – date and time for end

  • destination (str or pathlib.Path) – path to directory where the downloaded files should be stored.

abstract download_file(filename, destination)

Download file from data provider.

Parameters:
  • filename (str) – The name of the file to download.

  • destination (str or pathlib.Path) – path to directory where the downloaded files should be stored.

get_file_by_date(time)

Get file with start time closest to a given date.

Parameters:

time (datetime.datetime) – The date to download a file for.

Returns:

The filename of the file with the closest start time before the given time.

abstract get_files_by_day(year, day)

Return list of available files for a given day of a year.

Parameters:
  • year (int) – The year for which to look up the files.

  • day (int) – The Julian day for which to look up the files.

Returns:

A list of strings containing the filename that are available for the given day.

get_files_in_range(start_time, end_time, start_inclusive=True)

Get all files within time range.

Retrieves a list of product files that include the specified time range.

Parameters:
  • start_time (datetime.datetime) – Start time of the time range

  • end_time (datetime.datetime) – End time of the time range

  • start_inclusive (bool) – Whether or not the list should start with the first file containing start_time (True) or the first file found with start time later than start_time (False).

Returns:

List of filename that include the specified time range.