Skip to content

Commit

Permalink
Feature/prepml (#56)
Browse files Browse the repository at this point in the history
* fix setting mars type
  • Loading branch information
b8raoult authored Nov 26, 2024
1 parent 1496c6a commit 33d750f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/anemoi/inference/grib/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def grib_keys(
date,
time,
step,
type,
keys,
quiet,
grib1_keys={},
Expand Down Expand Up @@ -86,7 +85,11 @@ def grib_keys(
if edition == 2:
result.update(grib2_keys.get(param, {}))

result.setdefault("type", "fc")
type = result.get("type")

if type is not None:
# For organisations that do not use type
result.setdefault("dataType", type)

# if stream is not None:
Expand Down Expand Up @@ -160,7 +163,7 @@ def same(w, v, k):
w = handle.get(k)

if not same(w, v, k):
mismatches[k] = (w, v)
mismatches[k] = 'Expected "{}" but got "{}"'.format(v, w)

if mismatches:
raise ValueError(f"GRIB field could not be encoded. Mismatches={mismatches}")
2 changes: 0 additions & 2 deletions src/anemoi/inference/outputs/grib.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def write_initial_state(self, state):
date=None,
time=None,
step=0,
type="fc",
keys=self.encoding,
grib1_keys=self.grib1_keys,
grib2_keys=self.grib2_keys,
Expand Down Expand Up @@ -124,7 +123,6 @@ def write_state(self, state):
time=reference_date.hour,
step=step,
param=param,
type="fc",
accumulation=variable.is_accumulation,
keys=keys,
grib1_keys=self.grib1_keys,
Expand Down

0 comments on commit 33d750f

Please sign in to comment.