Skip to content

Commit add579e

Browse files
authored
Merge pull request #83 from NREL/bnb/dep_resolve
resolve dependencies
2 parents 42d8dfe + 087b6f7 commit add579e

3 files changed

Lines changed: 113 additions & 107 deletions

File tree

pyproject.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@ classifiers=[
2626
"Programming Language :: Python :: 3.11",
2727
]
2828
dependencies = [
29-
"netCDF4>=1.6,<1.7",
30-
"NREL-gaps>=0.8.0,<0.9",
29+
"sphinx-tabs>=3.4.5,<3.4.6",
30+
"sphinx>=8.0.2,<8.1.0",
31+
"NREL-gaps>=0.6.14,<0.8.0",
3132
"NREL-cloud_fs>=0.0.8",
3233
"NREL-farms>=1.0.6",
33-
"scikit-learn>=1.0",
3434
"NREL-rest2>=1.0.2",
3535
"NREL-mlclouds>=0.0.5",
36+
"netCDF4>=1.5.8,<1.7",
37+
"scikit-learn>=1.0",
38+
"matplotlib>=3.1"
3639
]
3740

3841
[project.optional-dependencies]
3942
dev = [
4043
"build>=0.5",
4144
"pre-commit",
4245
"ruff>=0.5.0",
43-
"matplotlib>=3.10.0"
4446
]
4547
doc = [
46-
"sphinx>=7.4.7",
48+
"sphinx>=8.0.2",
4749
"sphinx_rtd_theme>=3.0.2",
4850
"sphinx-click>=5.2.1",
4951
]
@@ -172,4 +174,4 @@ include-package-data = true
172174
packages = ["nsrdb"]
173175

174176
[tool.setuptools_scm]
175-
version_file = "nsrdb/_version.py"
177+
version_file = "nsrdb/_version.py"

tests/gap_fill/test_gap_fill.py

