pytesmo.validation_framework.results_manager module
The results manager stores validation results in netcdf format.
- class pytesmo.validation_framework.results_manager.PointDataResults(filename, zlib=True, read_only=False)[source]
Bases:
Dataset
- add_metrics_results(lons, lats, results, attr=None)[source]
Add observations over time to a locations results.
- Parameters:
lons (np.array) – Array of location longitudes, shape must match shape of arrays in data
lats (np.array) – Array of location latitudes, shape must match shape of arrays in data
results (dict) – Variable names as dict keys and data arrays as values. As returned by the metric calculators, except the RollingMetrics. Shape of data arrays must match lons/lats.
attr (dict, optional (default: None)) – Variable names as keys and attributes as dicts for each variable. Only used when the variable is created, not if it is already in the dataset.
- Returns:
idx – Indices of the new locations, can be used to add time results
- Return type:
indices
- add_result(lon, lat, data, ts_vars=None, times=None, attr=None)[source]
Add all results (time series and location metrics) for a single point.
- Parameters:
lon (float) – Longitude of the point
lat (float) – Latitude of the point
data (dict) – Dict of metric names and values. For normal (not rolling) metrics this is an array of size 1, otherwise if the same size as time.
times (np.array, optional (default: None)) – Time values, length must mach all time series (rolling) metrics in data.
attr (dict, optional (default: None)) –
- add_ts_results(idx, times, results, attr=None)[source]
Add observations over time to previously added locations results.
- Parameters:
idx (int) – Location index, as returned when adding metrics results.
times (pd.DatetimeIndex or np.array) – Datetime index as in the validation results from rolling metrics
results (dict) – Variable names as dict keys and data arrays as values. Data arrays must have same size as times.
attr (dict, optional (default: None)) – Variable names as keys and attributes as dicts for each variable. Only used when the variable is created, not if it is already in the dataset.
- read_loc(idx: int | array | None = None) DataFrame [source]
Read loc data for one/multiple/all point(s)
- property variables: array
Names of all variables in the data set
- pytesmo.validation_framework.results_manager.build_filename(root, key)[source]
Create savepath/filename that does not exceed 255 characters
- pytesmo.validation_framework.results_manager.netcdf_results_manager(results, save_path, filename: dict | None = None, ts_vars: list | None = None, zlib=True, attr=None)[source]
Write validation results to netcdf file.
- Parameters:
results (dict) – Validation results as returned by the metrics calculator. Keys are tuples that define the dataset names that were used. Values contains ‘lon’ and ‘lat’ keys for defining the points, and optionally ‘time’ which sets the time stamps for each location (if there are metrics over time in the results - e.g due to RollingMetrics)
save_path (str) – Directory where the netcdf file(s) are are created.
filename (dict, optional (default: None)) – Filename(s) (value), for each dataset combination in results (key). By default (if None is passed) the keys in results are used to generate a file name.
ts_vars (list, optional (default: None)) – List of variables in results that are treated as time series
zlib (bool, optional (default: True)) – Activate compression
attr (dict, optional (default: None)) – Variable attributes, variable names as keys, attributes as another dict in values.