Skip to content

Commit

Permalink
Merge branch 'release/0.16.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Aug 14, 2023
2 parents 51d7709 + 4af03e8 commit 2af57e2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
12 changes: 11 additions & 1 deletion climetlab/plotting/backends/magics/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,17 @@ def _push_layer(self, data):
self._layers.append(Layer(data))

def plot_grib(self, path: str, offset: int):
assert offset < 2**31, "grib_field_position must be less than 2**31"
if offset >= 2**31:
# Because Magics (version <4.14) does not support input
# grib files whihc are > 2**31 Bytes.
from climetlab.readers.grib.codes import CodesReader

tmp = self.temporary_file(".grib")
reader = CodesReader.from_cache(path)
handle = reader.at_offset(int(offset))
handle.save(tmp)
path = tmp
offset = 0

self._push_layer(
mgrib(
Expand Down
24 changes: 24 additions & 0 deletions climetlab/sources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,33 @@ def sin_local_time(self, date):
def insolation(self, date):
from ecmwf_mlkit.variables.insolation import insolation

date = to_datetime(date)
result = insolation([date], self.latitude_(), self.longitude_())
return result.flatten()

def toa_incident_solar_radiation(self, date):
from earthkit.meteo.solar import toa_incident_solar_radiation

date = to_datetime(date)
result = toa_incident_solar_radiation(
date - datetime.timedelta(hours=1),
date,
self.latitude_(),
self.longitude_(),
)
return result.flatten()

def cos_solar_zenith_angle(self, date):
from earthkit.meteo.solar import cos_solar_zenith_angle

date = to_datetime(date)
result = cos_solar_zenith_angle(
date,
self.latitude_(),
self.longitude_(),
)
return result.flatten()


class ConstantField:
def __init__(self, date, param, proc, shape):
Expand Down
2 changes: 1 addition & 1 deletion climetlab/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.16.1
0.16.2

0 comments on commit 2af57e2

Please sign in to comment.