pysiral.core.datahandler ======================== .. py:module:: pysiral.core.datahandler .. autoapi-nested-parse:: Created on Fri May 19 18:16:09 2017 @author: Stefan Classes ------- .. autoapisummary:: pysiral.core.datahandler.DefaultAuxdataClassHandler pysiral.core.datahandler.L1PDataHandler pysiral.core.datahandler.L2iDataHandler Module Contents --------------- .. py:class:: DefaultAuxdataClassHandler Bases: :py:obj:`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. .. py:attribute:: error .. py:method:: 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 .. py:method:: get_local_repository(auxdata_class, auxdata_id) Get the local repository for the the auxdata type and id .. py:method:: 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 .. py:class:: L1PDataHandler(platform: str, hemisphere: str, source_version: str = None, file_version: str = None) Bases: :py:obj:`pysiral.core.legacy_classes.DefaultLoggingClass` Class for querying L1P data files .. py:attribute:: _platform .. py:attribute:: _hemisphere .. py:attribute:: _source_version :value: None .. py:attribute:: _file_version :value: None .. py:attribute:: _last_directory :value: None .. py:method:: 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: .. py:method:: _autodetect_file_version() -> Union[str, None] Autodetect l1p file version from the directory structure :return: .. py:method:: l1p_in_trange(fn: str, tr: dateperiods.DatePeriod) -> bool :staticmethod: Returns flag if filename is within time range :param fn: :param tr: :return: .. py:property:: l1p_base_dir :type: str Returns the the l1p base base # TODO: Evaluate use of function (properties shouldn't raise errors?) :return: .. py:property:: last_directory :type: str .. py:class:: L2iDataHandler(base_directories: Union[List[str], List[pathlib.Path], str, pathlib.Path], search_str: str = ('l2i', 'l2')) Bases: :py:obj:`object` Class for discovering l2i files .. py:attribute:: _search_str :value: ('l2i', 'l2') .. py:attribute:: _base_directories .. py:attribute:: _subdirectory_list .. py:method:: 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() ? :param time_range: :return: .. py:method:: 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 :param day_dt: :return: .. py:method:: _validate_base_directories(base_directories: Union[List[str], List[pathlib.Path], str, pathlib.Path]) -> List[pathlib.Path] :staticmethod: Performs sanity checks and enforces the l2i subfolder type is pathlib.Path :param 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 .. py:method:: 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) :param year: :param month: :return: .. py:method:: get_subdirectory_list(base_dir: pathlib.Path) -> List[List[str]] :staticmethod: Returns a list of all subdirectories of type yyyy/mm :return: .. py:method:: get_l2i_search_str(year: int = None, month: int = None, day: int = None) -> str :staticmethod: 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 :param year: :param month: :param day: :return: .. py:property:: product_basedirs .. py:property:: subdirectory_list .. py:property:: start_month Returns a date time object for the first month of the l2i product repository .. py:property:: stop_month Returns a date time object for the last month of the l2i product repository