Follow-up to #2767 / #2803.
While fixing hotspots() to compute the real Getis-Ord Gi* statistic, I found that emerging_hotspots() carries its own copy of the same wrong formula. In xrspatial/emerging_hotspots.py it convolves each time step with a normalized kernel and z-scores the local mean against the global mean/std (see _emerging_hotspots_numpy around line 414, _emerging_hotspots_cupy around line 447, and _convolve_and_zscore_chunk around line 474). It reuses _calc_hotspots_numpy for the banding but never computes the Gi* weight sum, squared weight sum, sample count n, or the variance adjustment term.
The fix mirrors #2803: compute the per-cell Gi* z-score from the kernel weight sum, squared weight sum, valid-cell count, global mean, and population std, on all four backends. The Gi* helpers added in #2803 (_gistar_zscore, _gistar_global_stats) can be reused. The space-time hot/cold trend classification (Mann-Kendall step) stays as is; only the per-step z-score is wrong.
Kept separate from #2803 to keep one fix per PR.
Follow-up to #2767 / #2803.
While fixing
hotspots()to compute the real Getis-Ord Gi* statistic, I found thatemerging_hotspots()carries its own copy of the same wrong formula. Inxrspatial/emerging_hotspots.pyit convolves each time step with a normalized kernel and z-scores the local mean against the global mean/std (see_emerging_hotspots_numpyaround line 414,_emerging_hotspots_cupyaround line 447, and_convolve_and_zscore_chunkaround line 474). It reuses_calc_hotspots_numpyfor the banding but never computes the Gi* weight sum, squared weight sum, sample count n, or the variance adjustment term.The fix mirrors #2803: compute the per-cell Gi* z-score from the kernel weight sum, squared weight sum, valid-cell count, global mean, and population std, on all four backends. The Gi* helpers added in #2803 (
_gistar_zscore,_gistar_global_stats) can be reused. The space-time hot/cold trend classification (Mann-Kendall step) stays as is; only the per-step z-score is wrong.Kept separate from #2803 to keep one fix per PR.