Lines changed: 82 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,88 +5,107 @@
55
66
@author: gbuster
77
"""
8+
89
from copy import deepcopy
910

1011
import numpy as np
1112

1213
from nsrdb.gap_fill.cloud_fill import CloudGapFill
1314
from nsrdb.utilities.pytest import execute_pytest
1415

15-
CLOUD_TYPE = np.array([[0, 0, -128, 0, 0, 7],
16-
[1, 1, -15, 0, 0, 7],
17-
[7, 3, -15, 0, 0, 0],
18-
[7, -15, -15, 0, 1, 0],
19-
[3, 8, -15, 5, 1, 7],
20-
[3, 8, -15, 5, 1, 7],
21-
[7, 3, -15, -15, 4, -15],
22-
[7, 3, -15, 5, 4, 7],
23-
])
24-
25-
CLD_OPD_DCOMP = np.array([[0, 0, 0, 0, 0, 0],
26-
[0, 0, 0, 0, 0, 0],
27-
[0, 0, 0, 0, 0, 0],
28-
[0, 0, 0, 0, 0, 0],
29-
[71, 43, 0, 0, 0, 0],
30-
[73, 45, 0, 0, 0, 41],
31-
[17, 29, 0, 0, 0, 0],
32-
[14, 21, 0, 0, 0, 0],
33-
], dtype=np.int32)
34-
35-
SZA = np.array([[0, 0, 0, 0, 0, 180],
36-
[0, 0, 0, 0, 0, 180],
37-
[0, 0, 0, 0, 180, 180],
38-
[0, 0, 0, 0, 180, 180],
39-
[0, 0, 0, 0, 0, 0],
40-
[0, 0, 0, 0, 0, 0],
41-
[0, 0, 0, 0, 180, 0],
42-
[180, 0, 0, 180, 180, 0],
43-
])
44-
45-
OUT_CTYPE = np.array([[0, 0, 0, 0, 0, 7],
46-
[1, 1, 0, 0, 0, 7],
47-
[7, 3, 0, 0, 0, 0],
48-
[7, 3, 0, 0, 1, 0],
49-
[3, 8, 0, 5, 1, 7],
50-
[3, 8, 0, 5, 1, 7],
51-
[7, 3, 0, 5, 4, 7],
52-
[7, 3, 0, 5, 4, 7]], dtype=np.int8)
53-
54-
OUT_PROP = np.array([[0, 0, 0, 0, 0, 0],
55-
[0, 0, 0, 0, 0, 0],
56-
[17, 29, 0, 0, 0, 0],
57-
[17, 29, 0, 0, 0, 0],
58-
[71, 43, 0, 10, 0, 41],
59-
[73, 45, 0, 10, 0, 41],
60-
[17, 29, 0, 10, 0, 41],
61-
[0, 21, 0, 0, 0, 41]], dtype=np.int32)
62-
63-
OUT_FILL_FLAG = np.array([[0, 0, 2, 0, 0, 0],
64-
[0, 0, 2, 0, 0, 0],
65-
[3, 3, 2, 0, 0, 0],
66-
[3, 1, 2, 0, 0, 0],
67-
[0, 0, 2, 4, 0, 3],
68-
[0, 0, 2, 4, 0, 0],
69-
[0, 0, 2, 1, 0, 1],
70-
[0, 0, 2, 0, 0, 3]], dtype=np.int8)
16+
CLOUD_TYPE = np.array([
17+
[0, 0, -128, 0, 0, 7],
18+
[1, 1, -15, 0, 0, 7],
19+
[7, 3, -15, 0, 0, 0],
20+
[7, -15, -15, 0, 1, 0],
21+
[3, 8, -15, 5, 1, 7],
22+
[3, 8, -15, 5, 1, 7],
23+
[7, 3, -15, -15, 4, -15],
24+
[7, 3, -15, 5, 4, 7],
25+
])
26+
27+
CLD_OPD_DCOMP = np.array(
28+
[
29+
[0, 0, 0, 0, 0, 0],
30+
[0, 0, 0, 0, 0, 0],
31+
[0, 0, 0, 0, 0, 0],
32+
[0, 0, 0, 0, 0, 0],
33+
[71, 43, 0, 0, 0, 0],
34+
[73, 45, 0, 0, 0, 41],
35+
[17, 29, 0, 0, 0, 0],
36+
[14, 21, 0, 0, 0, 0],
37+
],
38+
dtype=np.int32,
39+
)
40+
41+
SZA = np.array([
42+
[0, 0, 0, 0, 0, 180],
43+
[0, 0, 0, 0, 0, 180],
44+
[0, 0, 0, 0, 180, 180],
45+
[0, 0, 0, 0, 180, 180],
46+
[0, 0, 0, 0, 0, 0],
47+
[0, 0, 0, 0, 0, 0],
48+
[0, 0, 0, 0, 180, 0],
49+
[180, 0, 0, 180, 180, 0],
50+
])
51+
52+
OUT_CTYPE = np.array(
53+
[
54+
[0, 0, 0, 0, 0, 7],
55+
[1, 1, 0, 0, 0, 7],
56+
[7, 3, 0, 0, 0, 0],
57+
[7, 3, 0, 0, 1, 0],
58+
[3, 8, 0, 5, 1, 7],
59+
[3, 8, 0, 5, 1, 7],
60+
[7, 3, 0, 5, 4, 7],
61+
[7, 3, 0, 5, 4, 7],
62+
],
63+
dtype=np.int8,
64+
)
65+
66+
OUT_PROP = np.array(
67+
[
68+
[0, 0, 0, 0, 0, 0],
69+
[0, 0, 0, 0, 0, 0],
70+
[17, 29, 0, 0, 0, 0],
71+
[17, 29, 0, 0, 0, 0],
72+
[71, 43, 0, 10, 0, 41],
73+
[73, 45, 0, 10, 0, 41],
74+
[17, 29, 0, 10, 0, 41],
75+
[0, 21, 0, 0, 0, 41],
76+
],
77+
dtype=np.int32,
78+
)
79+
80+
OUT_FILL_FLAG = np.array(
81+
[
82+
[0, 0, 2, 0, 0, 0],
83+
[0, 0, 2, 0, 0, 0],
84+
[3, 3, 2, 0, 0, 0],
85+
[3, 1, 2, 0, 0, 0],
86+
[0, 0, 2, 4, 0, 3],
87+
[0, 0, 2, 4, 0, 0],
88+
[0, 0, 2, 1, 0, 1],
89+
[0, 0, 2, 0, 0, 3],
90+
],
91+
dtype=np.int8,
92+
)
7193

7294

7395
def test_type():
7496
"""Test the cloud property gap fill algorithm."""
75-
cloud_type, fill_flag = CloudGapFill.fill_cloud_type(deepcopy(CLOUD_TYPE))
97+
cloud_type, _ = CloudGapFill.fill_cloud_type(deepcopy(CLOUD_TYPE))
7698
assert np.array_equal(cloud_type, OUT_CTYPE)
77-
return cloud_type, fill_flag
7899

79100

80101
def test_opd():
81102
"""Test the cloud property gap fill algorithm."""
82103
_, fill_flag = CloudGapFill.fill_cloud_type(deepcopy(CLOUD_TYPE))
83-
cloud_prop, fill_flag = CloudGapFill.fill_cloud_prop('cld_opd_dcomp',
84-
CLD_OPD_DCOMP,
85-
CLOUD_TYPE, SZA,
86-
fill_flag=fill_flag)
104+
cloud_prop, fill_flag = CloudGapFill.fill_cloud_prop(
105+
'cld_opd_dcomp', CLD_OPD_DCOMP, CLOUD_TYPE, SZA, fill_flag=fill_flag
106+
)
87107
assert np.array_equal(cloud_prop, OUT_PROP)
88108
assert np.array_equal(fill_flag, OUT_FILL_FLAG)
89-
return cloud_prop, fill_flag
90109

91110

92111
if __name__ == '__main__':

tests/test_nearest_neighbor.py

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
@author: gbuster
77
"""
88

