9
9
from typing import Sequence , Tuple
10
10
from datacube .utils .masking import mask_invalid_data
11
11
from odc .stats .plugins ._registry import register , StatsPluginInterface
12
- from odc .algo ._masking import (
13
- erase_bad ,
14
- enum_to_bool
15
- )
16
-
12
+ from odc .algo ._masking import erase_bad , enum_to_bool
17
13
18
14
class StatsNDVI (StatsPluginInterface ):
19
15
"""
@@ -42,13 +38,8 @@ def __init__(
42
38
self .contiguity_band = contiguity_band
43
39
self .group_by = group_by
44
40
45
- < << << << HEAD
46
- # These params get passed to the upstream
47
- # base class StatsPluginInterface
48
- == == == =
49
- ## These params get passed to the upstream
41
+ # These params get passed to the upstream
50
42
# base StatsPluginInterface class
51
- >> >> >> > refs / remotes / origin / plugin_documentation
52
43
super ().__init__ (
53
44
input_bands = tuple (input_bands ) + (mask_band ,) + (contiguity_band ,), ** kwargs
54
45
)
@@ -86,13 +77,8 @@ def native_transform(self, xx):
86
77
87
78
# drop masking bands
88
79
xx = xx .drop_vars ([self .mask_band ] + [self .contiguity_band ])
89
- < << << << HEAD
90
-
91
- # Mask the bad data (clouds etc)
92
- == == == =
93
80
94
- ## Mask the bad data (clouds etc)
95
- >> >> >> > refs / remotes / origin / plugin_documentation
81
+ # Mask the bad data (clouds etc)
96
82
xx = erase_bad (xx , bad )
97
83
98
84
return xx
@@ -104,21 +90,12 @@ def reduce(self, xx: xr.Dataset) -> xr.Dataset:
104
90
# convert to float by and convert nodata to NaN
105
91
xx = mask_invalid_data (xx )
106
92
107
- < << << << HEAD
108
- # calculate temporal median NDVI. Note that we use
109
- # 'spec' and not 'time', this is an odc-stats thing
110
- ndvi = ndvi .median ('spec' ).rename (self .output_bands )
111
-
112
- == == == =
113
93
ndvi = (xx ["nbart_nir" ] - xx ["nbart_red" ]) / (xx ["nbart_nir" ] + xx ["nbart_red" ])
114
94
115
- # calculate temporal median NDVI.
116
- # !!!!!!!!!!!!!!!!!!!!!!!!!!!!
117
- # Note that we use 'spec' and not 'time', this is an odc-stats thing
118
- # !!!!!!!!!!!!!!!!!!!!!!!!!!!!
95
+ # calculate temporal median NDVI. Note that we use
96
+ # 'spec' and not 'time', this is an odc-stats thing
119
97
ndvi = ndvi .median ("spec" ).rename (self .output_bands )
120
98
121
- >> >> >> > refs / remotes / origin / plugin_documentation
122
99
return ndvi .to_dataset ()
123
100
124
101
0 commit comments