Skip to content

Commit 36d7f46

Browse files
committed
passing tests.
1 parent 573b656 commit 36d7f46

File tree

1 file changed

+8
-30
lines changed

1 file changed

+8
-30
lines changed

openet/ssebop/image.py

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -644,11 +644,10 @@ def anomalous_landcover_mask(self):
644644

645645
@lazy_property
646646
def mixed_landscape_tcorr_smooth(self):
647-
"""TODO: Write a description for this function"""
647+
"""Here we take 4800m coarse tcorr in ag areas and smooth it. Fill it with a scene-wide tcorr."""
648648

649649
smooth_mixed_landscape_pre = (
650650
self.Tc_coarse_high_ndvi
651-
# CGM - Is this reproject needed?
652651
.focalMean(1, 'square', 'pixels')
653652
.reproject(self.crs, self.coarse_transform)
654653
.rename('lst')
@@ -657,16 +656,14 @@ def mixed_landscape_tcorr_smooth(self):
657656

658657
smooth_filled_pre = (
659658
smooth_mixed_landscape_pre
660-
.unmask(self.Tc_scene)
659+
.unmask(self.Tc_scene) # here we add the scene-wide constant.
661660
.reproject(self.crs, self.coarse_transform)
662661
.updateMask(1)
663662
)
664663

665664
# double smooth to increase area...
666665
smooth_filled = (
667666
smooth_filled_pre
668-
# CGM - Is this reproject needed?
669-
# .reproject(self.crs, self.coarse_transform)
670667
.focalMean(1, 'square', 'pixels')
671668
.reproject(self.crs, self.coarse_transform)
672669
.rename('lst')
@@ -1069,28 +1066,24 @@ def tcorr_FANO(self):
10691066
.updateMask(not_water_mask)
10701067
)
10711068

1072-
# Note LST is not smoothed.
1069+
# Mask LST in the same way
10731070
lst_masked = lst.updateMask(not_water_mask)
10741071

10751072
# ================= LANDCOVER LAZY Property creates ag_lc ==================
10761073

1077-
# Ag lands and grasslands and wetlands are 1, all others are 0
1074+
# Agricultural lands and grasslands and wetlands are 1, all others are 0
10781075
ag_lc = self.ag_landcover
10791076

10801077
# -------- Fine NDVI and LST (watermasked always)-------------
10811078
# Fine resolution Tcorr for areas that are natively high NDVI and hot-dry landcovers (not ag)
10821079
ndvi_fine_wmasked = (
10831080
ndvi_masked
1084-
# CGM - Is this reproject needed?
1085-
#.reproject(self.crs, self.transform)
10861081
.reduceResolution(ee.Reducer.mean(), True, m_pixels_fine)
10871082
.reproject(self.crs, fine_transform)
10881083
.updateMask(1)
10891084
)
10901085
lst_fine_wmasked = (
10911086
lst_masked
1092-
# CGM - Is this reproject needed?
1093-
#.reproject(self.crs, self.transform)
10941087
.reduceResolution(ee.Reducer.mean(), True, m_pixels_fine)
10951088
.reproject(self.crs, fine_transform)
10961089
.updateMask(1)
@@ -1114,17 +1107,6 @@ def tcorr_FANO(self):
11141107
.reproject(self.crs, self.coarse_transform)
11151108
)
11161109

1117-
# TODO: Test out commenting out reproject here?
1118-
# Here we don't need the reproject.reduce.reproject sandwich bc these are coarse data-sets
1119-
dt_fine = (
1120-
dt
1121-
)
1122-
dt_coarse = (
1123-
dt
1124-
)
1125-
tmax_avg = (
1126-
tmax
1127-
)
11281110

11291111
## =======================================================================================
11301112
## FANO TCORR
@@ -1135,15 +1117,15 @@ def tcorr_FANO(self):
11351117
'(lst - (dt_coeff * dt * (ndvi_threshold - ndvi) * 10))',
11361118
{
11371119
'dt_coeff': dt_coeff, 'ndvi_threshold': high_ndvi_threshold,
1138-
'ndvi': ndvi_fine_wmasked, 'dt': dt_fine, 'lst': lst_fine_wmasked,
1120+
'ndvi': ndvi_fine_wmasked, 'dt': dt, 'lst': lst_fine_wmasked,
11391121
}
11401122
)
11411123

11421124
self.Tc_coarse_high_ndvi = lst_coarse_wmasked_high_ndvi.expression(
11431125
'(lst - (dt_coeff * dt * (ndvi_threshold - ndvi) * 10))',
11441126
{
11451127
'dt_coeff': dt_coeff, 'ndvi_threshold': high_ndvi_threshold,
1146-
'ndvi': coarse_masked_ndvi, 'dt': dt_coarse,
1128+
'ndvi': coarse_masked_ndvi, 'dt': dt,
11471129
'lst': lst_coarse_wmasked_high_ndvi,
11481130
}
11491131
).updateMask(1)
@@ -1162,18 +1144,13 @@ def tcorr_FANO(self):
11621144
vegetated_mask = ndvi_fine_wmasked.gte(0.4).And(ag_lc)
11631145

11641146
# for 120m Ag areas with enough NDVI to run FANO
1165-
# # CGM - Commented out
11661147
self.vegetated_tcorr = (
11671148
Tc_fine.updateMask(vegetated_mask)
1168-
# CGM - Is this reproject needed?
1169-
#.reproject(self.crs, fine_transform)
11701149
)
11711150

11721151
# for all non-ag areas we run hot dry tcorr at 120m
11731152
self.hot_dry_tcorr = (
11741153
Tc_fine
1175-
# CGM - Is this reproject needed?
1176-
#.reproject(self.crs, fine_transform)
11771154
)
11781155

11791156
## ---------- Smoothing the FANO for Ag together starting with mixed landscape -------
@@ -1185,6 +1162,7 @@ def tcorr_FANO(self):
11851162
# The main Tc where we make use of landcovers
11861163
Tc_Layered = self.tc_layered
11871164

1165+
# 1 pixel of smoothing.
11881166
self.smooth_Tc_Layered = (
11891167
Tc_Layered
11901168
.focalMean(1, 'square', 'pixels')
@@ -1203,7 +1181,7 @@ def tcorr_FANO(self):
12031181
)
12041182

12051183
# obviated, now that we are at 120m resolution, but carry on to avoid a major code refactor while testing.
1206-
c_factor = Tc_cold.divide(tmax_avg)
1184+
c_factor = Tc_cold.divide(tmax)
12071185

12081186
return (
12091187
c_factor.rename(['tcorr'])

0 commit comments

Comments
 (0)