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 partial resampling #202

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add partial resampling #202

wants to merge 3 commits into from

Conversation

ph-kev
Copy link
Member

@ph-kev ph-kev commented Feb 27, 2025

This PR adds partial resampling by adding the keyword argument dim_names to Var.resampled_as.

We also add Var.find_corresponding_dim_name which allows one to find the name of the dimension in a OutputVar by using another dimension name.

  • Add documentation for both of the functions in the API
  • Add features to NEWS.md

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.32%. Comparing base (7513972) to head (0e63f61).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #202      +/-   ##
==========================================
+ Coverage   98.25%   98.32%   +0.06%     
==========================================
  Files          12       12              
  Lines        1263     1313      +50     
==========================================
+ Hits         1241     1291      +50     
  Misses         22       22              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ph-kev ph-kev force-pushed the kp/partial-resampled-as branch 3 times, most recently from 4d83c41 to 7d400f3 Compare February 27, 2025 19:19
@ph-kev ph-kev requested a review from Sbozzolo February 27, 2025 19:23
@ph-kev ph-kev marked this pull request as ready for review February 27, 2025 21:06
If the string or iterable `dim_names` is nothing, then resampling is done over all
dimensions. Otherwise, resampling is done over the dimensions in `dim_names`. If
resampling is done over all dimensions, then reordering dimensions is
automatically done.
Copy link
Member

Choose a reason for hiding this comment

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

What names are used for the dimensions?

Are the actual names or the conventional names?

Copy link
Member

Choose a reason for hiding this comment

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

Let's also add a !!! compat note to specify which version introduced this feature

Comment on lines +121 to +122
to fit the dimensions in `dest_var`. Resampling only over selected dimensions is
possible with the keyword `dim_names`. Resampling is not possible when the
Copy link
Member

Choose a reason for hiding this comment

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

Let's add an entry in the FAQ about this

"""
find_corresponding_dim_name(dim_name::AbstractString, dim_names::Iterable)

Find the corresponding dimension name in `dim_names` that match `dim_name`.
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 clarify that this is using the internal name bindings / going through the conventioanl names?

Comment on lines +728 to +737
x_long = 0.0:180.0 |> collect
x_lat = 0.0:90.0 |> collect
x_data = reshape(1.0:(181 * 91), (91, 181))
x_dims = OrderedDict(["lat" => x_lat, "long" => x_long])
x_attribs = Dict("long_name" => "hi")
x_dim_attribs = OrderedDict([
"lat" => Dict("units" => "test_units2"),
"long" => Dict("units" => "test_units1"),
])
x_var = ClimaAnalysis.OutputVar(x_attribs, x_dims, x_dim_attribs, x_data)
Copy link
Member

Choose a reason for hiding this comment

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

Not related to this PR, but we might want to think about adding a Factory or something to create OutputVar and reduce all this boilerplate

ph-kev added 3 commits March 3, 2025 15:33
The keyword argument `dim_names` allows the caller to only check for a
certain dimension as opposed to all of the dimensions in `x` and `y`.
@ph-kev ph-kev force-pushed the kp/partial-resampled-as branch from 7d400f3 to 0e63f61 Compare March 3, 2025 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants