Skip to content

Commit 93dfded

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 055cbfa commit 93dfded

File tree

8 files changed

+47
-47
lines changed

8 files changed

+47
-47
lines changed

odc/stats/plugins/l34_utils/l4_natural_aquatic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
NODATA = 255
88

9+
910
def natural_auquatic_veg(l4, veg_cover, water_season):
1011

1112
# mark woody/herbaceous
@@ -19,9 +20,9 @@ def natural_auquatic_veg(l4, veg_cover, water_season):
1920
},
2021
name="mark_water_season",
2122
dtype="float32",
22-
**{"nodata": NODATA},
23+
**{"nodata": NODATA},
2324
)
24-
25+
2526
res = expr_eval(
2627
"where((a==124), 56, a)",
2728
{
@@ -283,7 +284,7 @@ def natural_auquatic_veg(l4, veg_cover, water_season):
283284
name="mark_final",
284285
dtype="uint8",
285286
)
286-
287+
287288
res = expr_eval(
288289
"where((a==251)&(b==16), 92, a)",
289290
{
@@ -294,7 +295,7 @@ def natural_auquatic_veg(l4, veg_cover, water_season):
294295
dtype="uint8",
295296
)
296297

297-
# There are cases where a tile falls over water.
298+
# There are cases where a tile falls over water.
298299
# In these cases, the PC will have no data so we map back 251-254 to their corresponding classes
299300
res = expr_eval(
300301
"where((a>=251)&(a<=252), 57, a)",
@@ -312,6 +313,5 @@ def natural_auquatic_veg(l4, veg_cover, water_season):
312313
name="mark_final",
313314
dtype="uint8",
314315
)
315-
316316

317317
return res

odc/stats/plugins/l34_utils/l4_veg_cover.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
def canopyco_veg_con(xx: xr.Dataset, veg_threshold):
99

10-
1110
# Mask NODATA
1211
pv_pc_50 = expr_eval(
1312
"where(a==a, a, nodata)",

odc/stats/plugins/l34_utils/l4_water.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,24 @@ def water_classification(xx, intertidal_mask, water_persistence):
77

88
# Replace nan with nodata
99
l4 = expr_eval(
10-
"where((a==a), a, nodata)",
11-
{"a": xx.level_3_4.data},
12-
name="mark_water",
13-
dtype="uint8",
14-
**{"nodata": NODATA},
10+
"where((a==a), a, nodata)",
11+
{"a": xx.level_3_4.data},
12+
name="mark_water",
13+
dtype="uint8",
14+
**{"nodata": NODATA},
1515
)
1616

1717
l4 = expr_eval(
18-
"where((a==223)|(a==221), 98, a)",
19-
{"a": l4},
20-
name="mark_water",
21-
dtype="uint8"
18+
"where((a==223)|(a==221), 98, a)", {"a": l4}, name="mark_water", dtype="uint8"
2219
)
23-
20+
2421
l4 = expr_eval(
2522
"where((a==98)&(b!=1), 99, a)",
2623
{"a": l4, "b": intertidal_mask},
2724
name="mark_water",
2825
dtype="uint8",
2926
)
30-
27+
3128
l4 = expr_eval(
3229
"where((a==98)&(b==1), 100, a)",
3330
{"a": l4, "b": intertidal_mask},

odc/stats/plugins/lc_level34.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
NODATA = 255
2828

29+
2930
class StatsLccsLevel4(StatsPluginInterface):
3031
NAME = "ga_ls_lccs_Level34"
3132
SHORT_NAME = NAME
@@ -48,7 +49,6 @@ def __init__(
4849
self.watper_threshold = (
4950
watper_threshold if watper_threshold is not None else [1, 4, 7, 10]
5051
)
51-
5252

5353
def fuser(self, xx):
5454
return xx
@@ -59,15 +59,15 @@ def reduce(self, xx: xr.Dataset) -> xr.Dataset:
5959
water_persistence = l4_water_persistence.water_persistence(
6060
xx, self.watper_threshold
6161
)
62-
62+
6363
intertidal_mask = lc_intertidal_mask.intertidal_mask(xx)
6464

6565
# #TODO WATER (99-104)
6666
l4 = l4_water.water_classification(xx, intertidal_mask, water_persistence)
6767

6868
# Generate Level3 classes
6969
level3 = lc_level3.lc_level3(xx)
70-
70+
7171
# Vegetation cover
7272
veg_cover = l4_veg_cover.canopyco_veg_con(xx, self.veg_threshold)
7373

@@ -79,7 +79,7 @@ def reduce(self, xx: xr.Dataset) -> xr.Dataset:
7979

8080
# Apply terrestrial vegetation classes [19-36]
8181
l4 = l4_natural_veg.lc_l4_natural_veg(l4, level3, lifeform, veg_cover)
82-
82+
8383
# Bare gradation
8484
bare_gradation = l4_bare_gradation.bare_gradation(
8585
xx, self.bare_threshold, veg_cover
@@ -91,7 +91,7 @@ def reduce(self, xx: xr.Dataset) -> xr.Dataset:
9191

9292
level3 = level3.astype(np.uint8)
9393
level4 = level4.astype(np.uint8)
94-
94+
9595
attrs = xx.attrs.copy()
9696
attrs["nodata"] = NODATA
9797
dims = xx.level_3_4.dims[1:]
@@ -105,4 +105,4 @@ def reduce(self, xx: xr.Dataset) -> xr.Dataset:
105105
return leve34
106106

107107

108-
register("lc_l3_l4", StatsLccsLevel4)
108+
register("lc_l3_l4", StatsLccsLevel4)

tests/test_lc_l34.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def image_groups():
168168
def test_l4_classes(image_groups):
169169
expected_l3 = [[216, 216, 215], [216, 216, 216], [220, 215, 215], [220, 220, 220]]
170170

171-
expected_l4 = [[ 95, 97, 93], [97, 96, 96], [100, 93, 93], [101, 101, 101]]
171+
expected_l4 = [[95, 97, 93], [97, 96, 96], [100, 93, 93], [101, 101, 101]]
172172
stats_l4 = StatsLccsLevel4(measurements=["level3", "level4"])
173173
ds = stats_l4.reduce(image_groups)
174174

tests/test_lc_l4_natural_surface.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
NODATA = 255
2424

2525

26-
def image_groups(l34, urban, woody, bs_pc_50, pv_pc_50, cultivated, water_frequency, water_season):
26+
def image_groups(
27+
l34, urban, woody, bs_pc_50, pv_pc_50, cultivated, water_frequency, water_season
28+
):
2729

2830
tuples = [
2931
(np.datetime64("2000-01-01T00"), np.datetime64("2000-01-01")),
@@ -70,7 +72,7 @@ def image_groups(l34, urban, woody, bs_pc_50, pv_pc_50, cultivated, water_freque
7072
dims=("spec", "y", "x"),
7173
attrs={"nodata": 255},
7274
),
73-
"water_season": xr.DataArray(
75+
"water_season": xr.DataArray(
7476
da.from_array(water_season, chunks=(1, -1, -1)),
7577
dims=("spec", "y", "x"),
7678
attrs={"nodata": 255},

tests/test_lc_l4_nav.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
NODATA = 255
2222

2323

24-
def image_groups(l34, urban, cultivated, woody, pv_pc_50, water_frequency, water_season):
24+
def image_groups(
25+
l34, urban, cultivated, woody, pv_pc_50, water_frequency, water_season
26+
):
2527

2628
tuples = [
2729
(np.datetime64("2000-01-01T00"), np.datetime64("2000-01-01")),
@@ -63,7 +65,7 @@ def image_groups(l34, urban, cultivated, woody, pv_pc_50, water_frequency, water
6365
dims=("spec", "y", "x"),
6466
attrs={"nodata": 255},
6567
),
66-
"water_season":xr.DataArray(
68+
"water_season": xr.DataArray(
6769
da.from_array(water_season, chunks=(1, -1, -1)),
6870
dims=("spec", "y", "x"),
6971
attrs={"nodata": 255},
@@ -148,7 +150,7 @@ def test_ntv_classes_woody_herbaceous():
148150
],
149151
dtype="uint8",
150152
)
151-
153+
152154
water_season = np.array(
153155
[
154156
[
@@ -161,7 +163,9 @@ def test_ntv_classes_woody_herbaceous():
161163
dtype="uint8",
162164
)
163165

164-
xx = image_groups(l34, urban, cultivated, woody, pv_pc_50, water_frequency, water_season)
166+
xx = image_groups(
167+
l34, urban, cultivated, woody, pv_pc_50, water_frequency, water_season
168+
)
165169

166170
stats_l4 = StatsLccsLevel4()
167171
level3 = lc_level3.lc_level3(xx)
@@ -245,7 +249,6 @@ def test_ntv_herbaceous_seasonal_water_veg_cover():
245249
]
246250
],
247251
dtype="uint8",
248-
249252
)
250253
water_frequency = np.array(
251254
[
@@ -258,7 +261,7 @@ def test_ntv_herbaceous_seasonal_water_veg_cover():
258261
],
259262
dtype="uint8",
260263
)
261-
264+
262265
water_season = np.array(
263266
[
264267
[
@@ -271,7 +274,9 @@ def test_ntv_herbaceous_seasonal_water_veg_cover():
271274
dtype="uint8",
272275
)
273276

274-
xx = image_groups(l34, urban, cultivated, woody, pv_pc_50, water_frequency, water_season)
277+
xx = image_groups(
278+
l34, urban, cultivated, woody, pv_pc_50, water_frequency, water_season
279+
)
275280

276281
stats_l4 = StatsLccsLevel4()
277282
level3 = lc_level3.lc_level3(xx)
@@ -285,7 +290,7 @@ def test_ntv_herbaceous_seasonal_water_veg_cover():
285290
l4_ctv_ntv_nav = l4_natural_aquatic.natural_auquatic_veg(
286291
l4_ctv_ntv, veg_cover, xx.water_season
287292
)
288-
293+
289294
assert (l4_ctv_ntv_nav.compute() == expected_l4_ntv_classes).all()
290295

291296

@@ -356,7 +361,7 @@ def test_ntv_woody_seasonal_water_veg_cover():
356361
],
357362
dtype="uint8",
358363
)
359-
364+
360365
water_frequency = np.array(
361366
[
362367
[
@@ -368,7 +373,7 @@ def test_ntv_woody_seasonal_water_veg_cover():
368373
],
369374
dtype="uint8",
370375
)
371-
376+
372377
water_season = np.array(
373378
[
374379
[
@@ -380,7 +385,9 @@ def test_ntv_woody_seasonal_water_veg_cover():
380385
],
381386
dtype="uint8",
382387
)
383-
xx = image_groups(l34, urban, cultivated, woody, pv_pc_50, water_frequency, water_season)
388+
xx = image_groups(
389+
l34, urban, cultivated, woody, pv_pc_50, water_frequency, water_season
390+
)
384391

385392
stats_l4 = StatsLccsLevel4()
386393
level3 = lc_level3.lc_level3(xx)

tests/test_lc_l4_water.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,7 @@ def image_groups(l34, urban, cultivated, woody, bs_pc_50, pv_pc_50, water_freque
7474

7575
def test_water_classes():
7676
expected_water_classes = [
77-
[
78-
[104, 104, 104],
79-
[103, 103, 103],
80-
[102, 102, 101],
81-
[99, 101, 101]
82-
],
77+
[[104, 104, 104], [103, 103, 103], [102, 102, 101], [99, 101, 101]],
8378
]
8479

8580
l34 = np.array(
@@ -185,10 +180,10 @@ def test_water_classes():
185180
def test_water_intertidal():
186181

187182
expected_water_classes = [
188-
[100, 100, 100],
189-
[100, 100, 100],
190-
[102, 102, 101],
191-
[101, 99, 100],
183+
[100, 100, 100],
184+
[100, 100, 100],
185+
[102, 102, 101],
186+
[101, 99, 100],
192187
]
193188

194189
l34 = np.array(

0 commit comments

Comments
 (0)