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

missingmask of all layers in rasterstack #599

Merged
merged 9 commits into from
Feb 6, 2024

Conversation

tiemvanderdeure
Copy link
Collaborator

Changes the default behaviour of missingmask when applied on a RasterStack or RasterSeries, so the mask covers all layers.

It's probably possible to reduce the memory use of this operation by using missingmask!, but I can't really see how to guarantee that that works when not all dimensions are shared.

The dispatch on RasterSeries might run into errors if the dimensions are not shared between the layers, so maybe we don't want it?

@tiemvanderdeure tiemvanderdeure changed the title Missingmask_rasterstack missingmask of all layers in rasterstack Feb 5, 2024
@rafaqz
Copy link
Owner

rafaqz commented Feb 5, 2024

Yeah it will have to be using mask!.

broadcast_dims! can probably handle this pretty easily. First make the mask array matching the total size of the stack.
then map over layers(stack) and use broadcast_dims! on each layer to update the values.

Should only need one allocation. Will work even if stack layer dims are in weird orders, missing, etc.

Bad part is missing values in small layers propagate to every other dimension, but I guess we want that.

@tiemvanderdeure
Copy link
Collaborator Author

I definitely think we want missing values to propagate across dimensions. I can't come up with another consistent way to do this.

@tiemvanderdeure
Copy link
Collaborator Author

Alright, tried my best. But it might be you can come up with some wizardry to make this even cleaner?

src/methods/mask.jl Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (18dcf5d) 82.09% compared to head (9e96152) 82.17%.

Files Patch % Lines
src/methods/mask.jl 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #599      +/-   ##
==========================================
+ Coverage   82.09%   82.17%   +0.08%     
==========================================
  Files          61       61              
  Lines        4228     4242      +14     
==========================================
+ Hits         3471     3486      +15     
+ Misses        757      756       -1     

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

@rafaqz
Copy link
Owner

rafaqz commented Feb 5, 2024

Is there a test for mixed size stacks?

@tiemvanderdeure
Copy link
Collaborator Author

I added some.

Right now missingmask will fail on a RasterSeries if some layers have dimensions that the first layer does not have. For a RasterStack it just calls dims, but we cannot do this for a RasterSeries.

What do you think the most logical behaviour would be in that case?

@rafaqz
Copy link
Owner

rafaqz commented Feb 6, 2024

RasterSeries is for fixed dimensions so thats fine.

@tiemvanderdeure
Copy link
Collaborator Author

In that case I think we're good to go.

@rafaqz rafaqz merged commit 09e2f1d into rafaqz:main Feb 6, 2024
6 of 7 checks passed
@tiemvanderdeure tiemvanderdeure deleted the missingmask_rasterstack branch April 8, 2024 09:25
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.

3 participants