thermostrife.lookup

Tiered weather-archive resolver. See Pipeline guide for the tier cascade.

.. py:module:: thermostrife.lookup

Tiered Tmax resolver across GHCN, observatory archives, and reanalysis.

.. py:class:: Resolution(tmax_c: float | None, provenance: str, source_id: str, note: str = ‘’) :module: thermostrife.lookup

Bases: :py:class:object

Result of a single (lat, lon, date) lookup (no baseline).

.. py:attribute:: Resolution.tmax_c :module: thermostrife.lookup :type: float | None

.. py:attribute:: Resolution.provenance :module: thermostrife.lookup :type: str

.. py:attribute:: Resolution.source_id :module: thermostrife.lookup :type: str

.. py:attribute:: Resolution.note :module: thermostrife.lookup :type: str :value: ‘’

.. py:class:: AnomalyFetch(tmax_event_c: float | None, baseline: pd.DataFrame, station_id: str, provenance: str, note: str = ‘’) :module: thermostrife.lookup

Bases: :py:class:object

Generic event-day + baseline-window result from any tier.

By construction the baseline is built from the same underlying source / station / series that produced tmax_event_c, so the anomaly tmax_event_c - baseline['tmax'].mean() is internally consistent.

.. py:attribute:: AnomalyFetch.tmax_event_c :module: thermostrife.lookup :type: float | None

.. py:attribute:: AnomalyFetch.baseline :module: thermostrife.lookup :type: pd.DataFrame

.. py:attribute:: AnomalyFetch.station_id :module: thermostrife.lookup :type: str

.. py:attribute:: AnomalyFetch.provenance :module: thermostrife.lookup :type: str

.. py:attribute:: AnomalyFetch.note :module: thermostrife.lookup :type: str :value: ‘’

.. py:method:: AnomalyFetch.empty(note: str = ‘’) -> ~thermostrife.lookup.AnomalyFetch :module: thermostrife.lookup :classmethod:

.. py:function:: resolve(lat: float, lon: float, when: ~datetime.date, *, station_hint: str | None = None, radius_km: float = 50.0) -> ~thermostrife.lookup.Resolution :module: thermostrife.lookup

Resolve daily Tmax for when via the tier cascade.

.. py:function:: resolve_event_anomaly(lat: float, lon: float, when: ~datetime.date, *, half_window_years: int = 5, event_buffer_days: int = 7, min_baseline_days: int = 20, radius_km: float = 50.0) -> ~thermostrife.lookup.AnomalyFetch :module: thermostrife.lookup

Cascade through tiers until one returns a consistent (event, baseline) pair.

The returned AnomalyFetch carries event-day Tmax and a baseline DataFrame drawn from the same underlying series — never mixed across tiers — so the anomaly is internally consistent.

.. py:function:: fetch_same_source_day(provenance: str, lat: float, lon: float, when: ~datetime.date, *, station_id: str | None = None, radius_km: float = 60.0) -> float | None :module: thermostrife.lookup

Fetch Tmax at when via the same tier / station that resolved an event.

Dispatch by provenance: tier1 → meteostat (with station_id as a hint to pin the same station the cascade picked), tier2 → HadCET, tier3 → ERA5, tier4 → 20CRv3. Returns None if the dispatched adapter has no value for that date.

Used by thermostrife.inference.h3_within_event_contrast to pull surrounding-day Tmax values (t±1, t±7) for the within-event control test without mixing sources or stations.