Skip to content

Commit dadcae0

Browse files
authored
Merge pull request #311 from ecmwf/feature/handle_reduced_ll_grid
add handling of reduced_ll pl array with 0 values ie local reduced_ll…
2 parents 09d3d4c + 8885c30 commit dadcae0

File tree

1 file changed

+9
-3
lines changed
  • polytope_feature/datacube/transformations/datacube_mappers/mapper_types

1 file changed

+9
-3
lines changed

polytope_feature/datacube/transformations/datacube_mappers/mapper_types/reduced_ll.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ def __init__(self, base_axis, mapped_axes, resolution, md5_hash=None, local_area
2222
raise NotImplementedError("Reduced lat-lon grid with first axis in decreasing order is not supported")
2323

2424
def first_axis_vals(self):
25+
start_lat = 90
26+
if self._resolution == 3601:
27+
start_lat = 89.973092
2528
resolution = 180 / (self._resolution - 1)
26-
vals = [-90 + i * resolution for i in range(self._resolution)]
29+
vals = [round(start_lat - i * resolution, 12) for i in range(self._resolution)]
2730
return vals
2831

2932
def map_first_axis(self, lower, upper):
@@ -5084,8 +5087,11 @@ def lon_spacing(self):
50845087
def second_axis_vals(self, first_val):
50855088
first_idx = self._first_axis_vals.index(first_val[0])
50865089
Ny = self.lon_spacing()[first_idx]
5087-
second_spacing = 360 / Ny
5088-
return [i * second_spacing for i in range(Ny)]
5090+
if Ny != 0:
5091+
second_spacing = 360 / Ny
5092+
return [i * second_spacing for i in range(Ny)]
5093+
else:
5094+
raise ValueError("Requested latitude value is not within reduced latitude-longitude grid bounds")
50895095

50905096
def map_second_axis(self, first_val, lower, upper):
50915097
axis_lines = self.second_axis_vals(first_val)

0 commit comments

Comments
 (0)