obsparsers class#
- class pycif.utils.classes.obsparsers.ObsParser(plg_orig=None, orig_name='', **kwargs)[source]#
Bases:
Plugin
Class for handling time series parsing from different data providers and data file formats.
- static check_df(df, **kwargs)[source]#
Check that all required columns have been loaded
- Parameters:
df
kwargs
- Returns:
- classmethod get_parser(plg)[source]#
Get the correct Parser for a provider and file_format_id
- Args:
provider (str): provider of the input file file_format_id (str): name of the type of file with a given format
- Returns:
Parser: Parser for provider and file_format_id
- initiate_template()[source]#
Initializes a Plugin template, with methods from the corresponding module.
- Args:
self: the plugin to initialize plg_type: the type of the plugin to initialize default_functions (dict[str, bool]):
functions to load from the module and to attach to the plugin. Each key names the function and each value is a boolean to determine whether the corresponding function is a class method (with a reflective self as argument) or a classical static function
- parse_file(obs_file, **kwargs)[source]#
This function does the parsing (and post processing if necessary).
- Args:
obs_file (str): path to input file
- Keyword Args:
encoding (str): Encoding of input files freq (str): frequency after resampling
see `Offset Aliases`_ for valid strings
- src_freq (str):
explicit setting of the frequency in the input file shouldn’t be necessary
- Returns:
pandas.DataFrame: renamed, shifted, resampled Dataframe df[obssite_id, parameter] with t as index
- parse_multiple_files(**kwargs)[source]#
Parses multiple files specified by a glob pattern and stores the content into a datastore.
- Args:
self: the plugin with its describing arguments (in particular dir_obs)
- Returns:
dict: {obs_file} = df[obssite_id, parameter]
- Note:
By default, the function calls self.parse_file, which filters out NaNs and check that all required columns are available.
- classmethod register_parser(provider, file_format_id, parse_module, **kwargs)[source]#
Register a parsing function for provider and format with default options
- Args:
provider (str): provider of the input file file_format_id (str): name of the type of file with a given format parse_module (Module):
returns file content as pandas.DataFrame df[obssite_id, parameter]
**kwargs: default options for parse_function
- Notes:
The parse_function signature is the same as the
Parser.parse_file()