From 4adafdafbc5b86073f7fdba751fca116c9435948 Mon Sep 17 00:00:00 2001 From: Sandor Kertesz Date: Mon, 3 Jun 2024 09:26:45 +0100 Subject: [PATCH] Harmonise code with climetlab --- src/earthkit/data/core/index.py | 23 +++++++++++++---------- src/earthkit/data/readers/grib/output.py | 4 ++++ src/earthkit/data/sources/constants.py | 7 +++---- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/earthkit/data/core/index.py b/src/earthkit/data/core/index.py index 5b97488a..b9fe1555 100644 --- a/src/earthkit/data/core/index.py +++ b/src/earthkit/data/core/index.py @@ -119,23 +119,26 @@ def build_actions(self, kwargs): actions = {} def ascending(a, b): - if a == b: + if a is b or a == b: return 0 - if b is None or a > b: + + if b is None: return 1 - if a is None or a < b: - return -1 - raise ValueError(f"{a},{b}") - def descending(a, b): - if a == b: - return 0 - if b is None or a > b: + if a is None: return -1 - if a is None or a < b: + + if a > b: return 1 + + if a < b: + return -1 + raise ValueError(f"{a},{b}") + def descending(a, b): + return -ascending(a, b) + class Compare: def __init__(self, order): self.order = order diff --git a/src/earthkit/data/readers/grib/output.py b/src/earthkit/data/readers/grib/output.py index 0ec98437..779060ac 100644 --- a/src/earthkit/data/readers/grib/output.py +++ b/src/earthkit/data/readers/grib/output.py @@ -134,6 +134,10 @@ def write( for k in NOT_IN_EDITION_1: metadata.pop(k, None) + if int(metadata.get("deleteLocalDefinition", 0)): + for k in ("class", "type", "stream", "expver", "setLocalDefinition"): + metadata.pop(k, None) + if "generatingProcessIdentifier" not in metadata: metadata["generatingProcessIdentifier"] = 255 diff --git a/src/earthkit/data/sources/constants.py b/src/earthkit/data/sources/constants.py index 9fc1289b..5ef86330 100644 --- a/src/earthkit/data/sources/constants.py +++ b/src/earthkit/data/sources/constants.py @@ -10,7 +10,6 @@ import datetime import itertools import logging -from warnings import warn import numpy as np @@ -154,9 +153,9 @@ def sin_local_time(self, date): return np.sin(radians) def insolation(self, date): - warn( - "The function `insolation` is deprecated, please use `cos_solar_zenith_angle` instead" - ) + # warn( + # "The function `insolation` is deprecated, please use `cos_solar_zenith_angle` instead" + # ) return self.cos_solar_zenith_angle(date) def toa_incident_solar_radiation(self, date):