Skip to content

Commit 72da4dc

Browse files
committed
fix conflict
2 parents 6589cfd + 645d6cc commit 72da4dc

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

docs/config_ndvi_ls_median.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ cog_opts:
3030
# If you're making an RGBA image, compress better
3131
rgba:
3232
compress: JPEG
33-
jpeg_quality: 90
33+
jpeg_quality: 90

odc/stats/plugins/ls_ndvi_median.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Simple odc-stats plugin example, with excessive
33
documentation. Creates temporal median NDVI
44
from DEA Landsat Collection 3
5-
5+
66
"""
77

88
import xarray as xr
@@ -14,11 +14,13 @@
1414
enum_to_bool
1515
)
1616

17+
1718
class StatsNDVI(StatsPluginInterface):
1819
"""
19-
Define a class for summarising time
20+
Define a class for summarising time
2021
series of NDVI using the median.
2122
"""
23+
2224
NAME = "ndvi_median"
2325
SHORT_NAME = NAME
2426
VERSION = "1.0"
@@ -33,21 +35,24 @@ def __init__(
3335
group_by: str = "solar_day",
3436
**kwargs,
3537
):
36-
38+
3739
self.input_bands = input_bands
3840
self.output_bands = output_bands
3941
self.mask_band = mask_band
4042
self.contiguity_band = contiguity_band
4143
self.group_by = group_by
4244

45+
<<<<<<< HEAD
4346
# These params get passed to the upstream
4447
# base class StatsPluginInterface
48+
=======
49+
## These params get passed to the upstream
50+
# base StatsPluginInterface class
51+
>>>>>>> refs/remotes/origin/plugin_documentation
4552
super().__init__(
46-
input_bands=tuple(input_bands)+(mask_band,)+(contiguity_band,),
47-
**kwargs
53+
input_bands=tuple(input_bands) + (mask_band,) + (contiguity_band,), **kwargs
4854
)
4955

50-
5156
@property
5257
def measurements(self) -> Tuple[str, ...]:
5358
"""
@@ -56,7 +61,7 @@ def measurements(self) -> Tuple[str, ...]:
5661
but equally we could define the outputs ames within this function.
5762
For example, by adding a suffix to the input bands.
5863
"""
59-
64+
6065
return (self.output_bands,)
6166

6267
def native_transform(self, xx):
@@ -67,22 +72,27 @@ def native_transform(self, xx):
6772
step of data and is usually used for things like
6873
masking clouds, nodata, and contiguity masking.
6974
"""
70-
#grab the QA band from the Landsat data
75+
# grab the QA band from the Landsat data
7176
mask = xx[self.mask_band]
7277

7378
# create boolean arrays from the mask for cloud
7479
# and cloud shadows, and nodata
7580
bad = enum_to_bool(mask, ("nodata",))
7681
non_contiguent = xx.get(self.contiguity_band, 1) == 0
7782
bad = bad | non_contiguent
78-
83+
7984
cloud_mask = enum_to_bool(mask, ("cloud", "shadow"))
80-
bad = cloud_mask | bad
85+
bad = cloud_mask | bad
8186

8287
# drop masking bands
8388
xx = xx.drop_vars([self.mask_band] + [self.contiguity_band])
89+
<<<<<<< HEAD
8490

8591
# Mask the bad data (clouds etc)
92+
=======
93+
94+
## Mask the bad data (clouds etc)
95+
>>>>>>> refs/remotes/origin/plugin_documentation
8696
xx = erase_bad(xx, bad)
8797

8898
return xx
@@ -93,14 +103,24 @@ def reduce(self, xx: xr.Dataset) -> xr.Dataset:
93103
"""
94104
# convert to float by and convert nodata to NaN
95105
xx = mask_invalid_data(xx)
96-
97-
ndvi = (xx['nbart_nir'] - xx['nbart_red']) / (xx['nbart_nir'] + xx['nbart_red'])
98106

107+
<<<<<<< HEAD
99108
# calculate temporal median NDVI. Note that we use
100109
# 'spec' and not 'time', this is an odc-stats thing
101110
ndvi = ndvi.median('spec').rename(self.output_bands)
102111

112+
=======
113+
ndvi = (xx["nbart_nir"] - xx["nbart_red"]) / (xx["nbart_nir"] + xx["nbart_red"])
114+
115+
# calculate temporal median NDVI.
116+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!
117+
# Note that we use 'spec' and not 'time', this is an odc-stats thing
118+
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!
119+
ndvi = ndvi.median("spec").rename(self.output_bands)
120+
121+
>>>>>>> refs/remotes/origin/plugin_documentation
103122
return ndvi.to_dataset()
104123

124+
105125
# now lets 'register' the function with odc-stats
106126
register("ndvi-median", StatsNDVI)

0 commit comments

Comments
 (0)