Skip to content

Commit 2fcbeac

Browse files
committed
initial sic insitu
1 parent fe5899e commit 2fcbeac

File tree

7 files changed

+267
-2
lines changed

7 files changed

+267
-2
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package com.bc.fiduceo.reader.insitu.sic_cci;
2+
3+
import com.bc.fiduceo.core.Dimension;
4+
import com.bc.fiduceo.core.Interval;
5+
import com.bc.fiduceo.geometry.Polygon;
6+
import com.bc.fiduceo.location.PixelLocator;
7+
import com.bc.fiduceo.reader.AcquisitionInfo;
8+
import com.bc.fiduceo.reader.Reader;
9+
import com.bc.fiduceo.reader.time.TimeLocator;
10+
import ucar.ma2.Array;
11+
import ucar.ma2.ArrayInt;
12+
import ucar.ma2.InvalidRangeException;
13+
import ucar.nc2.Variable;
14+
15+
import java.io.BufferedReader;
16+
import java.io.File;
17+
import java.io.FileReader;
18+
import java.io.IOException;
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
22+
public class SicCciInsituReader implements Reader {
23+
24+
private static final String REG_EX = "ASCAT-vs-AMSR2-vs-ERA5-vs-DMISIC0-\\d{4}-[N|S].text";
25+
26+
private FileReader fileReader;
27+
private ArrayList<String> linelist;
28+
29+
@Override
30+
public void open(File file) throws IOException {
31+
fileReader = new FileReader(file);
32+
33+
linelist = new ArrayList<>();
34+
final BufferedReader bufferedReader = new BufferedReader(fileReader);
35+
String line;
36+
while ((line = bufferedReader.readLine()) != null) {
37+
linelist.add(line);
38+
}
39+
}
40+
41+
@Override
42+
public void close() throws IOException {
43+
if (linelist != null) {
44+
linelist.clear();
45+
linelist = null;
46+
}
47+
if (fileReader != null) {
48+
fileReader.close();
49+
fileReader = null;
50+
}
51+
}
52+
53+
@Override
54+
public AcquisitionInfo read() throws IOException {
55+
throw new RuntimeException("not implemented");
56+
}
57+
58+
@Override
59+
public String getRegEx() {
60+
return REG_EX;
61+
}
62+
63+
@Override
64+
public PixelLocator getPixelLocator() throws IOException {
65+
throw new RuntimeException("not implemented");
66+
}
67+
68+
@Override
69+
public PixelLocator getSubScenePixelLocator(Polygon sceneGeometry) throws IOException {
70+
throw new RuntimeException("not implemented");
71+
}
72+
73+
@Override
74+
public TimeLocator getTimeLocator() throws IOException {
75+
throw new RuntimeException("not implemented");
76+
}
77+
78+
@Override
79+
public int[] extractYearMonthDayFromFilename(String fileName) {
80+
throw new RuntimeException("not implemented");
81+
}
82+
83+
@Override
84+
public Array readRaw(int centerX, int centerY, Interval interval, String variableName) throws IOException, InvalidRangeException {
85+
throw new RuntimeException("not implemented");
86+
}
87+
88+
@Override
89+
public Array readScaled(int centerX, int centerY, Interval interval, String variableName) throws IOException, InvalidRangeException {
90+
throw new RuntimeException("not implemented");
91+
}
92+
93+
@Override
94+
public ArrayInt.D2 readAcquisitionTime(int x, int y, Interval interval) throws IOException, InvalidRangeException {
95+
throw new RuntimeException("not implemented");
96+
}
97+
98+
@Override
99+
public List<Variable> getVariables() throws InvalidRangeException, IOException {
100+
throw new RuntimeException("not implemented");
101+
}
102+
103+
@Override
104+
public Dimension getProductSize() throws IOException {
105+
throw new RuntimeException("not implemented");
106+
}
107+
108+
@Override
109+
public String getLongitudeVariableName() {
110+
return "longitude";
111+
}
112+
113+
@Override
114+
public String getLatitudeVariableName() {
115+
return "latitude";
116+
}
117+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.bc.fiduceo.reader.insitu.sic_cci;
2+
3+
import com.bc.fiduceo.reader.DataType;
4+
import com.bc.fiduceo.reader.Reader;
5+
import com.bc.fiduceo.reader.ReaderContext;
6+
import com.bc.fiduceo.reader.ReaderPlugin;
7+
8+
public class SicCciInsituReaderPlugin implements ReaderPlugin {
9+
10+
private final String[] SUPPORTED_KEYS = {"sic-cci-dmisic0"};
11+
12+
@Override
13+
public Reader createReader(ReaderContext readerContext) {
14+
return new SicCciInsituReader();
15+
}
16+
17+
@Override
18+
public String[] getSupportedSensorKeys() {
19+
return SUPPORTED_KEYS;
20+
}
21+
22+
@Override
23+
public DataType getDataType() {
24+
return DataType.INSITU;
25+
}
26+
}

core/src/test/java/com/bc/fiduceo/reader/insitu/gruan_uleic/GruanUleicInsituReaderPluginTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ public void testCreateReader() {
3535
assertNotNull(reader);
3636
assertTrue(reader instanceof GruanUleicInsituReader);
3737
}
38-
3938
}

