Skip to content
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

Merged
merged 5 commits into from
Sep 6, 2024
Merged

Add Var.integrate* functions #76

merged 5 commits into from
Sep 6, 2024

Conversation

ph-kev
Copy link
Member

@ph-kev ph-kev commented Sep 5, 2024

Closes #75 - This PR port the functionality of integrating OutputVar to ClimaAnalysis from ClimaCoupler. In particular, 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.

Lastly, update_long_name_average! is replaced by update_long_name_generic! so that the integrating functions can also use this function. Also, _reduce_over take in args and kwargs in squeeze.

@Sbozzolo Sbozzolo self-requested a review September 5, 2024 20:37
src/Var.jl Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
docs/src/howdoi.md Outdated Show resolved Hide resolved
src/ClimaAnalysis.jl Outdated Show resolved Hide resolved
src/Numerics.jl Outdated Show resolved Hide resolved
src/Numerics.jl Outdated Show resolved Hide resolved
src/Numerics.jl Outdated Show resolved Hide resolved
src/Numerics.jl Outdated
Return integration weights for rectangular integration using left endpoints for integrating
along longitude.
"""
function _integration_weights_lon_left(lon::AbstractVector)
Copy link
Member

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/Numerics.jl Outdated Show resolved Hide resolved
src/Numerics.jl Outdated Show resolved Hide resolved
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")
Copy link
Member

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.
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.37%. Comparing base (f761cfd) to head (c125e84).
Report is 5 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Sbozzolo Sbozzolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you!

@ph-kev ph-kev merged commit 564c753 into CliMA:main Sep 6, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants