Skip to content

reproject: NaN/Inf in scalar inputs propagates silently #1435

@brendancol

Description

@brendancol

Description

Several scalar / array inputs to reproject helpers are not finite-checked. NaN and Inf values pass through, producing silently wrong output instead of a clean error.

Site Bad input
itrf_transform(epoch=NaN/Inf) (_itrf.py:235) NaN -> dt = obs - epoch is NaN -> all-NaN output. Inf -> overflow garbage.
geoid_height(lon=NaN/Inf, lat=NaN/Inf) (_vertical.py:178) Index math (int(col_f) with % w) wraps NaN/Inf into bogus indices, returning a plausible-looking finite N.
ellipsoidal_to_orthometric / orthometric_to_ellipsoidal / depth_to_ellipsoidal / ellipsoidal_to_depth Inherit the geoid_height NaN/Inf bug.
_detect_nodata(nodata=Inf) (_crs_utils.py:113) nodata=Inf accepted; np.full(..., Inf) outputs break downstream np.isnan checks.

Expected behavior

Each scalar input is finite-checked at the API boundary. Latitude is also bounded to [-90, 90]. nodata=Inf is rejected (NaN remains the legitimate sentinel for missing data).

Proposed fix

  • itrf_transform: if not np.isfinite(epoch): raise ValueError(...) plus non-empty src/tgt strings.
  • geoid_height: enforce np.isfinite(lon).all() and np.isfinite(lat).all() plus (-90 <= lat <= 90).all(). The four conversion helpers inherit the fix.
  • _detect_nodata: after float(nodata) reject +/-Inf (NaN is still allowed as the canonical sentinel).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginput-validationInput validation and error messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions