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

Guard against trying to subsample >100% of the data #53

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyshepseg/tiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ def fitSpectralClustersWholeFile(inDs, bandNumbers, numClusters=60,
# We will try to sample roughly this many pixels
dfltTotalPixels = 1000000
totalImagePixels = inDs.RasterXSize * inDs.RasterYSize
# subsampleProp is the proportion of rows and columns sampled
# subsampleProp is the proportion of rows and columns sampled (hence
# sqrt of total proportion).
subsampleProp = numpy.sqrt(dfltTotalPixels / totalImagePixels)
# Must be <= 1, i.e. sampling 100% of the data
subsampleProp = min(1, subsampleProp)
# subsamplePcnt is the percentage of total pixels sampled
subsamplePcnt = 100 * subsampleProp**2
else:
Expand Down
Loading