-
Notifications
You must be signed in to change notification settings - Fork 12
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
Version 1.0: North Atlantic Update - Tides, Curved Boundaries, Config, and More!😀🤯🥳 #193
base: main
Are you sure you want to change the base?
Conversation
Override min depth
Changes to make compatible with CESM
having mask table and layout no longer required
Fix layout requirements
fix typo in find replace
Replace minimum layers with min depth
…nt num After talking with Ashley, the find_MOM6_orientation will likely be removed
The function names for rectangular and sinmple boundaries were changed because the tides are a kind of boundary function, the old names now give a warning and call the correct function. GFDL had rough horizontal subsetting for the tpxo dataset (probably for efficiency?), implemented in setup_tides_rectangular_boundaries.
Collapsed the *_tidal_dims functions into the encode_tides function in segment, and add citing documentation to the docstrings for now.
…l-mom6 into croc_with_req_changes
These pending checks on this PR have been around the whole time for me. The tests have been running on CROCODILE's fork so not sure what's up here. Thanks, |
They were running up to some point; last time I've seen them run was for commit 0523f1d. |
Fixed! |
G R E A T! |
@manishvenu we can perhaps zoom on Fri and sort out the explanation of the steps at https://regional-mom6--193.org.readthedocs.build/en/193/angle_calculation.html#boundary-rotation-algorithm ? I'm in California timezone until Fri but busy up to Thu... We can also always continue chat via GitHub. |
Yes, we can definitely zoom to wrap up this PR. Feel free to email me to coordinate! I'm happy to do Friday, though it may also be easier to do sometime next week if anyone in the Australian timezone wants to join. |
Let's play it by ear on Fri... |
Sounds good. |
I've fixed the MOM_layout not writing issue, and tried testing the example notebook again. However, it crashes with the 'eta has dropped below bathy' issue even with a really short timestep. It's suggesting a huge instability too, with the sea surface passing through the centre of the planet and making it all the way to Neptune. The instabilities are located at the boundaries too. Could you confirm whether MOM6 runs the demo successfully out of the box on Derecho @manishvenu ? If not, then some of the changes since October might have caused this to break. Last I'd checked in October, the rectangular Tasmania demo worked fine on the NCAR computers, but the curved boundary with tides on did not because of a bug I introduced but which you've subsequently fixed. If this is only an issue on our machine then that would make the diagnosis a lot easier! |
Hey Ashley, The tidal bug did have pretty much that error (I think). I can try to run the reanalysis_forced demo -> We've shifted away from using a few of the functions however, CrocoDash isn't using setup_run_directory and such, mostly just the forcing functions. That should still apply to this error (it's boundary related iirc??). For the tidal bug, it's because the corners of the boundaries had NaNs in them, but that should be fixed now. Did you try turning off the tides? Thanks, |
Thanks yeah if you can check whether it works on your setup we’ll know at least that it’s not the forcing and related to the differences to our setups. If there’s a problem for you though then the forcing files might still have an issue! |
But the tidal but didn’t used to be an issue on the non rotated Tasmania example right? I remember first getting it on the curved NWA domain so something else might have happened in the meantime which messed up the non rotated simple case. I’ll try without tides though |
Yeah, it shouldn't be an issue of the non rotated Tasmania because don't get NaNs there. I haven't tested this but it probably would fail if there were NaNs in the corner. Probably isn't that error tho! I'll see if it runs on our computer tmrw. We got to figure out that way to share cases across computers at some point:) |
Hi @ashjbarnes - I managed to get output from the curved domain to run at the point where I was doing my pull request to get the example notebook into the CROCODILE repository. I only ran it for a day though and didn't look at sea level output. How long before the crash appears? If it helps, I can dig a bit deeper to see if both of mine was running properly at that point in time. |
regional_mom6/rotation.py
Outdated
# Compute angle | ||
angle = np.arctan2( | ||
lon_scale * ((lonB[0, 1] - lonB[1, 0]) + (lonB[1, 1] - lonB[0, 0])), | ||
(bottom_left.y - top_right.y) + (top_left.y - bottom_right.y), |
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.
if we look at
it should be
(bottom_left.y - top_right.y) + (top_left.y - bottom_right.y), | |
(top_right.y - bottom_left.y) + (top_left.y - bottom_right.y), |
right @manishvenu, @ashjbarnes? Am I missing something here?
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.
Yes it is, good catch, thanks!
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 can do a little bit of testing next week for this
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.
Getting weird results, let me look at this further
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.
Ok I figured it out, this bug worked the first time because the numerator is also flipped the exact same way lonB is in indexing [y,x] so the complete fix should be :
angle = np.arctan2( lon_scale * (( lonB[1, 0] - lonB[0, 1]) + (lonB[1, 1] - lonB[0, 0])), (top_right.y - bottom_left.y) + (top_left.y - bottom_right.y) )
Basically, you always want the top points subtracting the bottom points on a diagonal.
We either do the suggestion here, or change the lonB matrix to be x,y instead of y, x. I can make this change.
Interesting note, because they were both flipped, thankfully, there were only differences in angles up to the 1e-5
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.
how's the commit I pushed?
the difference in angles "only up to 1e-5" depends on the grid you are testing; coarser grid might have more difference!
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.
Great - Fixed it. Forgot to swap the other part of the numerator
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 had a 90 degree transformation, didn't need that, which is good. Thanks for catching this Navid
def test_mom6_angle_calculation_method(get_curvilinear_hgrid): | ||
""" | ||
Check no rotation, up tilt, down tilt. | ||
""" | ||
|
||
# Check no rotation | ||
top_left = xr.Dataset( | ||
{ | ||
"x": (("nyp", "nxp"), [[0]]), | ||
"y": (("nyp", "nxp"), [[1]]), | ||
} | ||
) | ||
top_right = xr.Dataset( | ||
{ | ||
"x": (("nyp", "nxp"), [[1]]), | ||
"y": (("nyp", "nxp"), [[1]]), | ||
} | ||
) | ||
bottom_left = xr.Dataset( | ||
{ | ||
"x": (("nyp", "nxp"), [[0]]), | ||
"y": (("nyp", "nxp"), [[0]]), | ||
} | ||
) | ||
bottom_right = xr.Dataset( | ||
{ | ||
"x": (("nyp", "nxp"), [[1]]), | ||
"y": (("nyp", "nxp"), [[0]]), | ||
} | ||
) | ||
point = xr.Dataset( | ||
{ | ||
"x": (("nyp", "nxp"), [[0.5]]), | ||
"y": (("nyp", "nxp"), [[0.5]]), | ||
} | ||
) | ||
|
||
assert ( | ||
rot.mom6_angle_calculation_method( | ||
2, top_left, top_right, bottom_left, bottom_right, point | ||
) | ||
== 0 | ||
) | ||
|
||
# Angled | ||
hgrid = get_curvilinear_hgrid | ||
ds_t = rgd.get_hgrid_arakawa_c_points(hgrid, "t") | ||
ds_q = rgd.get_hgrid_arakawa_c_points(hgrid, "q") | ||
|
||
# Reformat into x, y comps | ||
t_points = xr.Dataset( | ||
{ | ||
"x": (("nyp", "nxp"), ds_t.tlon.data), | ||
"y": (("nyp", "nxp"), ds_t.tlat.data), | ||
} | ||
) | ||
q_points = xr.Dataset( | ||
{ | ||
"x": (("nyp", "nxp"), ds_q.qlon.data), | ||
"y": (("nyp", "nxp"), ds_q.qlat.data), | ||
} | ||
) | ||
assert ( | ||
( | ||
rot.mom6_angle_calculation_method( | ||
hgrid.x.max() - hgrid.x.min(), | ||
q_points.isel(nyp=slice(1, None), nxp=slice(0, -1)), | ||
q_points.isel(nyp=slice(1, None), nxp=slice(1, None)), | ||
q_points.isel(nyp=slice(0, -1), nxp=slice(0, -1)), | ||
q_points.isel(nyp=slice(0, -1), nxp=slice(1, None)), | ||
t_points, | ||
) | ||
- hgrid["angle_dx"].isel(nyp=ds_t.t_points_y, nxp=ds_t.t_points_x).values | ||
) | ||
< 1 | ||
).all() | ||
|
||
return |
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.
Can you explain what this test tests?
I see "assert something, something < 1", that doesn't sound too strict. But I admit I don't quite understand what the test tries to test what's been tested so that may be clear if I did?
For a test of mom6_angle_calculation_method
I'd expect we construct a grid at a particular angle and test to see if the mom6_angle_calculation_method
computes that angle?
Fix angle calc
Hey @ashjbarnes, 5 day run worked on the NCAR computer. I wonder what it is. Happy to send over the forcing files if that'll help |
@ashjbarnes could you update the features-limitations in the Readme as well? Thanks! |
Awesome thanks @helenmacdonald ! All I can say is that I took the Tassie example as it currently is, put in the same paths as I've done before (I have all the Tassie stuff saved for this purpose on Gadi), and it crashes before completing one day. Unfortunately I really need focus on my PhD after allowing myself a bit of rmom6 time last week (A wonderfully productive source of procrastination) so I won't get back around to troubleshooting further myself for another couple of weeks. If anyone on Gadi had the time to test it out that would be much appreciated! Given that @manishvenu said it works in Casper, it's got to be something to do with the setup_rundir function, and in turn the text files in the run directory rather than the input files, as there's no reason that the inputs would be different between our cases. Unless the NCAR workflow now does further modifications to the input files that I'm not aware of |
Authors: @ashjbarnes, @manishvenu, @helenmacdonald
Description:
Ashley and I worked together to add a few features to RM6. While we get the changes ready to merge with the main COSIMA branch, please check out this draft with a list of the changes below.
Major Features:
Minor Features:
Breaking Changes (for backwards compatibility):
Documentation Changes:
Co-authored-by: @ashjbarnes, @helenmacdonald
this PR closes #184 , #168 , and also #55 in a roundabout way since user now specifies which boundaries they want, and the MOM inputs are adjusted accordingly.
Before merging, need to resolve the following:
Outstanding Questions:
regridding.py
androtation.py
). Do we want to switch over RM6 to use python logging instead of print statements? Currently, we would prefer that but open it up to opinions.