Skip to content

Commit 7b54630

Browse files
authored
Merge pull request #220 from aodn/FixSelCoord
Fix: data query fix on latitude coordinate orientation for get_data
2 parents 6be97ac + d1c4db3 commit 7b54630

File tree

2 files changed

+625
-48
lines changed

2 files changed

+625
-48
lines changed

aodn_cloud_optimised/lib/DataQuery.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
PolygonNotIntersectingError,
5151
)
5252

53-
__version__ = "0.2.7"
53+
__version__ = "0.2.8"
5454

5555
REGION: Final[str] = "ap-southeast-2"
5656
ENDPOINT_URL = "https://s3.ap-southeast-2.amazonaws.com"
@@ -2049,7 +2049,13 @@ def get_data(
20492049
lat_is_dim = lat_var_name in ds.dims
20502050

20512051
if lat_is_dim:
2052-
selectors[lat_var_name] = slice(lat_min, lat_max)
2052+
# Check the direction of the latitude values, very important for the slicing
2053+
lat_values = ds[lat_var_name].values
2054+
if lat_values[0] > lat_values[-1]:
2055+
# latitude is descending (north to south)
2056+
selectors[lat_var_name] = slice(lat_max, lat_min)
2057+
else:
2058+
selectors[lat_var_name] = slice(lat_min, lat_max)
20532059
else:
20542060
if lat_min is not None:
20552061
mask_conditions.append(ds[lat_var_name] >= lat_min)

0 commit comments

Comments
 (0)