core/src/test/java/com/bc/fiduceo/reader/insitu/gruan_uleic/GruanUleicInsituReader_IO_Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void tearDown() throws IOException {
4848
}
4949

5050
@Test
51-
public void testReadAcquisitionInfo() throws IOException {
51+
public void testReadAcquisitionInfo() {
5252
final AcquisitionInfo info = reader.read();
5353
assertNotNull(info);
5454

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.bc.fiduceo.reader.insitu.sic_cci;
2+
3+
import com.bc.fiduceo.reader.DataType;
4+
import com.bc.fiduceo.reader.Reader;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
8+
import static org.junit.Assert.*;
9+
import static org.junit.Assert.assertTrue;
10+
11+
public class SciCciInsituReaderPluginTest {
12+
13+
private SicCciInsituReaderPlugin plugin;
14+
15+
@Before
16+
public void setUp() {
17+
plugin = new SicCciInsituReaderPlugin();
18+
}
19+
20+
@Test
21+
public void testGetSupportedSensorKeys() {
22+
final String[] expected = {"sic-cci-dmisic0"};
23+
24+
final String[] sensorKeys = plugin.getSupportedSensorKeys();
25+
assertArrayEquals(expected, sensorKeys);
26+
}
27+
28+
@Test
29+
public void testGetDataType() {
30+
assertEquals(DataType.INSITU, plugin.getDataType());
31+
}
32+
33+
@Test
34+
public void testCreateReader() {
35+
final Reader reader = plugin.createReader(null);
36+
assertNotNull(reader);
37+
assertTrue(reader instanceof SicCciInsituReader);
38+
}
39+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.bc.fiduceo.reader.insitu.sic_cci;
2+
3+
import com.bc.fiduceo.IOTestRunner;
4+
import com.bc.fiduceo.TestUtil;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
9+
import java.io.File;
10+
import java.io.IOException;
11+
12+
@RunWith(IOTestRunner.class)
13+
public class SciCciInsituReader_IO_Test {
14+
15+
private SicCciInsituReader reader;
16+
17+
@Before
18+
public void setUp() {
19+
reader = new SicCciInsituReader();
20+
}
21+
22+
@Test
23+
public void testReadAcquisitionInfo() throws IOException {
24+
final String relativePath = TestUtil.assembleFileSystemPath(new String[]{"insitu", "sic-cci", "DMI_SIC0", "v3", "ASCAT-vs-AMSR2-vs-ERA5-vs-DMISIC0-2016-N.text"}, false);
25+
final File testFile = TestUtil.getTestDataFileAsserted(relativePath);
26+
27+
try {
28+
reader.open(testFile);
29+
} finally {
30+
reader.close();
31+
}
32+
}
33+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.bc.fiduceo.reader.insitu.sic_cci;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import java.util.regex.Matcher;
7+
import java.util.regex.Pattern;
8+
9+
import static org.junit.Assert.*;
10+
import static org.junit.Assert.assertFalse;
11+
12+
public class SicCciInsituReaderTest {
13+
14+
private SicCciInsituReader reader;
15+
16+
@Before
17+
public void setUp() {
18+
reader = new SicCciInsituReader();
19+
}
20+
21+
@Test
22+
public void testGetRegEx() {
23+
final String expected = "ASCAT-vs-AMSR2-vs-ERA5-vs-DMISIC0-\\d{4}-[N|S].text";
24+
25+
assertEquals(expected, reader.getRegEx());
26+
27+
final Pattern pattern = Pattern.compile(expected);
28+
29+
Matcher matcher = pattern.matcher("ASCAT-vs-AMSR2-vs-ERA5-vs-DMISIC0-2017-N.text");
30+
assertTrue(matcher.matches());
31+
32+
matcher = pattern.matcher("ASCAT-vs-AMSR2-vs-ERA5-vs-DMISIC0-2018-S.text");
33+
assertTrue(matcher.matches());
34+
35+
matcher = pattern.matcher("insitu_0_WMOID_42531_19960904_19960909.nc");
36+
assertFalse(matcher.matches());
37+
38+
matcher = pattern.matcher("190546533.NSS.HIRX.NL.D11235.S1235.E1422.B5628788.WI.nc");
39+
assertFalse(matcher.matches());
40+
}
41+
42+
@Test
43+
public void testGetLongitudeVariableName() {
44+
assertEquals("longitude", reader.getLongitudeVariableName());
45+
}
46+
47+
@Test
48+
public void testGetLatitudeVariableName() {
49+
assertEquals("latitude", reader.getLatitudeVariableName());
50+
}
51+
}

0 commit comments

Comments
 (0)