DssDataReader extends DataReader { @Override public VortexData getDto(int idx) { HecDSSFileAccess.setDefaultDSSFileName(path); String[] paths; if (variableName.contains("*")) { HecDssCatalog catalog = new HecDssCatalog(); paths = catalog.getCatalog(true, variableName); } else { paths = new String[1]; paths[0] = variableName; } String dssPath = paths[idx]; int[] status = new int[1]; GridData gridData = GridUtilities.retrieveGridFromDss(this.path, dssPath, status); if (gridData != null) { return dssToDto(gridData); } return null; } DssDataReader(DataReaderBuilder builder); @Override List<VortexData> getDtos(); static Set<String> getVariables(String pathToDss); @Override int getDtoCount(); @Override VortexData getDto(int idx);  }
@Test void TrinityXMRG2DSSImport() { String pathToDss = new File(getClass().getResource("/TrinityXMRG2DSS.dss").getFile()).toString(); DataReader reader = DataReader.builder() .path(pathToDss) .variable(" .build(); VortexGrid grid = (VortexGrid) reader.getDto(0); float[] gridData = grid.data(); String pathToGtiff = new File(getClass().getResource("/TrinityXMRG2DSS.tiff").getFile()).toString(); Dataset dataset = gdal.Open(pathToGtiff); double[] geoTransform = dataset.GetGeoTransform(); double dx = geoTransform[1]; double dy = geoTransform[5]; double originY = geoTransform[3]; int nx = dataset.GetRasterYSize(); int ny = dataset.GetRasterYSize(); Band band = dataset.GetRasterBand(1); float[] data = new float[nx * ny]; band.ReadRaster(0, 0, nx, ny, gdalconst.GDT_Float32, data); dataset.delete(); band.delete(); assertEquals(originY, grid.originY()); assertEquals(dx, grid.dx()); assertEquals(dy, grid.dy()); double expectedMax = Double.MIN_VALUE; double actualMax = Double.MIN_VALUE; int isEqualCount = 0; for (int i=0; i<data.length; i++) { expectedMax = Math.max(expectedMax, data[i]); actualMax = Math.max(actualMax, gridData[i]); if (Double.compare(data[i], gridData[i]) == 0) isEqualCount++; } System.out.println((double) isEqualCount / data.length); assertEquals(expectedMax, actualMax); }