| import pandas as pd | |
| import xarray as xr | |
| from pathlib import Path | |
| import warnings | |
| def test_load(file_path, benchmark_name): | |
| with xr.open_dataset(file_path) as dataset: | |
| metric = dataset["metric"] | |
| failures = (metric == -1).sum(dim="random_seed") | |
| metric = metric.where(metric != -1) | |
| metric_mean = metric.mean(dim="random_seed", skipna=True) | |
| if isinstance(metric_mean, xr.DataArray): | |
| df = metric_mean.to_dataframe(name="metric").reset_index() | |
| df_failures = failures.to_dataframe(name="failures").reset_index() | |
| df["failures"] = df_failures["failures"] | |
| else: | |
| print("Not DataArray") | |
| print(df.head()) | |
| test_load(Path("data/bayesian/l63_hm.nc"), "L63") | |
| test_load(Path("data/l63_ensemble_results.nc"), "L63") | |
| test_load(Path("data/bayesian/l63_abc.nc"), "L63") | |