pysiral.core.datahandler

Created on Fri May 19 18:16:09 2017

@author: Stefan

Classes

DefaultAuxdataClassHandler

Class for retrieving handler classes for auxiliary data

L1PDataHandler

Class for querying L1P data files

L2iDataHandler

Class for discovering l2i files

Module Contents

class pysiral.core.datahandler.DefaultAuxdataClassHandler

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

Class for retrieving handler classes for auxiliary data (mss, sic, sitype, snow). The classes are initialized with directory information from the local machine definition and the auxdata information from auxdata.yaml configuration file.

error
get_pyclass(auxdata_class, auxdata_id, l2_procdef_opt)

Returns a class for handling auxiliary data files, that is initialized with auxdata settings in config/auxdata_def.yaml and with the directory specified in local_machine_def.yaml

Args:

auxdata_class (str): Auxdata class (e.g. mss, sic, sitype, snow) auxdata_id (str): Auxdata class identifier (e.g. osisaf)

Returns:

class: The initialized auxdata handler class

get_local_repository(auxdata_class, auxdata_id)

Get the local repository for the the auxdata type and id

get_auxdata_def(auxdata_class: str, auxdata_id: str) pysiral.core.legacy_classes.AttrDict

Returns the definition in config/auxdata_def.yaml for specified auxdata class and id. Raises an error if the entry is not found. :param auxdata_class: The code for auxiliary data type (sic, mss, sitype, snow, …) :param auxdata_id: The id of a specific data set for the auxiliary data class (e.g. sic:osisaf-operational) :return: The configuration dictionary

class pysiral.core.datahandler.L1PDataHandler(platform: str, hemisphere: str, source_version: str = None, file_version: str = None)

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

Class for querying L1P data files

_platform
_hemisphere
_source_version = None
_file_version = None
_last_directory = None
get_files_from_time_range(time_range: dateperiods.DatePeriod) List[str]

Query l1p files for a a given time range. :param time_range: a dateperiods.DatePeriod instance :return:

_autodetect_file_version() str | None

Autodetect l1p file version from the directory structure :return:

static l1p_in_trange(fn: str, tr: dateperiods.DatePeriod) bool

Returns flag if filename is within time range

Parameters:
  • fn

  • tr

Returns:

property l1p_base_dir: str

Returns the the l1p base base # TODO: Evaluate use of function (properties shouldn’t raise errors?) :return:

property last_directory: str
class pysiral.core.datahandler.L2iDataHandler(base_directories: List[str] | List[pathlib.Path] | str | pathlib.Path, search_str: str = ('l2i', 'l2'))

Bases: object

Class for discovering l2i files

_search_str = ('l2i', 'l2')
_base_directories
_subdirectory_list
get_files_from_time_range(time_range: dateperiods.DatePeriod) List[pathlib.Path]

Get all files that fall into time range (Maybe spread over the different year/ month subfolders

# TODO: Use get_files_for_day() ?

Parameters:

time_range

Returns:

get_files_for_day(day_dt: datetime.datetime) List[pathlib.Path]

Retrieve a list of l2i files with data points for a given day. Also, specifically looks for files with had a start time on the previous day

Parameters:

day_dt

Returns:

static _validate_base_directories(base_directories: List[str] | List[pathlib.Path] | str | pathlib.Path) List[pathlib.Path]

Performs sanity checks and enforces the l2i subfolder type is pathlib.Path

Parameters:

base_directories – List of l2i lookup directory as str

Raises:

IOError – One of the directories is not valid

:return:List of l2i lookup directory as str

get_lookup_directory(year: int, month: int) List[pathlib.Path]

Rturn the list of l2i lookup folder for a given year and month (no daily granularity)

Parameters:
  • year

  • month

Returns:

static get_subdirectory_list(base_dir: pathlib.Path) List[List[str]]

Returns a list of all subdirectories of type yyyy/mm

Returns:

static get_l2i_search_str(year: int = None, month: int = None, day: int = None) str

Returns a search pattern for l2i files with optional refined search for year, month, day. NOTE: month & day can only be set, if the year & year + month respectively is set

Examples:

l2i.nc l2i*2017.nc l2i*201704.nc l2i*20170401.nc

Parameters:
  • year

  • month

  • day

Returns:

property product_basedirs
property subdirectory_list
property start_month

Returns a date time object for the first month of the l2i product repository

property stop_month

Returns a date time object for the last month of the l2i product repository