{
assertTrue( "Unexpected IOException reading \"year\" variable: " + e.getMessage(),
false );
}
int val = 0;
IndexIterator iter = year.getIndexIterator();
while (iter.hasNext()) {
val = iter.getIntNext();
assertTrue( "Value of variable \"year\" <" + val + "> not expected <2003>.",
val == 2003 );
}
// Test reading dayOfYear.
ucar.ma2.Array dayOfYear = null;
try
{
dayOfYear = meNcf.findVariable( "dayOfYear").read();
}
catch ( IOException e )
{
assertTrue( "Unexpected IOException reading \"dayOfYear\" variable: " + e.getMessage(),
false );
}
val = 0;
iter = dayOfYear.getIndexIterator();
while (iter.hasNext()) {
val = iter.getIntNext();
assertTrue( "Value of variable \"dayOfYear\" <" + val + "> not expected <200>.",
val == 200 );
}
// Test reading dayOfYear.
ucar.ma2.Array secondsOfDay = null;
try
{
secondsOfDay = meNcf.findVariable( "secondsOfDay").read();
}
catch ( IOException e )
{
assertTrue( "Unexpected IOException reading \"secondsOfDay\" variable: " + e.getMessage(),
false );
}
double prevVal = 0;
double curVal = 0;
double timeInterval = 0;
double timeIntervalGuess = 0.42;
double delta = 0.01;
iter = secondsOfDay.getIndexIterator();
if ( iter.hasNext())
{
prevVal = iter.getDoubleNext();
int timeStep = 1;
while (iter.hasNext())
{
curVal = iter.getDoubleNext();
timeInterval = curVal - prevVal;
StringBuffer tmpMsg = new StringBuffer( "Variable \"secondsOfDay\": [" )
.append( timeStep ).append( "]=<" ).append( curVal).append( ">, [")
.append( (timeStep-1) ).append( "]=<" ).append( prevVal ).append( "> difference <")
.append( timeInterval).append( "> not within delta <" ).append( delta )