Skip to content

Commit

Permalink
Applied more code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
tebadi committed Nov 22, 2024
1 parent f3e776c commit 5458aae
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 189 deletions.
14 changes: 4 additions & 10 deletions odc/stats/plugins/l34_utils/l4_cultivated.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@ 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.
# skip these classes in level4
l4 = expr_eval(
"where((a==111), 1, d)",
{"a": level3, "d": l34},
name="mark_cultivated",
dtype="uint8",
)

l4 = expr_eval(
"where((a==111)&(b==113), 2, d)",
{"a": level3, "b": woody, "d": l4},
{"a": level3, "b": woody, "d": l34},
name="mark_cultivated",
dtype="uint8",
)
Expand All @@ -36,6 +27,9 @@ def lc_l4_cultivated(l34, level3, woody, veg_cover):
dtype="uint8",
)

# 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)&(b==10)&(c==113), 9, d)",
{"a": level3, "b": veg_cover, "c": woody, "d": l4},
Expand Down
7 changes: 0 additions & 7 deletions odc/stats/plugins/l34_utils/l4_natural_veg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ def lc_l4_natural_veg(l4, l3, woody, veg_cover):
**{"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
18 changes: 6 additions & 12 deletions odc/stats/plugins/l34_utils/l4_water.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,24 @@ def water_classification(xx, water_persistence):
**{"nodata": NODATA},
)

intertidal_mask = expr_eval(
"where(a==_u, 1, 0)",
{"a": l4},
name="mask_intertidal",
dtype="uint8",
**{"_u": 223},
)

l4 = expr_eval(
"where((a==223)|(a==221), 98, a)", {"a": l4}, name="mark_water", dtype="uint8"
)

l4 = expr_eval(
"where((a==98)&(b!=1), 99, a)",
{"a": l4, "b": intertidal_mask},
"where((a==98)&(b!=_u), 99, a)",
{"a": l4, "b": xx.level_3_4.data},
name="mark_water",
dtype="uint8",
**{"_u": 223},
)

l4 = expr_eval(
"where((a==98)&(b==1), 100, a)",
{"a": l4, "b": intertidal_mask},
"where((a==98)&(b==_u), 100, a)",
{"a": l4, "b": xx.level_3_4.data},
name="mark_water",
dtype="uint8",
**{"_u": 223},
)

l4 = expr_eval(
Expand Down
1 change: 0 additions & 1 deletion tests/test_lc_l4_natural_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import xarray as xr
import dask.array as da

from odc.stats.plugins.lc_level34 import StatsLccsLevel4
from odc.stats.plugins.l34_utils import (
l4_cultivated,
lc_level3,
Expand Down
159 changes: 0 additions & 159 deletions tests/test_lc_water_seasonality.py

This file was deleted.

0 comments on commit 5458aae

Please sign in to comment.