Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 22, 2024
1 parent b8f77e5 commit f3e776c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 23 deletions.
10 changes: 3 additions & 7 deletions odc/stats/plugins/l34_utils/l4_cultivated.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def lc_l4_cultivated(l34, level3, woody, veg_cover):

woody = expr_eval(
"where((a!=a), nodata, a)",
{"a": woody.data},
Expand All @@ -13,7 +13,7 @@ def lc_l4_cultivated(l34, level3, woody, veg_cover):
**{"nodata": NODATA},
)

# the 4-8 classes can't happen in LC since cultivated class will not be classified if vegetation doesn't exist.
# the 4-8 classes can't happen in LC since cultivated class will not be classified if vegetation doesn't exist.
# skip these classes in level4
l4 = expr_eval(
"where((a==111), 1, d)",
Expand Down Expand Up @@ -42,7 +42,7 @@ def lc_l4_cultivated(l34, level3, woody, veg_cover):
name="mark_cultivated",
dtype="uint8",
)

l4 = expr_eval(
"where((a==111)&(b==12)&(c==113), 10, d)",
{"a": level3, "b": veg_cover, "c": woody, "d": l4},
Expand Down Expand Up @@ -101,8 +101,4 @@ def lc_l4_cultivated(l34, level3, woody, veg_cover):
dtype="uint8",
)





return l4
8 changes: 3 additions & 5 deletions odc/stats/plugins/l34_utils/l4_natural_veg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ def lc_l4_natural_veg(l4, l3, woody, veg_cover):
dtype="float32",
**{"nodata": NODATA},
)

l4 = expr_eval(
"where((b==nodata), nodata, a)",
{"a": l4, "b": l3},
name="mark_cultivated",
dtype="uint8",
**{"nodata": NODATA},
)

l4 = expr_eval(
"where((a==112), 19, d)",
{"a": l3, "d": l4},
name="mark_cultivated",
dtype="uint8",
)

l4 = expr_eval(
"where((a==112)&(b==113), 20, d)",
{"a": l3, "b": woody, "d": l4},
Expand Down Expand Up @@ -137,6 +137,4 @@ def lc_l4_natural_veg(l4, l3, woody, veg_cover):
dtype="uint8",
)



return l4
2 changes: 1 addition & 1 deletion odc/stats/plugins/l34_utils/l4_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ def lc_l4_surface(l4, level3, bare_gradation):
name="mark_surface",
dtype="uint8",
)

return l4
3 changes: 1 addition & 2 deletions odc/stats/plugins/l34_utils/l4_water.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

def water_classification(xx, water_persistence):


# Replace nan with nodata
l4 = expr_eval(
"where((a==a), a, nodata)",
Expand All @@ -14,7 +13,7 @@ def water_classification(xx, water_persistence):
dtype="uint8",
**{"nodata": NODATA},
)

intertidal_mask = expr_eval(
"where(a==_u, 1, 0)",
{"a": l4},
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lc_l4_ctv.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ def test_ctv_classes_no_vegcover():

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

veg_cover = l4_veg_cover.canopyco_veg_con(xx, stats_l4.veg_threshold)
l4_ctv = l4_cultivated.lc_l4_cultivated(xx.level_3_4, level3, xx.woody, veg_cover)

assert (l4_ctv.compute() == expected_cultivated_classes).all()
8 changes: 2 additions & 6 deletions tests/test_lc_l4_water.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ def test_water_classes():
xx, stats_l4.watper_threshold
)

l4_water_classes = l4_water.water_classification(
xx, water_persistence
)
l4_water_classes = l4_water.water_classification(xx, water_persistence)

assert (l4_water_classes.compute() == expected_water_classes).all()

Expand Down Expand Up @@ -276,8 +274,6 @@ def test_water_intertidal():
xx, stats_l4.watper_threshold
)

l4_water_classes = l4_water.water_classification(
xx, water_persistence
)
l4_water_classes = l4_water.water_classification(xx, water_persistence)

assert (l4_water_classes.compute() == expected_water_classes).all()

0 comments on commit f3e776c

Please sign in to comment.