Skip to content

Commit de37835

Browse files
seasonal aggregates by priority by default
1 parent e074707 commit de37835

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

calvalus-processing/src/main/java/com/bc/calvalus/processing/l3/seasonal/SeasonalStatusAggregator.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public class SeasonalStatusAggregator implements TemporalAggregator {
8989
Date startDate;
9090
Date stopDate;
9191
Product primajorityStatusProduct;
92+
private boolean withMajorityStatus;
9293

9394
public void initialize(Configuration conf, Product firstInput) {
9495
sceneRasterHeight = firstInput.getSceneRasterHeight();
@@ -117,6 +118,7 @@ public void initialize(Configuration conf, Product firstInput) {
117118
throw new IllegalArgumentException("Cannot parse value of calvalus.compositing.srthreshold '" +
118119
System.getProperty("calvalus.compositing.srthreshold") + "' as a number: " + e);
119120
}
121+
withMajorityStatus = Boolean.getBoolean("calvalus.compositing.withmajoritystatus");
120122

121123
final String[] bandNames = isSyn ? SYN_BAND_NAMES : isOlci ? OLCI_BAND_NAMES : isMsi ? MSI_BAND_NAMES : null;
122124
statusBandName = bandNames[0];
@@ -233,7 +235,7 @@ public Product complete() {
233235
for (int row = 0; row < sceneRasterHeight; ++row) {
234236
for (int col = 0; col < sceneRasterWidth; ++col) {
235237
int i = row * sceneRasterWidth + col;
236-
byte state = majorityPriorityStatusOf(statusCount, row, col);
238+
byte state = withMajorityStatus ? majorityPriorityStatusOf(statusCount, row, col) : priorityStatusOf(statusCount, row, col);
237239
int index = index(state);
238240
if (index >= 0) {
239241
status[i] = state;
@@ -337,6 +339,18 @@ private byte majorityPriorityStatusOf(int[][][] statusCount, int row, int col) {
337339
(byte)0; // invalid
338340
}
339341

342+
private byte priorityStatusOf(int[][][] statusCount, int row, int col) {
343+
return statusCount[0][row][col] > 0 ? (byte)1 : // land
344+
statusCount[1][row][col] > 0 ? (byte)2 : // water
345+
statusCount[2][row][col] > 0 ? (byte)3 : // snow
346+
statusCount[3][row][col] > 0 ? (byte)15 : // dark
347+
statusCount[4][row][col] > 0 ? (byte)12 : // bright
348+
statusCount[5][row][col] > 0 ? (byte)11 : // haze
349+
statusCount[6][row][col] > 0 ? (byte)5 : // shadow
350+
statusCount[7][row][col] > 0 ? (byte)4 : // cloud
351+
(byte)0; // invalid
352+
}
353+
340354
private static float ndxiOf(float nir, float red) {
341355
return (nir - red) / (nir + red);
342356
}

0 commit comments

Comments
 (0)