Skip to content

Commit e7f8c15

Browse files
committed
intermediate
1 parent 5e31ac5 commit e7f8c15

File tree

4 files changed

+205
-0
lines changed

4 files changed

+205
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package com.bc.fiduceo.reader.smos;
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.ReaderContext;
10+
import com.bc.fiduceo.reader.snap.SNAP_PixelLocator;
11+
import com.bc.fiduceo.reader.time.TimeLocator;
12+
import org.esa.snap.core.datamodel.CrsGeoCoding;
13+
import org.geotools.referencing.CRS;
14+
import org.opengis.referencing.FactoryException;
15+
import org.opengis.referencing.crs.CoordinateReferenceSystem;
16+
import org.opengis.referencing.operation.TransformException;
17+
import ucar.ma2.Array;
18+
import ucar.ma2.ArrayInt;
19+
import ucar.ma2.InvalidRangeException;
20+
import ucar.nc2.Variable;
21+
22+
import java.io.File;
23+
import java.io.IOException;
24+
import java.util.Iterator;
25+
import java.util.List;
26+
import java.util.Set;
27+
28+
public class SmosL1CDailyGriddedReader implements Reader {
29+
public SmosL1CDailyGriddedReader(ReaderContext readerContext) {
30+
31+
}
32+
33+
@Override
34+
public void open(File file) throws IOException {
35+
throw new IllegalStateException("not implemented");
36+
}
37+
38+
@Override
39+
public void close() throws IOException {
40+
throw new IllegalStateException("not implemented");
41+
}
42+
43+
@Override
44+
public AcquisitionInfo read() throws IOException {
45+
throw new IllegalStateException("not implemented");
46+
}
47+
48+
@Override
49+
public String getRegEx() {
50+
return "SM_RE07_MIR_CDF3T[AD]_(\\d{8}T\\d{6}_){2}\\d{3}_\\d{3}_\\d{1}.tgz";
51+
}
52+
53+
@Override
54+
public PixelLocator getPixelLocator() throws IOException {
55+
throw new IllegalStateException("not implemented");
56+
}
57+
58+
@Override
59+
public PixelLocator getSubScenePixelLocator(Polygon sceneGeometry) throws IOException {
60+
throw new IllegalStateException("not implemented");
61+
}
62+
63+
@Override
64+
public TimeLocator getTimeLocator() throws IOException {
65+
throw new IllegalStateException("not implemented");
66+
}
67+
68+
@Override
69+
public int[] extractYearMonthDayFromFilename(String fileName) {
70+
throw new IllegalStateException("not implemented");
71+
}
72+
73+
@Override
74+
public Array readRaw(int centerX, int centerY, Interval interval, String variableName) throws IOException, InvalidRangeException {
75+
throw new IllegalStateException("not implemented");
76+
}
77+
78+
@Override
79+
public Array readScaled(int centerX, int centerY, Interval interval, String variableName) throws IOException, InvalidRangeException {
80+
throw new IllegalStateException("not implemented");
81+
}
82+
83+
@Override
84+
public ArrayInt.D2 readAcquisitionTime(int x, int y, Interval interval) throws IOException, InvalidRangeException {
85+
throw new IllegalStateException("not implemented");
86+
}
87+
88+
@Override
89+
public List<Variable> getVariables() throws InvalidRangeException, IOException {
90+
throw new IllegalStateException("not implemented");
91+
}
92+
93+
@Override
94+
public Dimension getProductSize() throws IOException {
95+
throw new IllegalStateException("not implemented");
96+
}
97+
98+
@Override
99+
public String getLongitudeVariableName() {
100+
throw new IllegalStateException("not implemented");
101+
}
102+
103+
@Override
104+
public String getLatitudeVariableName() {
105+
throw new IllegalStateException("not implemented");
106+
}
107+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.bc.fiduceo.reader.smos;
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 SmosL1CDailyGriddedReaderPlugin implements ReaderPlugin {
9+
10+
private static String[] SENSOR_KEYS = new String[]{"miras-smos-daily-gridded"};
11+
12+
@Override
13+
public Reader createReader(ReaderContext readerContext) {
14+
return new SmosL1CDailyGriddedReader(readerContext);
15+
}
16+
17+
@Override
18+
public String[] getSupportedSensorKeys() {
19+
return SENSOR_KEYS;
20+
}
21+
22+
@Override
23+
public DataType getDataType() {
24+
return DataType.POLAR_ORBITING_SATELLITE;
25+
}
26+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.bc.fiduceo.reader.smos;
2+
3+
import com.bc.fiduceo.reader.DataType;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
7+
import static org.junit.Assert.assertEquals;
8+
import static org.junit.Assert.assertNotNull;
9+
10+
public class SmosL1CDailyGriddedReaderPluginTest {
11+
12+
private SmosL1CDailyGriddedReaderPlugin plugin;
13+
14+
@Before
15+
public void setUp() throws Exception {
16+
plugin = new SmosL1CDailyGriddedReaderPlugin();
17+
}
18+
19+
@Test
20+
public void testGetSupportedSensorKeys() {
21+
final String[] keys = plugin.getSupportedSensorKeys();
22+
assertEquals(1, keys.length);
23+
assertEquals("miras-smos-daily-gridded", keys[0]);
24+
}
25+
26+
@Test
27+
public void testGetDataType() {
28+
assertEquals(DataType.POLAR_ORBITING_SATELLITE, plugin.getDataType());
29+
}
30+
31+
@Test
32+
public void testCreateReader() {
33+
final SmosL1CDailyGriddedReader reader = (SmosL1CDailyGriddedReader) plugin.createReader(null);
34+
assertNotNull(reader);
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.bc.fiduceo.reader.smos;
2+
3+
import com.bc.fiduceo.reader.Reader;
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+
11+
public class SmosL1cDailyGriddedReaderTest {
12+
13+
@Test
14+
public void testGetRegEx() {
15+
final Reader reader = new SmosL1CDailyGriddedReader(null); // this test does not require a context class tb 2022-09-13
16+
17+
final String expected = "SM_RE07_MIR_CDF3T[AD]_(\\d{8}T\\d{6}_){2}\\d{3}_\\d{3}_\\d{1}.tgz";
18+
assertEquals(expected, reader.getRegEx());
19+
20+
final Pattern pattern = Pattern.compile(expected);
21+
Matcher matcher = pattern.matcher("SM_RE07_MIR_CDF3TA_20160610T000000_20160610T235959_330_001_7.tgz");
22+
assertTrue(matcher.matches());
23+
24+
matcher = pattern.matcher("SM_RE07_MIR_CDF3TD_20171120T000000_20171120T235959_330_001_7.tgz");
25+
assertTrue(matcher.matches());
26+
27+
matcher = pattern.matcher("S3A_SL_1_RBT____20200522T231202_20200522T231502_20200524T053503_0179_058_286_5580_LN2_O_NT_004.zip");
28+
assertFalse(matcher.matches());
29+
30+
matcher = pattern.matcher("FIDUCEO_FCDR_L1C_AVHRR_N19ALL_20110705055721_20110705073927_EASY_v0.2Bet_fv2.0.0.nc");
31+
assertFalse(matcher.matches());
32+
33+
matcher = pattern.matcher("190583863.NSS.HIRX.M2.D11235.S1641.E1823.B2513233.SV.nc");
34+
assertFalse(matcher.matches());
35+
}
36+
}

0 commit comments

Comments
 (0)