Skip to content

2/8 Normalize satellite timestamps across units - #39

Open
Timothy-W-Hilton wants to merge 1 commit into
tglauch:mainfrom
Timothy-W-Hilton:fix-satellite-timestamp-units
Open

2/8 Normalize satellite timestamps across units#39
Timothy-W-Hilton wants to merge 1 commit into
tglauch:mainfrom
Timothy-W-Hilton:fix-satellite-timestamp-units

Conversation

@Timothy-W-Hilton

Copy link
Copy Markdown

Normalize satellite timestamps across units

Summary

Convert per-pixel satellite acquisition times to elapsed days using NumPy timedelta64 arithmetic rather than assuming that datetime values use nanosecond units.

Why

vprm_preprocessor.sort_and_merge_by_timestamp() previously divided elapsed datetime values by 1e9 and then by the number of seconds per day. That is correct only for datetime64[ns]. MODIS inputs can carry datetime64[us] timestamps; under the old calculation, distinct acquisition dates then collapsed toward day zero. LOWESS consequently received incorrect time coordinates and could return missing EVI/LSWI values.

Change

Divide the elapsed NumPy timedelta directly by np.timedelta64(1, "D"). This is independent of the underlying datetime precision and produces elapsed days for nanosecond-, microsecond-, and other supported NumPy datetime units.

Validation

  • Added a regression test with microsecond-resolution per-pixel acquisition timestamps on days 0 and 8.
  • The test verifies that the merged timestamp coordinate is [0.0, 8.0], rather than collapsing both observations to zero.
  • Focused test suite: 1 passed (one existing deprecation warning from xarray's drop method).

Convert per-pixel acquisition timestamps to elapsed days with NumPy
timedelta arithmetic rather than assuming nanosecond precision. This
preserves correct LOWESS timing for microsecond-resolution MODIS
timestamps, preventing distinct observations from collapsing onto day
zero; add a regression test covering the affected normalization path.
@Timothy-W-Hilton Timothy-W-Hilton changed the title Normalize satellite timestamps across units 2/8 Normalize satellite timestamps across units Aug 16, 2026
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.

1 participant