Skip to content

Commit e27c37e

Browse files
committed
adapted netbeans dependencies to Java21 and SNAP master; SNAPIdepix VIIRS: merged changes from 11.x branch
1 parent b4a7072 commit e27c37e

File tree

20 files changed

+152
-96
lines changed

20 files changed

+152
-96
lines changed

idepix-core/src/main/java/org/esa/snap/idepix/core/IdepixConstants.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ public class IdepixConstants {
9292

9393
public static final float[] PROBAV_WAVELENGTHS = {462.0f, 655.5f, 843.0f, 1599.0f};
9494

95+
public static final String[] VIRRS_SNPP_BAND_NAMES =
96+
new String[]{"rhot_410", "rhot_443", "rhot_486", "rhot_551", "rhot_671",
97+
"rhot_745", "rhot_862", "rhot_1238", "rhot_1601", "rhot_2257"};
98+
99+
public static final String[] VIRRS_NOAA20_BAND_NAMES =
100+
new String[]{"rhot_411", "rhot_445", "rhot_489", "rhot_556", "rhot_667",
101+
"rhot_746", "rhot_868", "rhot_1238", "rhot_1604", "rhot_2258"};
102+
103+
// todo: check these
104+
public static final String[] VIRRS_NOAA21_BAND_NAMES =
105+
new String[]{"rhot_411", "rhot_445", "rhot_489", "rhot_556", "rhot_667",
106+
"rhot_746", "rhot_868", "rhot_1238", "rhot_1604", "rhot_2258"};
107+
108+
95109
public static final String INPUT_INCONSISTENCY_ERROR_MESSAGE =
96110
"Selected cloud screening algorithm cannot be used with given input product. \n\n" +
97111
"Supported sensors are: MERIS, SPOT VGT, MODIS, Landsat-8, SeaWiFS, Sentinel-2 MSI, " +

idepix-core/src/main/java/org/esa/snap/idepix/core/util/IdepixIO.java

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,20 +251,57 @@ private static boolean isValidSeawifsProduct(Product product) {
251251
}
252252

253253
private static boolean isValidViirsProduct(Product product) {
254-
String[] expectedBandNames = new String[]{"rhot_410", "rhot_443", "rhot_486", "rhot_551", "rhot_671",
255-
"rhot_745", "rhot_862", "rhot_1238", "rhot_1601", "rhot_2257"};
256-
for (String expectedBandName : expectedBandNames) {
254+
return isValidViirsSNPPProduct(product) ||
255+
isValidViirsNOAA20Product(product) ||
256+
isValidViirsNOAA21Product(product);
257+
}
258+
259+
private static boolean isValidViirsNOAA21Product(Product product) {
260+
for (String expectedBandName : IdepixConstants.VIRRS_NOAA21_BAND_NAMES) {
257261
if (!product.containsBand(expectedBandName)) {
258262
return false;
259263
}
260264
}
261-
// e.g. V2012024230521.L1C
262-
// 20181005: PML requested L1C_SNPP.nc as valid extension
263-
return (product.getName().matches("V[0-9]{13}.(?i)(L1C)") ||
264-
product.getName().matches("V[0-9]{13}.(?i)(L1C.nc)") ||
265-
product.getName().matches("V[0-9]{13}.(?i)(L1C_SNPP.nc)") ||
266-
product.getName().matches("V[0-9]{13}.(?i)(L2)") ||
267-
product.getName().matches("V[0-9]{13}.(?i)(L2.nc)"));
265+
// Update 20250108: PML requests support for products like JPSS2_VIIRS.20190613T070000.L1C
266+
return product.getName().matches("JPSS2_VIIRS.[0-9]{8}T[0-9]{6}.(?i)(L1C)");
267+
}
268+
269+
private static boolean isValidViirsNOAA20Product(Product product) {
270+
for (String expectedBandName : IdepixConstants.VIRRS_NOAA20_BAND_NAMES) {
271+
if (!product.containsBand(expectedBandName)) {
272+
return false;
273+
}
274+
}
275+
// Update 20250108: PML requests support for products like JPSS2_VIIRS.20190613T070000.L1C
276+
return product.getName().matches("JPSS1_VIIRS.[0-9]{8}T[0-9]{6}.(?i)(L1C)");
277+
}
278+
279+
private static boolean isValidViirsSNPPProduct(Product product) {
280+
for (String expectedBandName : IdepixConstants.VIRRS_SNPP_BAND_NAMES) {
281+
if (!product.containsBand(expectedBandName)) {
282+
return false;
283+
}
284+
}
285+
// Update 20250108: PML requests support for products like SNPP_VIIRS.20190613T070000.L1C
286+
return product.getName().matches("SNPP_VIIRS.[0-9]{8}T[0-9]{6}.(?i)(L1C)");
287+
}
288+
289+
/**
290+
* Provides VIIRS spectral band names, depending on product type (SNPP, NOAA20 or NOAA21)
291+
*
292+
* @param productName -
293+
* @return String[]
294+
*/
295+
public static String[] getViirsSpectralBandNames(String productName) {
296+
if (productName.startsWith("SNPP_VIIRS")) {
297+
return IdepixConstants.VIRRS_SNPP_BAND_NAMES;
298+
} else if (productName.startsWith("JPSS1_VIIRS")) {
299+
return IdepixConstants.VIRRS_NOAA20_BAND_NAMES;
300+
} else if (productName.startsWith("JPSS2_VIIRS")) {
301+
return IdepixConstants.VIRRS_NOAA21_BAND_NAMES;
302+
} else {
303+
return null;
304+
}
268305
}
269306

270307

idepix-olci/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
<groupId>org.esa.snap</groupId>
5454
<artifactId>ceres-binding</artifactId>
5555
</dependency>
56+
<dependency>
57+
<groupId>org.esa.snap</groupId>
58+
<artifactId>ceres-glayer</artifactId>
59+
</dependency>
5660
<dependency>
5761
<groupId>org.esa.snap</groupId>
5862
<artifactId>ceres-jai</artifactId>

idepix-probav/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
<groupId>org.esa.snap</groupId>
4848
<artifactId>ceres-core</artifactId>
4949
</dependency>
50+
<dependency>
51+
<groupId>org.esa.snap</groupId>
52+
<artifactId>ceres-glayer</artifactId>
53+
</dependency>
5054
<dependency>
5155
<groupId>org.esa.snap</groupId>
5256
<artifactId>snap-core</artifactId>

idepix-s2msi/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
<groupId>org.esa.snap</groupId>
4848
<artifactId>ceres-core</artifactId>
4949
</dependency>
50+
<dependency>
51+
<groupId>org.esa.snap</groupId>
52+
<artifactId>ceres-glayer</artifactId>
53+
</dependency>
5054
<dependency>
5155
<groupId>org.esa.snap</groupId>
5256
<artifactId>ceres-jai</artifactId>

idepix-spotvgt/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
<groupId>org.esa.snap</groupId>
4949
<artifactId>ceres-core</artifactId>
5050
</dependency>
51+
<dependency>
52+
<groupId>org.esa.snap</groupId>
53+
<artifactId>ceres-glayer</artifactId>
54+
</dependency>
5155
<dependency>
5256
<groupId>org.esa.snap</groupId>
5357
<artifactId>snap-core</artifactId>

idepix-viirs/src/main/java/org/esa/snap/idepix/viirs/ViirsClassificationOp.java

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.esa.snap.idepix.viirs;
22

33
import org.esa.snap.idepix.core.IdepixConstants;
4+
import org.esa.snap.idepix.core.util.IdepixIO;
45
import org.esa.snap.idepix.core.util.SchillerNeuralNetWrapper;
56
import org.esa.snap.core.datamodel.*;
67
import org.esa.snap.core.gpf.OperatorException;
@@ -19,9 +20,10 @@
1920
* @author olafd
2021
*/
2122
@OperatorMetadata(alias = "Idepix.Viirs.Classification",
22-
version = "3.0",
23-
copyright = "(c) 2016 by Brockmann Consult",
24-
description = "VIIRS pixel classification operator.",
23+
version = "3.1",
24+
authors = "Olaf Danne, Marco Zuehlke",
25+
copyright = "(c) 2016 - 2024 by Brockmann Consult",
26+
description = "VIIRS pixel classification operator. Supports Suomi NPP, NOAA20, NOAA21 products.",
2527
internal = true)
2628
public class ViirsClassificationOp extends PixelOperator {
2729

@@ -38,7 +40,7 @@ public class ViirsClassificationOp extends PixelOperator {
3840
private int waterMaskResolution;
3941

4042

41-
@SourceProduct(alias = "refl", description = "MODIS L1b reflectance product")
43+
@SourceProduct(alias = "refl", description = "VIIRS L1C reflectance product")
4244
private Product reflProduct;
4345

4446
@SourceProduct(alias = "waterMask")
@@ -47,15 +49,12 @@ public class ViirsClassificationOp extends PixelOperator {
4749
private static final String VIIRS_NET_NAME = "6x5x4x3x2_204.8.net";
4850
private ThreadLocal<SchillerNeuralNetWrapper> viirsNeuralNet;
4951

52+
private String[] viirsSpectralBandNames;
5053

51-
@Override
52-
public Product getSourceProduct() {
53-
// this is the source product for the ProductConfigurer
54-
return reflProduct;
55-
}
5654

5755
@Override
5856
protected void prepareInputs() throws OperatorException {
57+
viirsSpectralBandNames = IdepixIO.getViirsSpectralBandNames(reflProduct.getName());
5958
readSchillerNet();
6059
}
6160

@@ -67,16 +66,21 @@ protected void computePixel(int x, int y, Sample[] sourceSamples, WritableSample
6766

6867
@Override
6968
protected void configureSourceSamples(SourceSampleConfigurer sampleConfigurer) throws OperatorException {
70-
for (int i = 0; i < ViirsConstants.VIIRS_L1B_NUM_SPECTRAL_BANDS; i++) {
71-
if (getSourceProduct().containsBand(ViirsConstants.VIIRS_SPECTRAL_BAND_NAMES[i])) {
72-
sampleConfigurer.defineSample(i, ViirsConstants.VIIRS_SPECTRAL_BAND_NAMES[i], getSourceProduct());
73-
} else {
74-
sampleConfigurer.defineSample(i, ViirsConstants.VIIRS_SPECTRAL_BAND_NAMES[i].replace(".", "_"),
75-
getSourceProduct());
69+
if (viirsSpectralBandNames != null) {
70+
for (int i = 0; i < viirsSpectralBandNames.length; i++) {
71+
if (getSourceProduct().containsBand(viirsSpectralBandNames[i])) {
72+
sampleConfigurer.defineSample(i, viirsSpectralBandNames[i], getSourceProduct());
73+
} else {
74+
sampleConfigurer.defineSample(i, viirsSpectralBandNames[i].replace(".", "_"),
75+
getSourceProduct());
76+
}
7677
}
78+
} else {
79+
// should never happen
80+
throw new OperatorException("Source product has no valid VIIRS spectral bands - please check.");
7781
}
7882

79-
sampleConfigurer.defineSample(ViirsConstants.VIIRS_L1B_NUM_SPECTRAL_BANDS+1,
83+
sampleConfigurer.defineSample(viirsSpectralBandNames.length+1,
8084
IdepixConstants.LAND_WATER_FRACTION_BAND_NAME, waterMaskProduct);
8185
}
8286

@@ -153,20 +157,20 @@ private void setClassifFlag(WritableSample[] targetSamples, ViirsAlgorithm algor
153157
}
154158

155159
private ViirsAlgorithm createViirsAlgorithm(int x, int y, Sample[] sourceSamples, WritableSample[] targetSamples) {
156-
final double[] reflectance = new double[ViirsConstants.VIIRS_L1B_NUM_SPECTRAL_BANDS];
160+
final double[] reflectance = new double[viirsSpectralBandNames.length];
157161
double[] neuralNetOutput;
158162

159163
float waterFraction = Float.NaN;
160164

161165
ViirsAlgorithm viirsAlgorithm = new ViirsAlgorithm();
162-
for (int i = 0; i < ViirsConstants.VIIRS_L1B_NUM_SPECTRAL_BANDS; i++) {
166+
for (int i = 0; i < viirsSpectralBandNames.length; i++) {
163167
reflectance[i] = sourceSamples[i].getFloat();
164168
}
165169
viirsAlgorithm.setRefl(reflectance);
166170
// the water mask ends at 59 Degree south, stop earlier to avoid artefacts
167171
if (getGeoPos(x, y).lat > -58f) {
168172
waterFraction =
169-
sourceSamples[ViirsConstants.VIIRS_L1B_NUM_SPECTRAL_BANDS + 1].getFloat();
173+
sourceSamples[viirsSpectralBandNames.length + 1].getFloat();
170174
}
171175
viirsAlgorithm.setWaterFraction(waterFraction);
172176

idepix-viirs/src/main/java/org/esa/snap/idepix/viirs/ViirsConstants.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@
99
*/
1010
class ViirsConstants {
1111

12-
13-
private final static String VIIRS_REFLECTANCE_1_BAND_NAME = "rhot_410";
14-
private final static String VIIRS_REFLECTANCE_2_BAND_NAME = "rhot_443";
15-
private final static String VIIRS_REFLECTANCE_3_BAND_NAME = "rhot_486";
16-
private final static String VIIRS_REFLECTANCE_4_BAND_NAME = "rhot_551";
17-
private final static String VIIRS_REFLECTANCE_5_BAND_NAME = "rhot_671";
18-
private final static String VIIRS_REFLECTANCE_6_BAND_NAME = "rhot_745";
19-
private final static String VIIRS_REFLECTANCE_7_BAND_NAME = "rhot_862";
20-
private final static String VIIRS_REFLECTANCE_8_BAND_NAME = "rhot_1238";
21-
private final static String VIIRS_REFLECTANCE_9_BAND_NAME = "rhot_1601";
22-
private final static String VIIRS_REFLECTANCE_10_BAND_NAME = "rhot_2257";
23-
static String[] VIIRS_SPECTRAL_BAND_NAMES = {
24-
VIIRS_REFLECTANCE_1_BAND_NAME,
25-
VIIRS_REFLECTANCE_2_BAND_NAME,
26-
VIIRS_REFLECTANCE_3_BAND_NAME,
27-
VIIRS_REFLECTANCE_4_BAND_NAME,
28-
VIIRS_REFLECTANCE_5_BAND_NAME,
29-
VIIRS_REFLECTANCE_6_BAND_NAME,
30-
VIIRS_REFLECTANCE_7_BAND_NAME,
31-
VIIRS_REFLECTANCE_8_BAND_NAME,
32-
VIIRS_REFLECTANCE_9_BAND_NAME,
33-
VIIRS_REFLECTANCE_10_BAND_NAME,
34-
};
35-
final static int VIIRS_L1B_NUM_SPECTRAL_BANDS = VIIRS_SPECTRAL_BAND_NAMES.length;
36-
3712
static final int IDEPIX_MIXED_PIXEL = IdepixConstants.NUM_DEFAULT_FLAGS + 1;
3813

3914
static final String IDEPIX_MIXED_PIXEL_DESCR_TEXT = "Mixed pixel";

idepix-viirs/src/main/java/org/esa/snap/idepix/viirs/ViirsOp.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
@SuppressWarnings({"FieldCanBeLocal"})
2525
@OperatorMetadata(alias = "Idepix.Viirs",
2626
category = "Optical/Preprocessing/Masking/IdePix (Clouds, Land, Water, ...)",
27-
version = "3.0",
27+
version = "3.1",
2828
authors = "Olaf Danne, Marco Zuehlke",
29-
copyright = "(c) 2016 by Brockmann Consult",
30-
description = "Pixel identification and classification for VIIRS.")
29+
copyright = "(c) 2016 - 2024 by Brockmann Consult",
30+
description = "Pixel identification and classification for VIIRS. Supports Suomi NPP, NOAA20, NOAA21 products.")
3131
public class ViirsOp extends Operator{
3232

3333
@Parameter(defaultValue = "false",
@@ -49,7 +49,8 @@ public class ViirsOp extends Operator{
4949
private int waterMaskResolution;
5050

5151

52-
@SourceProduct(alias = "sourceProduct", label = "Name (VIIRS L1b product)", description = "The source product.")
52+
@SourceProduct(alias = "sourceProduct", label = "Name (VIIRS L1C product)",
53+
description = "The L1C source product (SNPP, NOAA20, or NOAA21)")
5354
private Product sourceProduct;
5455

5556
private Product classifProduct;

idepix-viirs/src/main/javahelp/org/esa/snap/idepix/viirs/docs/help.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"http://java.sun.com/products/javahelp/helpset_2_0.dtd">
55

66
<helpset version="2.0">
7-
<title>IdePix Suomi NPP VIIRS Help</title>
7+
<title>IdePix VIIRS Help</title>
88
<maps>
99
<homeID>top</homeID>
1010
<mapref location="map.jhm"/>

0 commit comments

Comments
 (0)