@@ -45,6 +45,10 @@ class NdbcCWReader extends NdbcReader {
4545 private static final String LATITUDE = "latitude" ;
4646 private static final String BAROMETER_HEIGHT = "barometer_height" ;
4747 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" ;
4852 private static StationDatabase stationDatabase ;
4953
5054 private ArrayList <CwRecord > records ;
@@ -164,42 +168,51 @@ public int[] extractYearMonthDayFromFilename(String fileName) {
164168
165169 @ Override
166170 public Array readRaw (int centerX , int centerY , Interval interval , String variableName ) throws IOException , InvalidRangeException {
167- if (variableName .equals (STATION_ID )) {
168-
169- } else if (variableName .equals (STATION_TYPE )) {
170- final StationType type = station .getType ();
171- return createResultArray (toByte (type ), -1 , DataType .BYTE , interval );
172- } else if (variableName .equals (MEASUREMENT_TYPE )) {
173- final MeasurementType measurementType = station .getMeasurementType ();
174- return createResultArray (toByte (measurementType ), -1 , DataType .BYTE , interval );
175- } else if (variableName .equals (LATITUDE )) {
176- return createResultArray (station .getLat (), Float .NaN , DataType .FLOAT , interval );
177- } else if (variableName .equals (ANEMOMETER_HEIGHT )) {
178- return createResultArray (station .getAnemometerHeight (), Float .NaN , DataType .FLOAT , interval );
179- } else if (variableName .equals (BAROMETER_HEIGHT )) {
180- return createResultArray (station .getBarometerHeight (), Float .NaN , DataType .FLOAT , interval );
181- } else if (variableName .equals (SST_DEPTH )) {
182- return createResultArray (station .getSSTDepth (), Float .NaN , DataType .FLOAT , interval );
183- } else if (variableName .equals (WDIR )) {
184- final CwRecord record = records .get (centerY );
185- return createResultArray (record .windDir , 999 , DataType .SHORT , interval );
186- } else if (variableName .equals (WSPD )) {
187- final CwRecord record = records .get (centerY );
188- return createResultArray (record .windSpeed , 99.f , DataType .FLOAT , interval );
189- } else if (variableName .equals (GST )) {
190- final CwRecord record = records .get (centerY );
191- return createResultArray (record .gustSpeed , 99.f , DataType .FLOAT , interval );
192- } else if (variableName .equals (GTIME )) {
193- final CwRecord record = records .get (centerY );
194- return createResultArray (record .gustTime , 9999 , DataType .SHORT , interval );
171+ final CwRecord record = records .get (centerY );
172+
173+ switch (variableName ) {
174+ case STATION_ID :
175+ final Array resultArray = Array .factory (DataType .STRING , new int []{1 , 1 });
176+ resultArray .setObject (0 , station .getId ());
177+ return resultArray ;
178+ case STATION_TYPE :
179+ final StationType type = station .getType ();
180+ return createResultArray (toByte (type ), -1 , DataType .BYTE , interval );
181+ case MEASUREMENT_TYPE :
182+ final MeasurementType measurementType = station .getMeasurementType ();
183+ return createResultArray (toByte (measurementType ), -1 , DataType .BYTE , interval );
184+ case LONGITUDE :
185+ return createResultArray (station .getLon (), Float .NaN , DataType .FLOAT , interval );
186+ case LATITUDE :
187+ return createResultArray (station .getLat (), Float .NaN , DataType .FLOAT , interval );
188+ case ANEMOMETER_HEIGHT :
189+ return createResultArray (station .getAnemometerHeight (), Float .NaN , DataType .FLOAT , interval );
190+ case AIR_TEMP_HEIGHT :
191+ return createResultArray (station .getAirTemperatureHeight (), Float .NaN , DataType .FLOAT , interval );
192+ case BAROMETER_HEIGHT :
193+ return createResultArray (station .getBarometerHeight (), Float .NaN , DataType .FLOAT , interval );
194+ case SST_DEPTH :
195+ return createResultArray (station .getSSTDepth (), Float .NaN , DataType .FLOAT , interval );
196+ case TIME :
197+ return createResultArray (record .utc , NetCDFUtils .getDefaultFillValue (int .class ), DataType .INT , interval );
198+ case WDIR :
199+ return createResultArray (record .windDir , 999 , DataType .SHORT , interval );
200+ case WSPD :
201+ return createResultArray (record .windSpeed , 99.f , DataType .FLOAT , interval );
202+ case GST :
203+ return createResultArray (record .gustSpeed , 99.f , DataType .FLOAT , interval );
204+ case GDR :
205+ return createResultArray (record .gustDir , 999 , DataType .SHORT , interval );
206+ case GTIME :
207+ return createResultArray (record .gustTime , 9999 , DataType .SHORT , interval );
195208 }
196209
197210 return null ;
198211 }
199212
200213 @ Override
201214 public Array readScaled (int centerX , int centerY , Interval interval , String variableName ) throws IOException , InvalidRangeException {
202- throw new RuntimeException ( "not implemented" );
215+ return readRaw ( centerX , centerY , interval , variableName ); // nothing to scale here tb 2023-02-28
203216 }
204217
205218 @ Override
@@ -227,7 +240,7 @@ public List<Variable> getVariables() throws InvalidRangeException, IOException {
227240 attributes .add (new Attribute (CF_UNITS_NAME , "degree_east" ));
228241 attributes .add (new Attribute (CF_FILL_VALUE_NAME , NetCDFUtils .getDefaultFillValue (float .class )));
229242 attributes .add (new Attribute (CF_STANDARD_NAME , "longitude" ));
230- variables .add (new VariableProxy ("longitude" , DataType .FLOAT , attributes ));
243+ variables .add (new VariableProxy (LONGITUDE , DataType .FLOAT , attributes ));
231244
232245 attributes = new ArrayList <>();
233246 attributes .add (new Attribute (CF_UNITS_NAME , "degree_north" ));
@@ -245,7 +258,7 @@ public List<Variable> getVariables() throws InvalidRangeException, IOException {
245258 attributes .add (new Attribute (CF_UNITS_NAME , "m" ));
246259 attributes .add (new Attribute (CF_FILL_VALUE_NAME , Float .NaN ));
247260 attributes .add (new Attribute (CF_LONG_NAME , "Height of instrument above site elevation" ));
248- variables .add (new VariableProxy ("air_temp_height" , DataType .FLOAT , attributes ));
261+ variables .add (new VariableProxy (AIR_TEMP_HEIGHT , DataType .FLOAT , attributes ));
249262
250263 attributes = new ArrayList <>();
251264 attributes .add (new Attribute (CF_UNITS_NAME , "m" ));
@@ -263,7 +276,7 @@ public List<Variable> getVariables() throws InvalidRangeException, IOException {
263276 attributes .add (new Attribute (CF_UNITS_NAME , "seconds since 1970-01-01" ));
264277 attributes .add (new Attribute (CF_FILL_VALUE_NAME , NetCDFUtils .getDefaultFillValue (int .class )));
265278 attributes .add (new Attribute (CF_STANDARD_NAME , "time" ));
266- variables .add (new VariableProxy ("time" , DataType .INT , attributes ));
279+ variables .add (new VariableProxy (TIME , DataType .INT , attributes ));
267280
268281 // @todo 1 tb/tb check CF standard names for the measurement data 2023-02027
269282 attributes = new ArrayList <>();
@@ -282,7 +295,7 @@ public List<Variable> getVariables() throws InvalidRangeException, IOException {
282295 attributes .add (new Attribute (CF_UNITS_NAME , "degT" ));
283296 attributes .add (new Attribute (CF_FILL_VALUE_NAME , 999 ));
284297 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." ));
285- variables .add (new VariableProxy (" GDR" , DataType .SHORT , attributes ));
298+ variables .add (new VariableProxy (GDR , DataType .SHORT , attributes ));
286299
287300 attributes = new ArrayList <>();
288301 attributes .add (new Attribute (CF_UNITS_NAME , "m/s" ));
0 commit comments