Skip to content

Commit

Permalink
rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Mar 25, 2024
1 parent e0bde7c commit 0d41060
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions climetlab/readers/grib/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,12 @@ def resolution(self):
y = self["DyInDegrees"]
assert x == y, (x, y)
return x

if grid_type == "lambert":
x = self["DxInMetres"]
y = self["DyInMetres"]
assert x == y, (x, y)
return x
return str(x / 1000).replace(".", "p") + "km"

raise ValueError(f"Unknown gridType={grid_type}")

Expand Down Expand Up @@ -664,7 +665,7 @@ def iterate_grid_points(self):

@cached_property
def rotated(self):
return self.handle.get("latitudeOfSouthernPoleInDegrees") is not None
return "rotated" in self.grid_type

@cached_property
def rotated_iterator(self):
Expand All @@ -683,6 +684,8 @@ def grid_points(self):
lat = np.array([d["lat"] for d in data])
lon = np.array([d["lon"] for d in data])

lon[lon >= 360] -= 360

return lat, lon

def grid_points_unrotated(self):
Expand Down Expand Up @@ -723,3 +726,8 @@ def grid_points_raw(self):
return lat, lon
finally:
self.handle.set("iteratorDisableUnrotate", 0)

@property
def proj_string(self):
# +proj=lcc +lon_0=5.000000 +lat_0=53.500000 +lat_1=53.500000 +lat_2=53.500000 +R=6367470.000000
return self.handle.get("projString")

0 comments on commit 0d41060

Please sign in to comment.