Skip to content

Commit 8b3d1fe

Browse files
committed
intermediate readRaw
1 parent 53231af commit 8b3d1fe

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

core/src/main/java/com/bc/fiduceo/reader/windsat/WindsatReader.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.bc.fiduceo.geometry.*;
77
import com.bc.fiduceo.location.PixelLocator;
88
import com.bc.fiduceo.reader.AcquisitionInfo;
9+
import com.bc.fiduceo.reader.RawDataReader;
910
import com.bc.fiduceo.reader.ReaderContext;
1011
import com.bc.fiduceo.reader.ReaderUtils;
1112
import com.bc.fiduceo.reader.netcdf.NetCDFReader;
@@ -31,6 +32,7 @@ class WindsatReader extends NetCDFReader {
3132
private static final String[] LOOKS = {"fore", "aft"};
3233
private static final String[] FREQ_BANDS = {"068", "107", "187", "238", "370"};
3334
private static final String[] POLARIZATIONS = {"V", "H", "P", "M", "L", "R"};
35+
private final List<String> variables2D;
3436

3537
private final GeometryFactory geometryFactory;
3638

@@ -39,6 +41,11 @@ class WindsatReader extends NetCDFReader {
3941

4042
WindsatReader(ReaderContext readerContext) {
4143
this.geometryFactory = readerContext.getGeometryFactory();
44+
variables2D = new ArrayList<>();
45+
variables2D.add("latitude");
46+
variables2D.add("longitude");
47+
variables2D.add("land_fraction_06");
48+
variables2D.add("land_fraction_10");
4249
}
4350

4451
@Override
@@ -132,18 +139,19 @@ public int[] extractYearMonthDayFromFilename(String fileName) {
132139

133140
@Override
134141
public Array readRaw(int centerX, int centerY, Interval interval, String variableName) throws IOException, InvalidRangeException {
135-
// detect if variable one of the multidimensional
136-
// yes:
137-
// - extract layer indices from variable name
138-
// - extract NetCDF file variable name
139-
// - read from ArrayCache
140-
// - create section
141-
// no:
142-
// check if 1d vector
143-
// yes:
144-
// - implement specific fill handling
145-
// no:
146-
// -read subset
142+
if (variableName.equals("fractional_orbit")) {
143+
// read x section and fill in y-direction
144+
} else if (variables2D.contains(variableName)) {
145+
final Array array = arrayCache.get(variableName);
146+
final Number fillValue = arrayCache.getNumberAttributeValue(NetCDFUtils.CF_FILL_VALUE_NAME, variableName);
147+
return RawDataReader.read(centerX, centerY, interval, fillValue, array, getProductSize());
148+
} else {
149+
// - extract layer indices from variable name
150+
// - extract NetCDF file variable name
151+
// - read from ArrayCache
152+
// - create section
153+
}
154+
147155
throw new RuntimeException("not implmented");
148156
}
149157

core/src/test/java/com/bc/fiduceo/reader/windsat/WindsatReader_IO_Test.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.junit.Before;
1616
import org.junit.Test;
1717
import org.junit.runner.RunWith;
18+
import ucar.ma2.Array;
1819
import ucar.ma2.ArrayInt;
1920
import ucar.ma2.DataType;
2021
import ucar.ma2.InvalidRangeException;
@@ -302,6 +303,22 @@ public void testGetVariables() throws IOException, InvalidRangeException {
302303
}
303304
}
304305

306+
@Test
307+
public void testReadRaw() throws IOException, InvalidRangeException {
308+
final File file = getWindsatFile();
309+
310+
try {
311+
reader.open(file);
312+
313+
Array array = reader.readRaw(1328, 382, new Interval(3, 3), "land_fraction_06");
314+
NCTestUtils.assertValueAt(1.0, 0, 1, array);
315+
NCTestUtils.assertValueAt(0.996, 1, 1, array);
316+
NCTestUtils.assertValueAt(0.9920000433921814, 2, 1, array); // rounding issues in assertion code
317+
} finally {
318+
reader.close();
319+
}
320+
}
321+
305322
private File getWindsatFile() throws IOException {
306323
final String testFilePath = TestUtil.assembleFileSystemPath(new String[]{"windsat-coriolis", "v1.0", "2018", "04", "29", "RSS_WindSat_TB_L1C_r79285_20180429T174238_2018119_V08.0.nc"}, false);
307324
return TestUtil.getTestDataFileAsserted(testFilePath);

0 commit comments

Comments
 (0)