Skip to content

Commit 9e90c21

Browse files
LaurenSchenk1colourmeamused
authored andcommitted
Documenting WIT ls9
1 parent 032523c commit 9e90c21

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

examples/wit_ls9.conflux.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
output_crs = "EPSG:3577"
1515
resolution = (-30, 30)
1616

17+
# load Water Observations, Landsat 9 and Fractional Cover data
1718
input_products = {
1819
"ga_ls_wo_3": ["water"],
1920
"ga_ls9c_ard_3": [
@@ -52,28 +53,37 @@ def transform(inputs: xr.Dataset) -> xr.Dataset:
5253

5354
tcw = _tcw(ard_ds)
5455

56+
# divide FC values by 100 to keep them in [0, 1]
5557
bs = fc_ds.bs / 100
5658
pv = fc_ds.pv / 100
5759
npv = fc_ds.npv / 100
5860

61+
# generate the WIT raster bands
62+
# create an empty dataset called 'output_rast' and populate with values from input datasets
5963
rast_names = ["pv", "npv", "bs", "wet", "water"]
6064
output_rast = {n: xr.zeros_like(ard_ds) for n in rast_names}
6165

6266
output_rast["bs"] = bs
6367
output_rast["pv"] = pv
6468
output_rast["npv"] = npv
6569

70+
# Mask noncontiguous data, low solar incidence angle, cloud, and water out of the wet category
71+
# by disabling those flags
6672
mask = (wo_ds.water & 0b01100011) == 0
6773
# not apply poly_raster cause we will do it before summarise
6874

6975
open_water = wo_ds.water & (1 << 7) > 0
76+
77+
# Thresholding
78+
# set wet pixels where not masked and above threshold of -350
7079
wet = tcw.where(mask) > -350
7180

7281
# TCW
7382
output_rast["wet"] = wet.astype(float)
7483
for name in rast_names[:3]:
7584
output_rast[name].values[wet.values] = 0
7685

86+
# WO
7787
output_rast["water"] = open_water.astype(float)
7888

7989
for name in rast_names[0:4]:
@@ -82,13 +92,15 @@ def transform(inputs: xr.Dataset) -> xr.Dataset:
8292
# save this mask then can do 90% check in summarise
8393
output_rast["mask"] = (mask).astype(int)
8494

95+
# masking
8596
ds_wit = xr.Dataset(output_rast).where(mask)
8697

8798
return ds_wit
8899

89100

90101
def summarise(inputs: xr.Dataset) -> xr.Dataset:
91102

103+
# calculate percentage missing
92104
pc_missing = 1 - (np.nansum(inputs.mask.values) / len(inputs.mask.values))
93105
# inputs = inputs.where(pc_missing < 0.1)
94106

0 commit comments

Comments
 (0)