-
Notifications
You must be signed in to change notification settings - Fork 42
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
Optimize NuthKaab RAM usage #198
Conversation
Huh, I get a 500 HTTP response when trying to look at the changed files! Making a new apply function (or just reviving the old one) is one solution to the problem, indeed! It's unfortunate that the fix is required (I'm not particularly proud of Your "Thoughts" parts are most easily handled by the user-end. The Coreg class takes two rasters in the same grid and estimates the shifts. If the reference DEM has a higher resolution, why not reproject the reference DEM? If it is larger than the TBA DEM, it could be cropped beforehand. Making a custom |
I fully agree that currently the generic implementation is overly complex, especially in the case of Nuth & Kaab where we only need a shift. I also agree that we should try to optimize memory usage so that it can run on a desktop computer, as it will be most use cases. I also agree with @erikmannerfelt that the issue of DEM resolution and extent can easily be handled beforehand by the user with all of the nice geoutils tools 😉. Should we talk about all this together when @rhugonnet get back to work? |
As these resolution/extent steps would have no influence on the N&K results, but have high potential to improve its efficiency, I think it should be an optimization within the |
Closing this, as we'll be working on the We still have the ~20 lines of changes proposed here for the record and the discussion. |
Slightly related to #110.
Issue
The
apply_matrix
function is using a lot of RAM, which rapidly limits application on personal computers.I tested with a couple of DEMs of ~500 and 100MB on disk that, respectively, take about 1GB and 200MB in-memory.
Running
NuthKaab.fit()
(using the 100MB DEM as reference to reduce usages) uses ~2Go of RAM, which is OK but still a lot.We should aim to cap it at 3-4 times the DEM size, enough for: 1x elevation differences, 1x slope, 1x aspect.
Running
NuthKaab.apply()
on the 500MB DEM (the dem to align) results in a memory error after using more than 8GB of memory.We should aim to cap it at 1 times the DEM size, enough for: 1x DEM correction at the same grid size, possibly derived from a 4x4 matrix.
Started a fix
I tried to re-write the old
apply_func
of the Nuth and Kaab based on arrays into a case to treat differently inapply_matrix
but I'm not sure that it is correct as I'm only familiar with the method of shifting the geotransform + warping (input @erikmannerfelt, @adehecq ?).If we find a magic solution to speed up/limit RAM usage for the generic
apply_matrix
solution, great!But otherwise, we should probably try to subdivide in use cases to make it as efficient as possible. I guess that leaving these cases outside of the
NuthKaab
and otherCoreg
subclasses makes sense in case theapply_func
needs to be applied for a fullCoregPipeline
.Thoughts
These issues made me think that we could add a "default" behaviour for coregistration that optimizes efficiency:
What do you think?