Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats function moved to be better shared across metrics #1014

Merged
merged 20 commits into from
Jan 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update
  • Loading branch information
lee1043 committed Jan 4, 2024
commit d0c98dcbd5e399aab7669f4b68ff816aaecf68da
10 changes: 8 additions & 2 deletions pcmdi_metrics/io/xcdat_dataset_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ def _find_key(
) -> str:
try:
key = xc.get_dim_keys(ds, axis)
except Exception:
except Exception as e:
axes = get_axis_list(ds)
key_candidates = [k for k in axes if k.lower() in potential_names]
if len(key_candidates) > 0:
key = key_candidates[0]
else:
key_candidates = [k for k in axes if k.lower() in potential_names]
data_keys = get_data_list(ds)
key_candidates = [k for k in data_keys if k.lower() in potential_names]
if len(key_candidates) > 0:
key = key_candidates[0]
else:
all_keys = ", ".join(axes + data_keys)
print(
f"Error: Cannot find a proper key name for {axis} from keys:{all_keys} {e}"
)
return key


Expand Down
Loading