-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add Var.integrate* functions #76
Conversation
src/Numerics.jl
Outdated
Return integration weights for rectangular integration using left endpoints for integrating | ||
along longitude. | ||
""" | ||
function _integration_weights_lon_left(lon::AbstractVector) |
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.
You probably don't need to specify the type in lon
here
src/Var.jl
Outdated
angle_dim_unit in deg_unit_names || | ||
lowercase(angle_dim_unit) |> (x -> occursin("deg", x)) || | ||
error("The unit for $angle_dim_name is missing or is not degree") |
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 just substitute this with
lowercase(angle_dim_unit) in deg_unit_names
?
The function `_reduce_over` has `args` and `kwargs` as inputs, but never use them. This commit changes `_reduce_over` so that `args` and `kwargs` are passed to `squeeze` in `_reduce_over`.
The commit removes `update_long_name_average!` and replace it with `update_long_name_generic!` so that it can be used by any other functions that do some kind of reduction on data.
This commit adds Var.integrate_lonlat, Var.integrate_lon, and Var.integrate_lat for integrating `OutputVar` with respect to longitude, latitude, or both. Additionally, this commit adds a Numerics module to decouple the numerical implementation of integration and the construction of an OutputVar. The numerical implementation is rectangular integration using the midpoint rule when the points are equispaced which assume each point correspond to a midpoint of a cell and using the left endpoint rule when the points are not equispaced.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #76 +/- ##
===========================================
+ Coverage 16.84% 96.37% +79.52%
===========================================
Files 9 10 +1
Lines 558 607 +49
===========================================
+ Hits 94 585 +491
+ Misses 464 22 -442 ☔ View full report in Codecov by Sentry. |
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.
Awesome! Thank you!
Closes #75 - This PR port the functionality of integrating
OutputVar
to ClimaAnalysis from ClimaCoupler. In particular,Var.integrate_lonlat
,Var.integrate_lon
, andVar.integrate_lat
for integratingOutputVar
with respect to longitude, latitude, orboth. Additionally, this commit adds a Numerics module to decouple the numerical implementation of integration and the construction of an
OutputVar
. The numerical implementation is rectangular integration using the midpoint rule when the points are equispaced which assume each point correspond to a midpoint of a cell and using the left endpoint rule when the points are not equispaced.Lastly,
update_long_name_average!
is replaced byupdate_long_name_generic!
so that the integrating functions can also use this function. Also,_reduce_over
take inargs
andkwargs
insqueeze
.