Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Jun 1, 2024
1 parent 4880ab5 commit 92592b4
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/climetlab/sources/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
src/climetlab/sources/constants.py# (C) Copyright 2020 ECMWF.
# (C) Copyright 2020 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
Expand All @@ -14,7 +14,8 @@

import numpy as np

from climetlab.decorators import cached_method, normalize
from climetlab.decorators import cached_method
from climetlab.decorators import normalize
from climetlab.indexing.cube import index_to_coords
from climetlab.readers.grib.index import GribFieldSet
from climetlab.utils.dates import to_datetime
Expand Down Expand Up @@ -152,9 +153,7 @@ 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):
Expand Down Expand Up @@ -299,9 +298,7 @@ def find_numbers(source_or_dataset):
source_or_dataset, "unique_values"
), f"{source_or_dataset} (type '{type(source_or_dataset).__name__}') is not a proper source or dataset"

return source_or_dataset.unique_values(
"number", patches={"number": {None: 0}}
)["number"]
return source_or_dataset.unique_values("number", patches={"number": {None: 0}})["number"]

def find_dates(source_or_dataset):
if "date" not in self.request and "time" in self.request:
Expand All @@ -313,9 +310,7 @@ def find_dates(source_or_dataset):
if "date" in self.request and "time" in self.request:
dates = [
make_datetime(date, time)
for date, time in itertools.product(
self.request["date"], self.request["time"]
)
for date, time in itertools.product(self.request["date"], self.request["time"])
]
assert len(set(dates)) == len(dates), "Duplicates dates in constants."
return dates
Expand Down Expand Up @@ -355,9 +350,7 @@ def _getitem(self, i):
if i >= self._len:
raise IndexError(i)

date, param, number = index_to_coords(
i, (len(self.dates), len(self.params), len(self.numbers))
)
date, param, number = index_to_coords(i, (len(self.dates), len(self.params), len(self.numbers)))

# assert repeat == 0, "Not implemented"

Expand Down

0 comments on commit 92592b4

Please sign in to comment.