Skip to content

feat: add optional timezone masking (closes #2)#37

Open
steps-re wants to merge 2 commits into
bellingcat:mainfrom
steps-re:add-timezone-masking
Open

feat: add optional timezone masking (closes #2)#37
steps-re wants to merge 2 commits into
bellingcat:mainfrom
steps-re:add-timezone-masking

Conversation

@steps-re

@steps-re steps-re commented Jul 7, 2026

Copy link
Copy Markdown

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

  • Adds a timezone argument to ShadowFinder and set_details, and a --timezone option to the find and find_sun CLI commands.
  • Reuses the per-cell timezone grid ShadowFinder already computes (self.timezones), so there is no extra lookup cost: after the likelihood grid is built, cells whose timezone doesn't match are set to NaN.
  • An unrecognised timezone name emits a clear warning (e.g. suggesting an IANA name like 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 black is clean. The README documents the new option in both the library and CLI sections.

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>
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.

Add timezone masking

1 participant