Describe the bug
Six CUDA inverse projection kernels in _projections_cuda.py return raw lam + lon0 without wrapping longitude to [-180, 180]. The corresponding CPU Numba kernels in _projections.py all pass the result through _norm_lon_rad() before converting to degrees.
Without normalization, input coordinates far from the central meridian (e.g., near the antimeridian, or in a sinusoidal projection with wide extent) can produce longitude values outside [-180, 180], which then get converted to nonsensical source pixel coordinates.
Affected CUDA kernels
| Kernel |
Line |
CPU equivalent |
_d_lcc_inv |
294, 298 |
_lcc_inv_point (line 428) |
_d_aea_inv |
358 |
_aea_inv_point (line 564) |
_d_cea_inv |
407 |
_cea_inv_point (line 631) |
_d_sinu_inv |
479 |
_sinu_inv_point (line 747) |
_d_laea_inv |
597 |
_laea_inv_point (line 926) |
_d_stere_inv |
673 |
_stere_inv_point (line 1075) |
CPU version (correct)
return math.degrees(_norm_lon_rad(lam + lon0)), math.degrees(phi)
CUDA version (missing normalization)
return math.degrees(lam + lon0), math.degrees(phi)
Expected behavior
CUDA inverse projections should normalize longitude to [-pi, pi] before converting to degrees, matching the CPU kernels.
Additional note
_tmerc_params() (line 1745-1748 in _projections.py) has dead code: a loop computing dCn that is immediately overwritten by _clenshaw_complex_py() on line 1751. Not a bug, but worth cleaning up.
Describe the bug
Six CUDA inverse projection kernels in
_projections_cuda.pyreturn rawlam + lon0without wrapping longitude to [-180, 180]. The corresponding CPU Numba kernels in_projections.pyall pass the result through_norm_lon_rad()before converting to degrees.Without normalization, input coordinates far from the central meridian (e.g., near the antimeridian, or in a sinusoidal projection with wide extent) can produce longitude values outside [-180, 180], which then get converted to nonsensical source pixel coordinates.
Affected CUDA kernels
_d_lcc_inv_lcc_inv_point(line 428)_d_aea_inv_aea_inv_point(line 564)_d_cea_inv_cea_inv_point(line 631)_d_sinu_inv_sinu_inv_point(line 747)_d_laea_inv_laea_inv_point(line 926)_d_stere_inv_stere_inv_point(line 1075)CPU version (correct)
CUDA version (missing normalization)
Expected behavior
CUDA inverse projections should normalize longitude to [-pi, pi] before converting to degrees, matching the CPU kernels.
Additional note
_tmerc_params()(line 1745-1748 in_projections.py) has dead code: a loop computingdCnthat is immediately overwritten by_clenshaw_complex_py()on line 1751. Not a bug, but worth cleaning up.