3333
3434class NdbcCWReader extends NdbcReader {
3535
36- public static final String GST = "GST" ;
37- public static final String MEASUREMENT_TYPE = "measurement_type" ;
38- public static final String ANEMOMETER_HEIGHT = "anemometer_height" ;
39- public static final String SST_DEPTH = "sst_depth" ;
40- public static final String WSPD = "WSPD" ;
41- public static final String GTIME = "GTIME" ;
36+ private static final String GST = "GST" ;
37+ private static final String MEASUREMENT_TYPE = "measurement_type" ;
38+ private static final String ANEMOMETER_HEIGHT = "anemometer_height" ;
39+ private static final String SST_DEPTH = "sst_depth" ;
40+ private static final String WSPD = "WSPD" ;
41+ private static final String GTIME = "GTIME" ;
4242 private static final String REG_EX_CW = "\\ w{5}c\\ d{4}.txt" ;
4343 private static final String STATION_ID = "station_id" ;
4444 private static final String STATION_TYPE = "station_type" ;
45+ private static final String LONGITUDE = "longitude" ;
4546 private static final String LATITUDE = "latitude" ;
4647 private static final String BAROMETER_HEIGHT = "barometer_height" ;
4748 private static final String WDIR = "WDIR" ;
48- public static final String LONGITUDE = "longitude " ;
49- public static final String AIR_TEMP_HEIGHT = "air_temp_height " ;
50- public static final String TIME = "time " ;
51- public static final String GDR = "GDR" ;
49+ private static final String AIR_TEMP_HEIGHT = "air_temp_height " ;
50+ private static final String TIME = "time " ;
51+ private static final String GDR = "GDR " ;
52+
5253 private static StationDatabase stationDatabase ;
5354
5455 private ArrayList <CwRecord > records ;
5556 private TimeLocator timeLocator ;
5657 private Station station ;
5758
58- NdbcCWReader () {
59- }
60-
6159 @ Override
6260 public void open (File file ) throws IOException {
6361 ensureStationDatabase ();
@@ -163,7 +161,13 @@ private void createTimeLocator() {
163161
164162 @ Override
165163 public int [] extractYearMonthDayFromFilename (String fileName ) {
166- throw new RuntimeException ("not implemented" );
164+ int [] ymd = new int [3 ];
165+ final int dotIndex = fileName .indexOf ('.' );
166+ final String yearString = fileName .substring (dotIndex - 4 , dotIndex );
167+ ymd [0 ] = Integer .parseInt (yearString );
168+ ymd [1 ] = 1 ;
169+ ymd [2 ] = 1 ;
170+ return ymd ;
167171 }
168172
169173 @ Override
@@ -217,7 +221,9 @@ public Array readScaled(int centerX, int centerY, Interval interval, String vari
217221
218222 @ Override
219223 public ArrayInt .D2 readAcquisitionTime (int x , int y , Interval interval ) throws IOException , InvalidRangeException {
220- throw new RuntimeException ("not implemented" );
224+ final Array timeArray = readRaw (x , y , interval , TIME );
225+
226+ return (ArrayInt .D2 ) timeArray ;
221227 }
222228
223229 @ Override
@@ -282,24 +288,28 @@ public List<Variable> getVariables() throws InvalidRangeException, IOException {
282288 attributes = new ArrayList <>();
283289 attributes .add (new Attribute (CF_UNITS_NAME , "degT" ));
284290 attributes .add (new Attribute (CF_FILL_VALUE_NAME , 999 ));
291+ attributes .add (new Attribute (CF_STANDARD_NAME , "wind_from_direction" ));
285292 attributes .add (new Attribute (CF_LONG_NAME , "Ten-minute average wind direction measurements in degrees clockwise from true North." ));
286293 variables .add (new VariableProxy (WDIR , DataType .SHORT , attributes ));
287294
288295 attributes = new ArrayList <>();
289296 attributes .add (new Attribute (CF_UNITS_NAME , "m/s" ));
290297 attributes .add (new Attribute (CF_FILL_VALUE_NAME , 99.f ));
298+ attributes .add (new Attribute (CF_STANDARD_NAME , "wind_speed" ));
291299 attributes .add (new Attribute (CF_LONG_NAME , "Ten-minute average wind speed values in m/s." ));
292300 variables .add (new VariableProxy (WSPD , DataType .FLOAT , attributes ));
293301
294302 attributes = new ArrayList <>();
295303 attributes .add (new Attribute (CF_UNITS_NAME , "degT" ));
296304 attributes .add (new Attribute (CF_FILL_VALUE_NAME , 999 ));
305+ attributes .add (new Attribute (CF_STANDARD_NAME , "wind_gust_from_direction" ));
297306 attributes .add (new Attribute (CF_LONG_NAME , "Direction, in degrees clockwise from true North, of the GST, reported at the last hourly 10-minute segment." ));
298307 variables .add (new VariableProxy (GDR , DataType .SHORT , attributes ));
299308
300309 attributes = new ArrayList <>();
301310 attributes .add (new Attribute (CF_UNITS_NAME , "m/s" ));
302311 attributes .add (new Attribute (CF_FILL_VALUE_NAME , 99.f ));
312+ attributes .add (new Attribute (CF_STANDARD_NAME , "wind_gust_speed" ));
303313 attributes .add (new Attribute (CF_LONG_NAME , "Maximum 5-second peak gust during the measurement hour, reported at the last hourly 10-minute segment." ));
304314 variables .add (new VariableProxy (GST , DataType .FLOAT , attributes ));
305315
@@ -319,12 +329,12 @@ public Dimension getProductSize() throws IOException {
319329
320330 @ Override
321331 public String getLongitudeVariableName () {
322- throw new RuntimeException ( "not implemented" ) ;
332+ return LONGITUDE ;
323333 }
324334
325335 @ Override
326336 public String getLatitudeVariableName () {
327- throw new RuntimeException ( "not implemented" ) ;
337+ return LATITUDE ;
328338 }
329339
330340 private void ensureStationDatabase () throws IOException {
0 commit comments