Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions gsw/tests/test_check_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@
mfuncnames = [mf.name for mf in mfuncs]


@pytest.fixture(scope='session', params=mfuncs)
def cfcf(request):
return cv, cf, request.param
@pytest.fixture(params=[-360, 0, 360])
def lonshift(request):
return request.param


def test_check_function(cfcf):
cv, cf, mfunc = cfcf
@pytest.fixture(params=mfuncs, ids=mfuncnames)
def setup(request, lonshift):
cvshift = Bunch(**cv)
cvshift.long_chck_cast = cv.long_chck_cast + lonshift
return cvshift, cf, request.param


def test_check_function(setup):
cv, cf, mfunc = setup
mfunc.run(locals())
if mfunc.exception is not None or not mfunc.passed:
print('\n', mfunc.name)
Expand Down
8 changes: 8 additions & 0 deletions src/c_gsw/gsw_oceanographic_toolbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -8992,6 +8992,10 @@ gsw_sa_from_sp_baltic(double sp, double lon, double lat)
GSW_BALTIC_DATA;
double xx_left, xx_right, return_value;

lon = fmod(lon, 360.0);
if (lon < 0.0)
lon += 360.0;

if (xb_left[1] < lon && lon < xb_right[0] && yb_left[0] < lat &&
lat < yb_left[2]) {

Expand Down Expand Up @@ -9535,6 +9539,10 @@ gsw_sp_from_sa_baltic(double sa, double lon, double lat)
GSW_BALTIC_DATA;
double xx_left, xx_right, return_value;

lon = fmod(lon, 360.0);
if (lon < 0.0)
lon += 360.0;

if (xb_left[1] < lon && lon < xb_right[0] && yb_left[0] < lat &&
lat < yb_left[2]) {

Expand Down
2 changes: 2 additions & 0 deletions src/c_gsw/gsw_saar.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ gsw_saar(double p, double lon, double lat)
if (lat < -86.0 || lat > 90.0)
return (return_value);

lon = fmod(lon, 360.0);
if (lon < 0.0)
lon += 360.0;

Expand Down Expand Up @@ -180,6 +181,7 @@ gsw_deltasa_atlas(double p, double lon, double lat)
if (lat < -86.0 || lat > 90.0)
return (return_value);

lon = fmod(lon, 360.0);
if (lon < 0.0)
lon += 360.0;

Expand Down