@Category(NeedsCdmUnitTest.class) public void testSectionVsSectionNoReduce() throws IOException { setupReadDmspAsNetcdf(this.testFilePath, this.testDataFileName); assertTrue("Year variable not of rank one.", yearVar.getRank() == 1); assertTrue("Visible imagery variable not of rank two.", visVar.getRank() == 2); assertTrue("Infrared imagery variable not of rank two.", irVar.getRank() == 2); assertTrue("Visible and infrared imagery variables are different sizes (" + visSize + " vs " + irSize + ".", visSize == irSize); yearArray = yearVar.read("0:1:1"); } catch (InvalidRangeException e) { assertTrue("Unexpected InvalidRangeException reading \"year\" variable: " + e.getMessage(), false); } catch (IOException e) { assertTrue("Unexpected IOException reading \"year\" variable: " + e.getMessage(), false); assertTrue("Year array not rank 1 <" + yearRank + ">", yearRank == 1); visArray = visVar.read("0:0:1,0:1:1"); } catch (InvalidRangeException e) { assertTrue("Unexpected InvalidRangeException reading \"visibleImagery\" variable: " + e.getMessage(),
private void setupReadDmspAsNetcdf(String testFilePath, String testDataFileName) { // Register the DMSP IOServiceProvider. try { NetcdfFile.registerIOProvider(DMSPiosp.class); } catch (IllegalAccessException e) { assertTrue("Unexpected IllegalAccessException registering DMSPiosp: " + e.getMessage(), false); } catch (InstantiationException e) { assertTrue("Unexpected InstantiationException registering DMSPiosp: " + e.getMessage(), false); } // Make sure test DMSP file exists and such. File testFile = new File(testFilePath, testDataFileName); assertTrue("Test file <" + testFile.getAbsolutePath() + "> does not exist.", testFile.exists()); assertTrue("Test file <" + testFile.getAbsolutePath() + "> cannot be read.", testFile.canRead()); assertTrue("Test file <" + testFile.getAbsolutePath() + "> is a directory.", !testFile.isDirectory()); // Open test DMSP file as NetCDF file. try { meNcf = NetcdfFile.open(testFilePath + "/" + testDataFileName); } catch (IOException e) { assertTrue("Unexpected IOException opening DMSP file <" + testFile.getAbsolutePath() + ">: " + e.getMessage(), false); } }
assertTrue("Alternate date/time format string <" + DMSPHeader.DateFormatHandler.ALT_DATE_TIME.getDateTimeFormatString() + "> not as expected <" + altDateTimeFormatString + ">.", DMSPHeader.DateFormatHandler.ALT_DATE_TIME.getDateTimeFormatString().equals(altDateTimeFormatString)); testDate = DMSPHeader.DateFormatHandler.ALT_DATE_TIME.getDateFromDateTimeString(targetDate1AltDateTimeString); } catch (ParseException e) { assertTrue("Unexpected ParseException while parsing date/time string <" + targetDate1AltDateTimeString + ">: " + e.getMessage(), false); assertTrue("Alternate date/time <" + testDate + "> not as expected <" + targetDate1.toString() + ">.", testDate.equals(targetDate1)); assertTrue("Date/time string <" + testDateTimeString + "> not as expected <" + targetDate1AltDateTimeString + ">.", testDateTimeString.equals(targetDate1AltDateTimeString));
@Category(NeedsCdmUnitTest.class) public void testReadEpoch() throws IOException { setupReadDmspAsNetcdf(this.testFilePath, this.testDataFileName); year = meNcf.findVariable("year").read(); } catch (IOException e) { assertTrue("Unexpected IOException reading \"year\" variable: " + e.getMessage(), false); while (iter.hasNext()) { val = iter.getIntNext(); assertTrue("Value of variable \"year\" <" + val + "> not expected <2003>.", val == 2003); dayOfYear = meNcf.findVariable("dayOfYear").read(); } catch (IOException e) { assertTrue("Unexpected IOException reading \"dayOfYear\" variable: " + e.getMessage(), false); while (iter.hasNext()) { val = iter.getIntNext(); assertTrue("Value of variable \"dayOfYear\" <" + val + "> not expected <200>.", val == 200); secondsOfDay = meNcf.findVariable("secondsOfDay").read(); } catch (IOException e) { assertTrue("Unexpected IOException reading \"secondsOfDay\" variable: " + e.getMessage(), false); .append(timeInterval).append("> not within delta <").append(delta)
@Category(NeedsCdmUnitTest.class) public void testLatLonCalcAndCache() throws IOException { setupReadDmspAsNetcdf(this.testFilePath, this.testDataFileName); latitude = latVar.read(); } catch (IOException e) { assertTrue("Unexpected IOException reading \"latitude\" variable: " + e.getMessage(), false); assertTrue("Biggest difference in latitude between neighboring pixels of the first scan <" + biggestDiff + "> bigger than expected <0.004>.", biggestDiff < 0.004); assertTrue("Smallest difference in latitude between neighboring pixels of the first scan <" + smallestDiff + "> smaller than expected <0.002>.", smallestDiff > 0.002); latPointAfterModify = latVar.read("0:0:1,0:0:1"); } catch (InvalidRangeException e) { assertTrue("Unexpected InvalidRangeException reading \"latitude\" variable: " + e.getMessage(), false); } catch (IOException e) { assertTrue("Unexpected IOException reading \"latitude\" variable: " + e.getMessage(), false); assertTrue("Value of lat[0,0] <" + lat1 + "> changed <" + lat1After + ">", lat1 == lat1After);
setupReadDmspAsNetcdf(this.testFilePath, this.testDataFileName); assertTrue("Created NetcdfFile is null.", meNcf != null); assertTrue("Number of data records <" + curDim.getLength() + "> not as expected <" + this.testDataFileNumDataRecordsAttValue + ">.", curDim.getLength() == this.testDataFileNumDataRecordsAttValue); assertTrue("Number of bytes per records <" + curDim.getLength() + "> not as expected <" + this.testDataFileNumSamplesPerBandDimAttValue + ">.", curDim.getLength() == this.testDataFileNumSamplesPerBandDimAttValue); assertTrue("FileId attribute <" + curAtt.getStringValue() + "> not as expected <" + this.testDataFileFileIdAttValue + ">.", curAtt.getStringValue().equals(this.testDataFileFileIdAttValue)); assertTrue("DatasetId attribute <" + curAtt.getStringValue() + "> not as expected <" + this.testDataFileDatasetIdAttValue + ">.", curAtt.getStringValue().equals(this.testDataFileDatasetIdAttValue)); assertTrue("SuborbitHistory attribute <" + curAtt.getStringValue() + "> not as expected <" + this.testDataFileSuborbitHistoryAttValue + ">.", curAtt.getStringValue().equals(this.testDataFileSuborbitHistoryAttValue)); assertTrue("ProcessingSystem attribute <" + curAtt.getStringValue() + "> not as expected <" + this.testDataFileProcessingSystemAttValue + ">.", curAtt.getStringValue().equals(this.testDataFileProcessingSystemAttValue)); assertTrue("ProcessingDate attribute <" + curAtt.getStringValue() + "> not as expected <" + this.testDataFileProcessingDateAttValue + ">.", curAtt.getStringValue().equals(this.testDataFileProcessingDateAttValue)); assertTrue("SpacecraftId attribute <" + curAtt.getStringValue() + "> not as expected <" + this.testDataFileSpacecraftIdAttValue + ">.", curAtt.getStringValue().equals(this.testDataFileSpacecraftIdAttValue)); assertTrue("ProcessingDate attribute <" + curAtt.getStringValue() + "> not as expected <" + this.testDataFileNoradIdAttValue + ">.", curAtt.getStringValue().equals(this.testDataFileNoradIdAttValue));