-
Notifications
You must be signed in to change notification settings - Fork 27
Account for ERA5/ClimaAtmos topo differences #4098
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
Open
costachris
wants to merge
1
commit into
main
Choose a base branch
from
cc/improve_wxmodel_pressure_init_diag
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,13 +158,29 @@ function to_z_levels(source_file, target_file, target_levels, FT) | |
| end | ||
|
|
||
| # Write 2D surface variables - extend to all levels (TODO: accept 2D variables in atmos) | ||
| # Simply repeat the surface values for all levels | ||
| surf_map = Dict("skt" => "skt", "sp" => "p") | ||
| # Duplicate 2D surface field across all target vertical levels | ||
| surf_map = Dict("skt" => "skt", "sp" => "p", "surface_geopotential" => "z_sfc") | ||
| for (src_name, dst_name) in surf_map | ||
| var_obj = | ||
| defVar(ncout, dst_name, FT, ("lon", "lat", "z"), attrib = ncin[src_name].attrib) | ||
| # Choose attributes; for z_sfc, set clean altitude attributes | ||
| var_attrib = if dst_name == "z_sfc" | ||
| Dict( | ||
| "standard_name" => "surface_altitude", | ||
| "long_name" => "surface altitude derived from ERA5", | ||
| "units" => "m", | ||
| "source_variable" => src_name, | ||
| ) | ||
| else | ||
| ncin[src_name].attrib | ||
| end | ||
| var_obj = defVar(ncout, dst_name, FT, ("lon", "lat", "z"), attrib = var_attrib) | ||
| # Read first time slice and coalesce; follow same convention as sp (use [:, :, 1]) | ||
| data2d = FT.(coalesce.(ncin[src_name][:, :, 1], NaN)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a coalesce? Are there instances when the data is NaN and our model will still run? If not then we could consider asserting not NaN |
||
| # Convert geopotential to meters if necessary | ||
| if dst_name == "z_sfc" | ||
| data2d .= data2d ./ grav | ||
| end | ||
costachris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for k in 1:length(target_levels) | ||
| var_obj[:, :, k] = FT.(ncin[src_name][:, :, 1]) | ||
| var_obj[:, :, k] = data2d | ||
| end | ||
| end | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the data you're writing is geopotential based on the ERA5 name? If that is the case the units are gravity * height (m^2/s^2) and would be good to at least rename the long_name and the units. I would also use zg_sfc even though ERA5 uses z for geopotential because then it's very clear.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok I see what is happening now, you're correct. Not sure I have an immediate suggestion other that it is a little confusing because there are two if statements in this loop to catch
z_sfcsince it needs a new var_attrib and needs to be divided by gravity. Possibly separating it out could be cleaner / easier to read if a little longer.