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

Opening Angle method optimizations and organization #144

Merged
merged 16 commits into from
Jul 10, 2024

Conversation

amoodie
Copy link
Member

@amoodie amoodie commented Jun 25, 2024

overview

Significant optimizations and organizations applied to the opening angle method. This is a breaking PR, because it fixes several bugs within the implementation. These bugs likely did not affect the results of any work relying on the computations, but were points where the code was inconsistent with intention (e.g., off-by-one errors).

changes

This PR also changes some default options to be consistent with the paper in some places, but optimized for speed and clarity in others.

  • preprocessing is added to fill lakes (optional, enabled by default)
  • the processing of water pixels and land pixels is now separated, but can still be accomplished with two calls to the dm.plan.shaw_opening_angle_method() with optional parameter query_set=lwi (land-water interface).
  • the default "number of views" (numviews is changed to 1. This provides acceptable results in nearly all circumstances, with a significant advantage of speed. Support is maintained to use numviews=3, which is consistent with the original paper. Note, the old implementation was never using more than a single view; this PR fixes this, so that the opening angle is the sum of the numviews largest view angles.
  • many variables have been renamed, to be self-consistent and consistent with the paper. Overall, I feel code readability is greatly improved.

speed

Speed also seems to be improved. In a simple example using the golf data and default options, the compute time is reduced from 0.79 to 0.28 seconds (excluding jit compile time!). The same test on this PR with numviews=3 is 0.43 seconds, due to an extra necessary call to np.sort.

PR also implements optional parallelization on the opening angle method calculation. Default is no parallelization, and an optional integer argument specifies the number of threads to use in computation. Parallelization here induces pretty low overhead for a smallish number of cores; therefore 2 cores -> ~2x speedup; 4 cores -> ~4x speedup.

I expect, but have not verified, that these benefits play out the same on larger data processing (e.g., timeseries with higher resolution data).

Andrew Moodie added 16 commits June 21, 2024 09:06
…izing in terms of min_disksize and step between disks.
…ction to be land pixels (consistent with the paper).
…s looping over 360 degrees. Split extra calculation of angles of shorelines into an optional way to process the angles from the same function, so now only returns a single obj, and the old behavior is achieved with two separate calls to the function.
…ptions to specify the query and test sets, and also allows the user to specify numviews. Previously numviews had no effect on the result. Now, numviews is treated in accordance with the p term in the original paper. up to p largest views are summed to give the result. Default choice is 1, however, whereas numviews=3 is consistent with p=3 in the paper.
…es. Change the mehtod for edge detection -- this new method accurately includes strips of land a single pixel across, which were previously being missed by the gradient-based detection.
…) lead to the inlet not being marked as land when there is no delta built yet.
@amoodie amoodie merged commit 443f374 into DeltaRCM:develop Jul 10, 2024
3 of 11 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
Development

Successfully merging this pull request may close these issues.

1 participant