private void doRead3( GridDataset ds, String varName) throws IOException { GeoGrid gg = ds.findGridByName( varName); Array aa = gg.readDataSlice(-1,-1,-1,-1); int[] shape = aa.getShape(); int[] w = getWeights( gg); Index ima = aa.getIndex(); for (int i=0; i<shape[0]; i++) { for (int j=0; j<shape[1]; j++) { for (int k=0; k<shape[2]; k++) { double got = aa.getDouble( ima.set(i,j,k)); double want = ((double) (i*w[0] + j*w[1] + k*w[2])); assert (got == want) : "got "+got+ " want "+want; } } } System.out.println("ok reading "+varName); }
private void doRead4( GridDataset ds, String varName) throws IOException { GeoGrid gg = ds.findGridByName( varName); Array aa = gg.readDataSlice(-1,-1,-1,-1); int[] shape = aa.getShape(); Index ima = aa.getIndex(); int[] w = getWeights( gg); for (int i=0; i<shape[0]; i++) { for (int j=0; j<shape[1]; j++) { for (int k=0; k<shape[2]; k++) { for (int m=0; m<shape[3]; m++) { double got = aa.getDouble( ima.set(i,j,k,m)); double want = ((double) (i*w[0] + j*w[1] + k*w[2] + m*w[3])); assert (got == want) : "got "+got+ " want "+want; // System.out.println("got "+got+ " want "+want); } } } } System.out.println("ok reading "+varName); }
private void doRead3Volume( GridDataset ds, String varName) throws IOException { GeoGrid gg = ds.findGridByName( varName); CoordinateAxis1D timeAxis = gg.getCoordinateSystem().getTimeAxis1D(); int[] w = getWeights( gg); for (int t=0; t<timeAxis.getSize(); t++) { Array aa = gg.readVolumeData(t); int[] shape = aa.getShape(); Index ima = aa.getIndex(); for (int i=0; i<shape[0]; i++) { for (int j=0; j<shape[1]; j++) { double got = aa.getDouble( ima.set(i,j)); double want = ((double) (t*1000 + i*w[1] + j*w[2])); assert (got == want) : "got "+got+ " want "+want; } } } System.out.println("*** ok reading doRead3Volume for "+varName); }
private void doRead3XY( GridDataset ds, String varName) throws IOException { GeoGrid gg = ds.findGridByName( varName); CoordinateAxis1D zAxis = gg.getCoordinateSystem().getVerticalAxis(); int[] w = getWeights( gg); for (int z=0; z<zAxis.getSize(); z++) { Array aa = gg.readYXData(0, z); int[] shape = aa.getShape(); Index ima = aa.getIndex(); for (int i=0; i<shape[0]; i++) { for (int j=0; j<shape[1]; j++) { double got = aa.getDouble( ima.set(i,j)); double want = ((double) (z*100 + i*w[1] + j*w[2])); assert (got == want) : "got "+got+ " want "+want; } } } System.out.println("*** ok reading doRead3XY for "+varName); }
private void doWrite3( NetcdfFileWriter ncfile, String varName) throws Exception { Variable v = ncfile.findVariable( varName); int[] w = getWeights( v); int[] shape = v.getShape(); Array aa = Array.factory(v.getDataType(), shape); Index ima = aa.getIndex(); for (int i=0; i<shape[0]; i++) { for (int j=0; j<shape[1]; j++) { for (int k=0; k<shape[2]; k++) { aa.setDouble( ima.set(i,j,k), (double) (i*w[0] + j*w[1] + k*w[2])); } } } ncfile.write(varName, aa); }
private void doWrite4( NetcdfFileWriter ncfile, String varName) throws Exception { Variable v = ncfile.findVariable( varName); int[] w = getWeights( v); int[] shape = v.getShape(); Array aa = Array.factory(v.getDataType(), shape); Index ima = aa.getIndex(); for (int i=0; i<shape[0]; i++) { for (int j=0; j<shape[1]; j++) { for (int k=0; k<shape[2]; k++) { for (int m=0; m<shape[3]; m++) { aa.setDouble( ima.set(i,j,k,m), (double) (i*w[0] + j*w[1] + k*w[2] + m*w[3])); } } } } ncfile.write(varName, aa); }