9-
109
import numpy as np
1110
import pandas as pd
1211

@@ -21,38 +20,27 @@
2120
lat_mesh = lat_mesh.flatten()
2221
source_meta = pd.DataFrame({'latitude': lat_mesh, 'longitude': lon_mesh})
2322

24-
nsrdb_meta = pd.DataFrame(
25-
{'latitude': [1.1, 12.8, 23.3, 43.4, 44.2],
26-
'longitude': [-120.4, -112.3, -101.1, -91.3, -88.4]})
27-
28-
baseline4 = np.array([[[1, -120],
29-
[1, -121],
30-
[2, -120],
31-
[2, -121]],
32-
[[13, -112],
33-
[13, -113],
34-
[12, -112],
35-
[12, -113]],
36-
[[23, -101],
37-
[24, -101],
38-
[23, -102],
39-
[23, -100]],
40-
[[43, -91],
41-
[44, -91],
42-
[43, -92],
43-
[44, -92]],
44-
[[44, -88],
45-
[44, -89],
46-
[45, -88],
47-
[45, -89]]])
23+
nsrdb_meta = pd.DataFrame({
24+
'latitude': [1.1, 12.8, 23.3, 43.4, 44.2],
25+
'longitude': [-120.4, -112.3, -101.1, -91.3, -88.4],
26+
})
27+
28+
baseline4 = np.array([
29+
[[1, -120], [1, -121], [2, -120], [2, -121]],
30+
[[13, -112], [13, -113], [12, -112], [12, -113]],
31+
[[23, -101], [24, -101], [23, -102], [23, -100]],
32+
[[43, -91], [44, -91], [43, -92], [44, -92]],
33+
[[44, -88], [44, -89], [45, -88], [45, -89]],
34+
])
4835

4936
# calculated using Vincenty: https://www.cqsrg.org/tools/GCDistance/
50-
baseline_dist = np.array([45.873,
51-
39.365,
52-
34.766,
53-
50.688,
54-
38.983,
55-
])
37+
baseline_dist = np.array([
38+
45.873,
39+
39.365,
40+
34.766,
41+
50.688,
42+
38.983,
43+
])
5644

5745

5846
def test_geo_haversine_nn():
@@ -63,20 +51,19 @@ def test_geo_haversine_nn():
6351
result = np.allclose(baseline4, coords_closest)
6452
msg = 'Haversine NN failed!'
6553
assert result, msg
66-
return coords_closest
6754

6855

6956
def test_geo_haversine_dist():
7057
"""Test the geographic haversine nearest neighbor."""
7158

72-
dist, ind = geo_nn(source_meta, nsrdb_meta, k=1)
59+
dist, _ = geo_nn(source_meta, nsrdb_meta, k=1)
7360
dist = dist.flatten()
7461
result = np.allclose(baseline_dist, dist, rtol=0.01, atol=0.0)
7562
diff = np.abs(baseline_dist - dist)
76-
msg = ('Haversine distance failed! '
77-
'\nDist: \n{}\nDiff:\n{}'.format(dist, diff))
63+
msg = 'Haversine distance failed! ' '\nDist: \n{}\nDiff:\n{}'.format(
64+
dist, diff
65+
)
7866
assert result, msg
79-
return dist
8067

8168

8269
def test_knn():
@@ -87,7 +74,6 @@ def test_knn():
8774
result = np.allclose(baseline4, coords_closest)
8875
msg = 'KNN failed!'
8976
assert result, msg
90-
return coords_closest
9177

9278

9379
def test_regular_grid_nn():
@@ -98,7 +84,6 @@ def test_regular_grid_nn():
9884
coords_closest_knn = source_meta.values[ind]
9985
msg = 'Regular grid NN failed!'
10086
assert np.allclose(coords_closest_knn, coords_closest_reg), msg
101-
return coords_closest_reg
10287

10388

10489
if __name__ == '__main__':

0 commit comments

Comments
 (0)