Skip to content

Fix four bugs in the time-series workflow - #51

Merged
mfangaritav merged 11 commits into
ASFHyP3:developfrom
yuankailiu:fix-hyp3-job-failures
Nov 14, 2026
Merged

mfangaritav merged 11 commits into
ASFHyP3:developfrom
yuankailiu:fix-hyp3-job-failures

Conversation

@yuankailiu

@yuankailiu yuankailiu commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Found while debugging failed time-series jobs on hyp3-lavas. Each commit fixes one bug and can be reviewed on its own.

1. Wrong orbit for scenes acquired just before midnight

  • Problem: sentinel/orbitstatevectors.py saves orbit times without the date, so for scenes between 23:00 and 24:00 UTC the code picks the orbit from the next day.
  • Effect: the GSLCs are all zeros and the job fails. This happened to every scene of Lago-Yojoa a165.
  • Fix: store orbit times relative to midnight of the acquisition date (sentinel/orbitstatevectors.py, sentinel/getburststatevectors.f90). Scenes at other times are not affected. The a165 GSLCs need to be made again.

2. Clear error when unwrapping fails

  • Problem: the bundled snaphu (2.0 beta from 2017) crashes on some small patches of valid pixels next to no-data areas. On Tacaná a136, 26 of 655 interferograms were not unwrapped, and the job only failed later in sbas with an unclear error.
  • Fix: util/unwrap_parallel.py now stops right away with a list of the interferograms that failed to unwrap.
  • The crash itself is fixed by upgrading snaphu to 2.0.7 (sent by @ashkreli to @mfangaritav separately), so this PR does not change snaphu.

3. Wrong track number for Sentinel-1C in product names

  • Problem: src/srg/time_series.py used the Sentinel-1B formula for Sentinel-1C.
  • Effect: products that start with an S1C scene have the wrong track in their name (for example a116 named _86_).
  • Fix: use the right offset for each satellite. Added a test.

4. Reference point one row off

  • Problem: sbas/sbas.f90 reads the reference phase one row below the ref_locs points.
  • Effect: small, about 0.5 mm on Jebel-at-Tair a116.
  • Fix: read the phase at the ref_locs points.

Testing

  • Tacaná a136: reproduced the snaphu crash from the S3 data; the old snaphu now stops with the list of failed interferograms, and snaphu 2.0.7 unwraps all 26.
  • Lago-Yojoa a165: the fixed code picks the correct orbit (checked against the orbit file); the GSLCs were not re-made here.
  • Unit tests pass; ruff and mypy are clean.

Not included: choosing reference points with refpointsfromsim (hyp3-srg PR #161).

@yuankailiu
yuankailiu requested review from a team and kspepin as code owners November 5, 2026 01:14
@yuankailiu yuankailiu changed the title Fix HyP3 time-series failures: midnight orbit, snaphu segfault, S1C track name, ref pixel row Fix four bugs in the time-series workflow Nov 9, 2026
yuankailiu and others added 4 commits November 9, 2026 11:50
orbitstatevectors.py stored state-vector times as seconds of day,
dropping the date. A POEORB file spans ~26 h, so the time column wraps
at midnight, and getburststatevectors.f90 took vectors from the day after
the file's first midnight. For a 23:58 scene the ASF orbit service
returns the file starting D 22:59:42, so the vectors came from D+1:
the satellite was on the other side of the Earth, every GSLC was all
zeros and no SBAS pairs passed the baseline cut (Lago-Yojoa a165).

Store times as seconds since midnight of the acquisition date (from
the SAFE name), so they never wrap, and search from the first vector.
Scenes at other times select the same vectors as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
util/unwrap_parallel.py now checks that every .int has a .unw of the
same size and exits 1 with the list of failed interferograms. Before,
a failed unwrap (e.g. the snaphu 2.0-beta crash on Tacana a136, 26 of
655 interferograms) only showed up later as 'Non-existing record
number' in regressheight/sbas. The snaphu crash itself is fixed by
upgrading snaphu to 2.0.7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every non-S1A granule used the S1B offset (27), so stacks starting with
an S1C scene got the wrong track number (e.g. a116 named _86_, a022
named _167_). Use a per-platform offset table: S1A 73, S1B 27, S1C 172.
The S1C offset is verified on S1C granules of known track (95, 136, 22).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
phase is allocated (nr, naz, ncells), but the reference phase was read
as phase(nr+ref_locs(1,k), ref_locs(2,k), i), left over from the older
dat(2*nr, naz) layout. In column-major order nr+x spills into the next
row, so every reference point was taken one row below the listed pixel.

Checked on Jebel-at-Tair a116 (78 ref_locs): before, the time series
averaged 0 one row below the ref_locs; after, it averages 0 at the
ref_locs. The change is a constant per epoch (here up to 0.11 rad,
~0.5 mm).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yuankailiu
yuankailiu force-pushed the fix-hyp3-job-failures branch from 226b5db to 5dd565a Compare November 9, 2026 19:51
@mfangaritav
mfangaritav changed the base branch from hyp3-srg to develop November 10, 2026 19:08

@mfangaritav mfangaritav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snaphu has been updated to 2.0.7 in this PR

@mfangaritav
mfangaritav merged commit 13d928c into ASFHyP3:develop Nov 14, 2026
7 checks passed
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.

2 participants