-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
52a9fc5
commit 9a6c987
Showing
18 changed files
with
730 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
|
||
import xarray as xr | ||
from odc.stats._algebra import expr_eval | ||
|
||
NODATA = 255 | ||
|
||
|
||
def bare_gradation(xx: xr.Dataset, bare_threshold, veg_cover): | ||
|
||
# Now add the bare gradation | ||
fcp_nodaata = -999 | ||
bs_mask = expr_eval( | ||
"where(a!=nodata, a, NODATA)", | ||
{"a": xx.bs_pc_50.data}, | ||
name="mark_nodata", | ||
dtype="uint8", | ||
**{"nodata": fcp_nodaata, "NODATA": NODATA}, | ||
) | ||
|
||
# Map any data > 100 ---> 100 | ||
bs_mask = expr_eval( | ||
"where((a>100)&(a!=nodata), 100, a)", | ||
{"a": bs_mask}, | ||
name="mark_veg", | ||
dtype="uint8", | ||
**{"nodata": NODATA}, | ||
) | ||
|
||
# 60% <= data --> 15(0) | ||
bs_mask = expr_eval( | ||
"where((a>=m)&(a!=nodata), 150, a)", | ||
{"a": bs_mask}, | ||
name="mark_veg", | ||
dtype="uint8", | ||
**{"m": bare_threshold[1], "nodata": NODATA}, | ||
) | ||
|
||
# 20% <= data < 60% --> 12(0) | ||
bs_mask = expr_eval( | ||
"where((a>=m)&(a<n), 120, a)", | ||
{"a": bs_mask}, | ||
name="mark_veg", | ||
dtype="uint8", | ||
**{"m": bare_threshold[0], "n": bare_threshold[1]}, | ||
) | ||
|
||
# data < 20% --> 10(0) | ||
bs_mask = expr_eval( | ||
"where(a<m, 100, a)", | ||
{"a": bs_mask}, | ||
name="mark_veg", | ||
dtype="uint8", | ||
**{"m": bare_threshold[0]}, | ||
) | ||
return bs_mask | ||
# Now add the bare gradation | ||
fcp_nodaata = -999 | ||
bs_mask = expr_eval( | ||
"where(a!=nodata, a, NODATA)", | ||
{"a": xx.bs_pc_50.data}, | ||
name="mark_nodata", | ||
dtype="uint8", | ||
**{"nodata": fcp_nodaata, "NODATA": NODATA}, | ||
) | ||
|
||
# Map any data > 100 ---> 100 | ||
bs_mask = expr_eval( | ||
"where((a>100)&(a!=nodata), 100, a)", | ||
{"a": bs_mask}, | ||
name="mark_veg", | ||
dtype="uint8", | ||
**{"nodata": NODATA}, | ||
) | ||
|
||
# 60% <= data --> 15(0) | ||
bs_mask = expr_eval( | ||
"where((a>=m)&(a!=nodata), 150, a)", | ||
{"a": bs_mask}, | ||
name="mark_veg", | ||
dtype="uint8", | ||
**{"m": bare_threshold[1], "nodata": NODATA}, | ||
) | ||
|
||
# 20% <= data < 60% --> 12(0) | ||
bs_mask = expr_eval( | ||
"where((a>=m)&(a<n), 120, a)", | ||
{"a": bs_mask}, | ||
name="mark_veg", | ||
dtype="uint8", | ||
**{"m": bare_threshold[0], "n": bare_threshold[1]}, | ||
) | ||
|
||
# data < 20% --> 10(0) | ||
bs_mask = expr_eval( | ||
"where(a<m, 100, a)", | ||
{"a": bs_mask}, | ||
name="mark_veg", | ||
dtype="uint8", | ||
**{"m": bare_threshold[0]}, | ||
) | ||
|
||
return bs_mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.