Skip to content

Commit

Permalink
Merge pull request #311 from ecmwf/feature/handle_reduced_ll_grid
Browse files Browse the repository at this point in the history
add handling of reduced_ll pl array with 0 values ie local reduced_ll…
  • Loading branch information
mathleur authored Jan 28, 2025
2 parents 09d3d4c + 8885c30 commit dadcae0
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ def __init__(self, base_axis, mapped_axes, resolution, md5_hash=None, local_area
raise NotImplementedError("Reduced lat-lon grid with first axis in decreasing order is not supported")

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

def map_first_axis(self, lower, upper):
Expand Down Expand Up @@ -5084,8 +5087,11 @@ def lon_spacing(self):
def second_axis_vals(self, first_val):
first_idx = self._first_axis_vals.index(first_val[0])
Ny = self.lon_spacing()[first_idx]
second_spacing = 360 / Ny
return [i * second_spacing for i in range(Ny)]
if Ny != 0:
second_spacing = 360 / Ny
return [i * second_spacing for i in range(Ny)]
else:
raise ValueError("Requested latitude value is not within reduced latitude-longitude grid bounds")

def map_second_axis(self, first_val, lower, upper):
axis_lines = self.second_axis_vals(first_val)
Expand Down

0 comments on commit dadcae0

Please sign in to comment.