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

Replace stacking gradient search with resample_blocks variant #626

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

Conversation

mraspaud
Copy link
Member

@mraspaud mraspaud commented Oct 22, 2024

This PR replaces the stacking gradient search with resample blocks for the swath to area case.
It also adds support for area to swath in the gradient search.

  • Closes #xxxx
  • Tests added
  • Tests passed
  • Fully documented

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 98.95833% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.93%. Comparing base (c4ce8ee) to head (c174f88).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
pyresample/gradient/__init__.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #626      +/-   ##
==========================================
- Coverage   93.97%   93.93%   -0.04%     
==========================================
  Files          86       86              
  Lines       13848    13494     -354     
==========================================
- Hits        13013    12675     -338     
+ Misses        835      819      -16     
Flag Coverage Δ
unittests 93.93% <98.95%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@mraspaud mraspaud marked this pull request as ready for review October 22, 2024 09:43
@mraspaud mraspaud requested a review from pnuu October 22, 2024 09:43
@coveralls
Copy link

coveralls commented Oct 22, 2024

Coverage Status

coverage: 93.625% (-0.06%) from 93.686%
when pulling c174f88 on mraspaud:feature-remove-stacking-gradient
into 8da073e on pytroll:main.

@mraspaud mraspaud self-assigned this Oct 22, 2024
Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

Couple of initial comments. I'll do some real-life testing next.

I'm surprised you could get rid of such a huge chunk of code!

Comment on lines +56 to +57
if ((isinstance(source_geo_def, AreaDefinition) and isinstance(target_geo_def, AreaDefinition)) or
(isinstance(source_geo_def, SwathDefinition) and isinstance(target_geo_def, AreaDefinition))):
Copy link
Member

Choose a reason for hiding this comment

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

Could these be is_area_to_swath(source_geo_def, target_geo_def) and is_swath_to_area(source_geo_def, target_geo_def)? Also, this bit seems to be untested, likely also originally.

@@ -618,7 +353,7 @@ def block_bilinear_interpolator(data, indices_xy, fill_value=np.nan, block_info=
res = ((1 - weight_l) * (1 - weight_p) * data[..., l_start, p_start] +
(1 - weight_l) * weight_p * data[..., l_start, p_end] +
weight_l * (1 - weight_p) * data[..., l_end, p_start] +
weight_l * weight_p * data[..., l_end, p_end])
weight_l * weight_p * data[..., l_end, p_end]).astype(data.dtype)
Copy link
Member

Choose a reason for hiding this comment

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

Should we make sure the calculation is does not promote the dtype in the first place by making the weights the same type?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. I think I want to keep the highest precision to do the bilinear interpolation, and only then convert to float32. But maybe I'm being too careful?

Copy link
Member

@pnuu pnuu Oct 22, 2024

Choose a reason for hiding this comment

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

I doubt there's anything lost whether the interpolation is done with float32 or float64. Of course the weights need to be floats, so casting to integer dtypes would still need additional handling... But as a test, it might be interesting to see the difference in memory usage between f32/f64 weights.

@mraspaud
Copy link
Member Author

For reference, main seems to have striping problems:
overview_20190405_081003_main
This branch doesn't:
overview_20190405_081003

@mraspaud
Copy link
Member Author

Also, preliminary test, resampling that metop scene to euron1 takes 5GB on main vs 3GB with this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants