Skip to content

Commit

Permalink
Merge branch 'release/0.21.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Feb 26, 2024
2 parents 70836d0 + 0320c5b commit 7d3addf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion climetlab/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.21.1
0.21.2
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def read(fname):
"cfgrib>=0.9.10.1",
"cdsapi",
"ecmwf-api-client>=1.6.1",
"earthkit-meteo",
"multiurl>=0.1.0",
"ecmwf-opendata>=0.1.2",
"tqdm",
Expand Down
25 changes: 15 additions & 10 deletions tests/sources/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#

import datetime

import numpy as np

from climetlab import load_source
Expand All @@ -35,7 +36,7 @@ def test_constant_1():
"cos_julian_day",
"cos_local_time",
"sin_julian_day",
"sin_local_time",
"cos_solar_zenith_angle",
]

ds = load_source(
Expand Down Expand Up @@ -70,7 +71,7 @@ def test_constant_2():
"cos_julian_day",
"cos_local_time",
"sin_julian_day",
"sin_local_time",
"cos_solar_zenith_angle",
]

ntimes = 4
Expand All @@ -92,19 +93,23 @@ def test_constant_3():

date = sample[0].datetime()
date_plus_6h = date + datetime.timedelta(hours=6)
a = load_source("constants", sample, date=date_plus_6h, param="insolation")
b = load_source("constants", sample, date=date, param="insolation+6h")
a = load_source(
"constants", sample, date=date_plus_6h, param="cos_solar_zenith_angle"
)
b = load_source("constants", sample, date=date, param="cos_solar_zenith_angle+6h")
assert np.all(a.to_numpy() == b.to_numpy())
assert a.unique_values("param")["param"] == ("insolation",)
assert b.unique_values("param")["param"] == ("insolation+6h",)
assert a[0].metadata("param") == "cos_solar_zenith_angle"
assert b[0].metadata("param") == "cos_solar_zenith_angle+6h"

date = sample[0].datetime()
date_minus_30d = date + datetime.timedelta(days=-30)
a = load_source("constants", sample, date=date_minus_30d, param="insolation")
b = load_source("constants", sample, date=date, param="insolation-30d")
a = load_source(
"constants", sample, date=date_minus_30d, param="cos_solar_zenith_angle"
)
b = load_source("constants", sample, date=date, param="cos_solar_zenith_angle-30d")
assert np.all(a.to_numpy() == b.to_numpy())
assert a.unique_values("param")["param"] == ("insolation",)
assert b.unique_values("param")["param"] == ("insolation-30d",)
assert a[0].metadata("param") == "cos_solar_zenith_angle"
assert b[0].metadata("param") == "cos_solar_zenith_angle-30d"


if __name__ == "__main__":
Expand Down

0 comments on commit 7d3addf

Please sign in to comment.