Open
Conversation
…nto add-support-for-met-norway-verification-output-mergebranch
…utput-mergebranch
Sorcha/dev/1880 REfactor of verifparser
Collaborator
Contributor
Author
Contributor
I don't believe it will affect the work as there are no changes to the |
enssow
reviewed
Mar 16, 2026
Comment on lines
+190
to
+210
| var_dict, pl = find_pl(data.channel.values) | ||
| data_vars = {} | ||
|
|
||
| for new_var, old_vars in var_dict.items(): | ||
| if len(old_vars) > 1: | ||
| data_vars[new_var] = xr.DataArray( | ||
| data.sel(channel=old_vars).values, | ||
| dims=["ipoint", "pressure_level"], | ||
| ) | ||
| else: | ||
| data_vars[new_var] = xr.DataArray( | ||
| data.sel(channel=old_vars[0]).values, | ||
| dims=["ipoint"], | ||
| ) | ||
|
|
||
| reshaped_dataset = xr.Dataset(data_vars) | ||
| reshaped_dataset = reshaped_dataset.assign_coords( | ||
| ipoint=data.coords["ipoint"], | ||
| pressure_level=pl, | ||
| ) | ||
|
|
Contributor
There was a problem hiding this comment.
HI Rolf, fyi there are recent changes to the export package that will affect this PR. To ensure compatibility, these lines should be changed (I'm not sure if merging ecmwf/develop will do it automatically so leaving a comment here)
Suggested change
| var_dict, pl = find_pl(data.channel.values) | |
| data_vars = {} | |
| for new_var, old_vars in var_dict.items(): | |
| if len(old_vars) > 1: | |
| data_vars[new_var] = xr.DataArray( | |
| data.sel(channel=old_vars).values, | |
| dims=["ipoint", "pressure_level"], | |
| ) | |
| else: | |
| data_vars[new_var] = xr.DataArray( | |
| data.sel(channel=old_vars[0]).values, | |
| dims=["ipoint"], | |
| ) | |
| reshaped_dataset = xr.Dataset(data_vars) | |
| reshaped_dataset = reshaped_dataset.assign_coords( | |
| ipoint=data.coords["ipoint"], | |
| pressure_level=pl, | |
| ) | |
| var_dict = find_pl(data.channel.values) | |
| data_vars = {} | |
| for new_var, pls in var_dict.items(): | |
| if pls[0] is not None: | |
| old_vars = [f"{new_var}_{p}" for p in pls] | |
| data_vars[new_var] = xr.DataArray( | |
| data.sel(channel=old_vars).values, | |
| dims=["ipoint", "pressure_level"], | |
| coords={"pressure_level": pls}, | |
| ) | |
| else: | |
| data_vars[new_var] = xr.DataArray( | |
| data.sel(channel=new_var).values, | |
| dims=["ipoint"], | |
| ) | |
| reshaped_dataset = xr.Dataset(data_vars) | |
| reshaped_dataset = reshaped_dataset.assign_coords( | |
| ipoint=data.coords["ipoint"], | |
| ) | |
| # order using pressure_level coord | |
| if "pressure_level" in reshaped_dataset.coords: | |
| reshaped_dataset = reshaped_dataset.sortby("pressure_level") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds routines to generate verif files for Met Norways verification program.
Issue Number
Closes #1800
Checklist before asking for review
./scripts/actions.sh lint./scripts/actions.sh unit-test./scripts/actions.sh integration-testlaunch-slurm.py --time 60