feat: add optional timezone masking (closes #2)#37
Open
steps-re wants to merge 2 commits into
Open
Conversation
Closes bellingcat#2. When the timezone of a location is known, ShadowFinder can now mask out candidate cells in every other timezone, leaving only the matching region. Adds a `timezone` argument to `ShadowFinder`/`set_details` and a `--timezone` option to the `find` and `find_sun` CLI commands, reusing the per-cell timezone grid the tool already computes. An unrecognised timezone name emits a clear warning instead of silently returning an empty map. Includes tests covering the masked and unmasked cases, and documents the new option in the README. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses review feedback: - set_details now keeps a previously set timezone when called with timezone=None, matching how object_height/shadow_length/sun_altitude are preserved. Previously a partial update (e.g. changing only the time) silently dropped the timezone mask. - find_shadows now warns when masking leaves no candidate cells at all (a misspelled IANA name, or a timezone entirely in darkness), instead of silently returning a blank map. This replaces the narrower "not in grid" warning and also covers the night case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2.
What
When the timezone of a photographed location is known, this adds an optional way to mask out candidate locations in every other timezone, so the results focus on the matching region.
How
timezoneargument toShadowFinderandset_details, and a--timezoneoption to thefindandfind_sunCLI commands.self.timezones), so there is no extra lookup cost: after the likelihood grid is built, cells whose timezone doesn't match are set toNaN.Europe/Kyiv) rather than silently returning an empty map.Example
shadowfinder find 10 5 2024-02-29 13:59:59 --time_format=utc --timezone="Europe/Kyiv"On a sample scenario this narrows the candidate set from ~88,000 cells spanning 249 timezones down to ~290 cells, all within
Europe/Kyiv.Tests
Adds tests covering both the masked case (only the requested timezone survives) and the unmasked baseline (candidates span many timezones). Full suite passes and
blackis clean. The README documents the new option in both the library and CLI sections.