-
Notifications
You must be signed in to change notification settings - Fork 45
cumulative integrate #1419
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
cumulative integrate #1419
Conversation
erogluorhan
left a comment
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.
Thanks for putting this together! I think I am envisioning the cumulative_integrate user API a little differently than how it currently wraps the xarray one, i.e. actually a bit closer to the way the test case you've written around cross_sections handles it.
In other words, having the function signature similar to its xarray counterpart may not be intuitive since coords maybe quite different in the unstructured grids' case (e.g. node_lon, face_lat, etc. in contrast to structured lat/lon in xarray's case). Instead, shouldn't it be something like this (which is similar to our cross-sections):
def cumulative_integrate(self, lat=lat)
def cumulative_integrate(self, lon=lon)
def cumulative_integrate(self, start=(...), end=(...))
which should under the hood call our cross-section on them and then xarray
s cumulative-integrate on that result, i.e. the way the current test-case is implemented.
Or, instead of these, just do:
def cumulative_integrate(self, direction=direction)
where direction can get values of either "lon" or "lat". Not calling it coord intentionally because there is no "lat", 'lon' coords in uxarray datarrays.
Thoughts?
Consider a time‑series UxDataArray on faces with dims ("time", "n_face"), we may want cumulative precipitation along time. With the proposed lat/lon/start-end/direction signature, there’s no way to specify the time coord—forcing a cross_section... I think the current xarray-like coord=... preserves these valid uses (time, level, custom distance) without forcing a cross_section that doesn’t apply. |
Ok that makes sense to me. However, I still guess that the cumulative integration after cross sections for lat/lon coords might be (probably the most) common use case though. Therefore:
|
You're correct that wrapping the cross-section inside
Strongly agree. I will make changes to make docstring examples showing the cross-section + integrate pattern |
…lative integrate in called on uxdataarray object
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
erogluorhan
left a comment
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.
Looks great! Please don't forget to change the description of this PR accordingly for future reference.
|
This is great! |
• Fixes #98
This PR simplifies our cumulative integration story and documents how to call cumulative_integrate:
coordinate).
plotting the cumulative field over all faces at a single time slice with the Ux plot accessor.
Note: integrate vs cumulative_integrate
uxds.integrate(): Calculates total area/volume (definite integral) using grid geometry (Jacobians/face areas).
uxds.cumulative_integrate(): Calculates running accumulation (indefinite integral) along a specific coordinate path.