-
Notifications
You must be signed in to change notification settings - Fork 14
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
Shared ocean spherical convergence analysis step #126
Shared ocean spherical convergence analysis step #126
Conversation
TestingThe cosine bell test cases with viz have been run on Chrys with intel, openmpi. |
f5ed1f2
to
622675a
Compare
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.
This is going to be amazing to have! It was an excellent idea!
I have a few changes to suggest. And there's obviously some documentation needed.
t0 = datetime.datetime.strptime(xtime[0].decode(), | ||
'%Y-%m-%d_%H:%M:%S') |
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.
It's great to know that this works! I think I had had trouble with years lower than around 1600 in the past but maybe this has been fixed. I'm also surprised that the xtime
variable can be decoded with decode()
. This must be a recent improvement in xarray
.
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.
This reminds me -- I was wondering if there is another common place this should live in the framework. I could see us invoking this in a lot of analysis steps. Or maybe this should live in MPAS-Tools?
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.
Maybe we could have a polaris.time
module and put that there? It would be really handy to have something equivalent for converting from seconds to xtime
values, and that could also go there in the future.
Okay, that makes sense. In which case the min threshold is set by the QU meshes for all practical purposes. Does it make sense to keep the max? I'm not sure anyone will notice the warning if it gets exceeded. |
9c9f4b1
to
611da50
Compare
@xylar I don't see a strong reason to keep the max convergence rate. Are you ok with me removing it from the shared analysis step as well as |
Yep, go for it! |
611da50
to
5550746
Compare
5550746
to
52a5517
Compare
@xylar Thanks for reviewing! I think I've made all the changes you requested. I also finished editing the documentation. Let me know if you spot anything else. |
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.
A few more small changes to consider. In the meantime, I'll test this out.
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.
And a few more things that I noticed in running the cosine bell and building the docs.
Okay, @cbegeman, I'm done reviewing for now. If you're okay with some suggested changes, I'll approve and we can get this in! If you want to iterate a bit more, that's fine, too. |
Co-authored-by: Xylar Asay-Davis <[email protected]>
60a6fd9
to
0f01b61
Compare
@xylar I made just about all the changes you suggested. Let me know what you think about the remaining comments. |
Looks good! We'll take care of pulling out the one function into |
order1 = 0.5 * error_array[-1] * (res_array / res_array[-1]) | ||
order2 = 0.5 * error_array[-1] * (res_array / res_array[-1])**2 | ||
|
||
fig = plt.figure() |
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.
We might want to use the matplotlib
style file that we use in the global viz plots.
We would need these imports (from polaris.viz.globe
)
import sys
from typing import TYPE_CHECKING # noqa: F401
if TYPE_CHECKING or sys.version_info >= (3, 9, 0):
import importlib.resources as imp_res # noqa: F401
else:
# python <= 3.8
import importlib_resources as imp_res # noqa: F401
...
and then:
fig = plt.figure() | |
style_filename = str( | |
imp_res.files('polaris.viz') / 'polaris.mplstyle') | |
plt.style.use(style_filename) | |
fig = plt.figure() |
Without this, the plots have different font sizes before and after the viz has run:
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.
Let's decide if we want to do this in a separate PR...
I reran all 4 cosine bell tests successfully. Aside from the weird change in font size I noted above for future follow-up, everything is great! |
This PR introduces a new step class,
SphericalConvergenceAnalysis
that performs the analysis step for a convergence study, computing the convergence rate and generating a figure. Two error measures are available, L2 and L-infinity. Theexact_solution
method is set to the initial state, but can easily be modified for test cases by overriding this method in their analysis steps.I also implemented this step in the
cosine_bell
case to demonstrate its functionality.cosine_bell
is BFB with main, but the convergence rates differ because an area-weighted version of the L2 norm is used instead of the original unweighted L2 norm. I removed the differentiation of convergence rates between QU and icosahedral meshes. In my view, the acceptable convergence rates should be set by the solution methods. This change could be reverted by dropping a commit.I will update the documentation once I get an initial review of the functionality.
Checklist
api.md
) has any new or modified class, method and/or functions listedTesting
comment in the PR documents testing used to verify the changesNew tests have been added to a test suite