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

fix 286 #287

Merged
merged 8 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Bug fixes
* Fixed ``get_warming_level`` to avoid incomplete matches. (:pull:`269`).
* `search_data_catalogs` now eliminates anything that matches any entry in `exclusions`. (:issue:`275`, :pull:`280`).
* Fixed a bug in ``xs.scripting.save_and_update`` where ``build_path_kwargs`` was ignored when trying to guess the file format. (:pull:`282`).
* Add a warning to ``xs.extract._dispatch_historical_to_future``. (:issue:`286`, :pull:`287`).

Internal changes
^^^^^^^^^^^^^^^^
Expand Down
6 changes: 6 additions & 0 deletions xscen/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,12 @@ def _dispatch_historical_to_future(
hist = sdf[sdf.experiment == "historical"]
if hist.empty:
continue
if pd.isna(sdf.activity).any():
warnings.warn(
f"np.NaN was found in the activity column of {group}. The rows with np.NaN activity will be skipped."
"If you want them to be included in the historical and future matching, please put a valid activity (https://xscen.readthedocs.io/en/latest/columns.html)."
"For example, xscen expects experiment `historical` to have `CMIP` activity and experiments `sspXYZ` to have `ScenarioMIP` activity. "
)
for activity_id in set(sdf.activity) - {"HighResMip", np.NaN}:
sub_sdf = sdf[sdf.activity == activity_id]
for exp_id in set(sub_sdf.experiment) - {"historical", "piControl", np.NaN}:
Expand Down