@@ -164,21 +164,6 @@ def generate_features(input_block, bands_indices):
164
164
norm , 1e-8
165
165
) # Avoid division by zero, fine if it's nan
166
166
167
- # reassemble the array
168
- output_block = np .concatenate (
169
- [output_block , input_block [..., bands_indices ["sdev" ]][..., np .newaxis ]],
170
- axis = - 1 ,
171
- ).astype ("float32" )
172
- # scale edev \in [0, 1]
173
- edev = input_block [..., bands_indices ["edev" ]] / 1e4
174
- output_block = np .concatenate (
175
- [output_block , edev [..., np .newaxis ]], axis = - 1
176
- ).astype ("float32" )
177
- output_block = np .concatenate (
178
- [output_block , input_block [..., bands_indices ["bcdev" ]][..., np .newaxis ]],
179
- axis = - 1 ,
180
- ).astype ("float32" )
181
-
182
167
feature_block = None
183
168
for f , p in zip (
184
169
[
@@ -193,15 +178,29 @@ def generate_features(input_block, bands_indices):
193
178
],
194
179
feature_input_indices ,
195
180
):
196
- ib = f (output_block [..., : bands_indices [ "nbart_swir_2" ] + 1 ] , * p )
181
+ ib = f (output_block , * p )
197
182
if feature_block is None :
198
183
feature_block = ib [..., np .newaxis ]
199
184
else :
200
185
feature_block = np .concatenate (
201
186
[feature_block , ib [..., np .newaxis ]], axis = - 1
202
187
)
203
-
188
+ # reassemble the array
189
+ output_block = np .concatenate (
190
+ [output_block , input_block [..., bands_indices ["sdev" ]][..., np .newaxis ]],
191
+ axis = - 1 ,
192
+ ).astype ("float32" )
193
+ # scale edev \in [0, 1]
194
+ edev = input_block [..., bands_indices ["edev" ]] / 1e4
195
+ output_block = np .concatenate (
196
+ [output_block , edev [..., np .newaxis ]], axis = - 1
197
+ ).astype ("float32" )
198
+ output_block = np .concatenate (
199
+ [output_block , input_block [..., bands_indices ["bcdev" ]][..., np .newaxis ]],
200
+ axis = - 1 ,
201
+ ).astype ("float32" )
204
202
output_block = np .concatenate ([output_block , feature_block ], axis = - 1 )
203
+
205
204
selected_indices = np .r_ [
206
205
[
207
206
bands_indices [k ]
@@ -288,23 +287,23 @@ def aggregate_results_from_group(self, predict_output):
288
287
predict_output = predict_output .sum (axis = 0 )
289
288
290
289
predict_output = expr_eval (
291
- "where((m/nodata)>=_l, nodata, m%nodata)" ,
290
+ "where((m/nodata)+0.5 >=_l, nodata, m%nodata)" ,
292
291
{"m" : predict_output },
293
292
name = "mark_nodata" ,
294
293
dtype = "float32" ,
295
294
** {"_l" : m_size , "nodata" : NODATA },
296
295
)
297
296
298
297
predict_output = expr_eval (
299
- "where((m>0)&(m<nodata), _u, m)" ,
298
+ "where((m>0.5 )&(m<nodata), _u, m)" ,
300
299
{"m" : predict_output },
301
300
name = "output_classes_cultivated" ,
302
301
dtype = "float32" ,
303
302
** {"_u" : self .output_classes ["cultivated" ], "nodata" : NODATA },
304
303
)
305
304
306
305
predict_output = expr_eval (
307
- "where(m<=0 , _nu, m)" ,
306
+ "where(m<0.5 , _nu, m)" ,
308
307
{"m" : predict_output },
309
308
name = "output_classes_natural" ,
310
309
dtype = "uint8" ,
0 commit comments