pytesmo.validation_framework.temporal_matchers module

Created on Sep 24, 2013

@author: Christoph.Paulik@geo.tuwien.ac.at

class pytesmo.validation_framework.temporal_matchers.BasicTemporalMatching(window=0.5)[source]

Bases: object

Temporal matching object

Parameters:

window (float) – window size to use for temporal matching. A match in other will only be found if it is +- window size days away from a point in reference

combinatory_matcher(df_dict, refkey, n=2, **kwargs)[source]

Basic temporal matcher that matches always one Dataframe to the reference Dataframe resulting in matched DataFrame pairs.

If the input dict has the keys ‘data1’ and ‘data2’ then the output dict will have the key (‘data1’, ‘data2’). The new key is stored as a tuple to avoid any issues with string concetanation.

During matching the column names of the dataframes will be transformed into MultiIndex to ensure unique names.

Parameters:
  • df_dict (dict of pandas.DataFrames) – dictionary containing the spatially colocated DataFrames.

  • refkey (string) – key into the df_dict of the DataFrame that should be taken as a reference.

  • n (int) – number of datasets to match at once

  • k (dummy argument) –

Returns:

matched – Dictionary containing matched DataFrames. The key is put together from the keys of the input dict as a tuple of the keys of the datasets this dataframe contains.

Return type:

dict of pandas.DataFrames

match(reference, *args)[source]

takes reference and other dataframe and returnes a joined Dataframe in this case the reference dataset for the grid is also the temporal reference dataset

pytesmo.validation_framework.temporal_matchers.df_name_multiindex(df, name)[source]

Rename columns of a DataFrame by using new column names that are tuples of (name, column_name) to ensure unique column names that can also be split again. This transforms the columns to a MultiIndex.

pytesmo.validation_framework.temporal_matchers.dfdict_combined_temporal_collocation(dfs, refname, k, window=None, n=None, **kwargs)[source]

Applies combined_temporal_collocation() on a dictionary of dataframes.

Parameters:
  • dfs (dict) – Dictionary of pd.DataFrames containing the dataframes to be collocated.

  • refname (str) – Name of the reference frame in dfs.

  • k (int) – Number of columns that will be put together in the output dictionary. The output will consist of all combinations of size k.

  • window (pd.Timedelta or float, optional) – Window around reference timestamps in which to look for data. Floats are interpreted as number of days. If it is not given, defaults to 1 hour to mimick the behaviour of BasicTemporalMatching.combinatory_matcher.

  • **kwargs – Keyword arguments passed to combined_temporal_collocation().

  • Returns

  • --------

  • matched_dict (dict) – Dictionary where the key is tuples of (refname, othernames...).

pytesmo.validation_framework.temporal_matchers.make_combined_temporal_matcher(window)[source]

Matches multiple dataframes together to only have common timestamps.

See pytesmo.temporal_matching.dfdict_combined_temporal_collocation() for more details

Parameters:

window (pd.Timedelta or float, optional) – Window around reference timestamps in which to look for data. Floats are interpreted as number of days. If it is not given, defaults to 1 hour to mimick the behaviour of BasicTemporalMatching.combinatory_matcher.