void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException { Unit super_degree = CommonUnit.degree.scale(2.5); RealType lon = RealType.getRealType("lon", super_degree); DataReference ref = loadFile(); if (ref == null) { System.err.println("must specify netCDF file name"); System.exit(1); return; } FieldImpl netcdf_data = (FieldImpl) ref.getData(); // compute ScalarMaps from type components FunctionType ftype = (FunctionType) netcdf_data.getType(); RealTupleType dtype = ftype.getDomain(); MathType rntype = ftype.getRange(); int n = dtype.getDimension(); dpys[0].addMap(new ScalarMap((RealType) dtype.getComponent(0), Display.XAxis)); if (n > 1) { dpys[0].addMap(new ScalarMap((RealType) dtype.getComponent(1), Display.YAxis)); } if (n > 2) { dpys[0].addMap(new ScalarMap((RealType) dtype.getComponent(2), Display.ZAxis)); } if (rntype instanceof RealType) { dpys[0].addMap(new ScalarMap((RealType) rntype, Display.Green)); if (n <= 2) { dpys[0].addMap(new ScalarMap((RealType) rntype, Display.ZAxis)); } } else if (rntype instanceof RealTupleType) { int m = ((RealTupleType) rntype).getDimension(); RealType rr = (RealType) ((RealTupleType) rntype).getComponent(0); dpys[0].addMap(new ScalarMap(rr, Display.Green)); if (n <= 2) { if (m > 1) { rr = (RealType) ((RealTupleType) rntype).getComponent(1); } dpys[0].addMap(new ScalarMap(rr, Display.ZAxis)); } } dpys[0].addMap(new ConstantMap(0.5, Display.Red)); dpys[0].addMap(new ConstantMap(0.0, Display.Blue)); dpys[0].addReference(ref, null); System.out.println("now saving data as 'save.nc' and re-reading"); Plain plain = new Plain(); try { plain.save("save.nc", netcdf_data, true); netcdf_data = (FieldImpl) plain.open("save.nc"); } catch (IOException e) { System.err.println("Couldn't open \"save.nc\": " + e.getMessage()); System.exit(1); return; } }
/** * Load the volume data to the display * * @throws RemoteException problem loading remote data * @throws VisADException problem loading the data */ private void loadVolumeData() throws VisADException, RemoteException { Trace.call1("VRC.loadVolumeData"); FieldImpl grid = getGridDataInstance().getGrid(); FieldImpl newGrid = grid; if (getSkipValue() > 0) { grid = GridUtil.subset(grid, getSkipValue() + 1); newGrid = grid; } if (!usePoints) { // make sure the projection is correct before we start // transforming the data setProjectionInView(true, true); CoordinateSystem cs = getNavigatedDisplay().getDisplayCoordinateSystem(); if ((cs != null) && (getNavigatedDisplay() instanceof MapProjectionDisplay)) { try { if (GridUtil.isConstantSpatialDomain(grid)) { newGrid = makeLinearGrid(grid, cs); } else { Set timeSet = GridUtil.getTimeSet(grid); for (int i = 0; i < timeSet.getLength(); i++) { FieldImpl timeField = makeLinearGrid((FieldImpl) grid.getSample(i, false), cs); if (i == 0) { FunctionType ft = new FunctionType( ((SetType) timeSet.getType()).getDomain(), timeField.getType()); newGrid = new FieldImpl(ft, timeSet); } newGrid.setSample(i, timeField, false); } } } catch (VisADException ve) { ve.printStackTrace(); userErrorMessage( "Can't render volume for " + paramName + " in this projection. Try using the data projection"); newGrid = grid; } } } Trace.call1("VRC.loadVolumeData.loadData"); myDisplay.loadData(newGrid); Trace.call2("VRC.loadVolumeData.loadData"); Trace.call2("loadVolumeData"); }