Esempio n. 1
0
  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;
    }
  }
Esempio n. 2
0
  static {
    Unit min;
    Unit h;
    Unit d;
    Unit a;

    try {
      min = SECOND.scale(60).clone("min");
      h = min.scale(60).clone("h");
      d = h.scale(24).clone("d");
      a = SECOND.scale(3.15569259747e7).clone("a");
      instance = new TimeInterval();
    } catch (Exception e) {
      min = null; // to fool compiler
      h = null; // to fool compiler
      d = null; // to fool compiler
      a = null; // to fool compiler

      System.err.println("TimeInterval.<clinit>(): Couldn't initialize class: " + e);
      System.exit(1);
    }

    MINUTE = min;
    HOUR = h;
    DAY = d;
    YEAR = a;
  }
Esempio n. 3
0
 static {
   try {
     instance = new YSpeed();
   } catch (Exception e) {
     System.err.println("YSpeed.<clinit>(): Couldn't initialize class: " + e);
     System.exit(1);
   }
 }
Esempio n. 4
0
 /**
  * Test this out
  *
  * @param args filename
  * @throws Exception problem
  */
 public static void main(String[] args) throws Exception {
   if (args.length == 0) {
     System.err.println("need to supply a filename");
     System.exit(1);
   }
   ShapefileAdapter sfa = new ShapefileAdapter(args[0]);
   UnionSet data = sfa.getData();
   // System.out.println(data);
   visad.python.JPythonMethods.dumpTypes(data);
 }
Esempio n. 5
0
  private DataReferenceImpl loadFile() throws RemoteException, VisADException {
    FieldImpl data;
    try {
      data = (FieldImpl) new Plain().open(fileName);
    } catch (IOException e) {
      System.err.println("Couldn't open \"" + fileName + "\": " + e.getMessage());
      System.exit(1);
      return null;
    }
    // System.out.println("data type = " + data.getType());

    DataReferenceImpl ref = new DataReferenceImpl("netcdf");
    ref.setData(data);

    return ref;
  }
  static {
    Real mdp = null;
    Real mp = null;
    Real mws = null;

    try {
      mdp = (Real) DewPoint.getRealType().missingData();
      mp = (Real) AirPressure.getRealType().missingData();
      mws = (Real) WaterVaporMixingRatio.getRealType().missingData();
    } catch (Exception e) {
      System.err.print("Couldn't initialize class: ");
      e.printStackTrace();
      System.exit(1);
    }

    missingDewPoint = mdp;
    missingPres = mp;
    missingWsat = mws;
  }
Esempio n. 7
0
  static {
    CoordinateSystem coordSys;

    try {
      coordSys =
          new PolarCoordinateSystem(
              CartesianVelocity2D.instance().getRealTupleType(),
              Speed.DEFAULT_UNIT,
              PlaneAngle.DEFAULT_UNIT);
      instance =
          new PolarVelocity(
              "Polar_Velocity",
              (Speed) Speed.instance(),
              (PlaneAngle) PlaneAngle.instance(),
              coordSys);
    } catch (Exception e) {
      System.err.println("PolarVelocity.<clinit>(): Couldn't initialize class: " + e);
      System.exit(1);
    }
  }
Esempio n. 8
0
  void setupServerData(LocalDisplay[] dpys) throws RemoteException, VisADException {
    DefaultFamily df = new DefaultFamily("loader");

    DataReference ref1 = loadFile(df, file1, "img1");
    if (ref1 == null) {
      System.err.println("\"" + file1 + "\" is not a valid file");
      System.exit(1);
      return;
    }

    DataReference ref2 = loadFile(df, file2, "img2");
    if (ref2 == null) {
      System.err.println("\"" + file2 + "\" is not a valid file");
      System.exit(1);
      return;
    }

    FlatField img1 = (FlatField) ref1.getData();
    FlatField img2 = (FlatField) ref2.getData();

    /*
        if (!img1.getType().equals(img2.getType())) {
          System.err.println("Incompatible file types:");
          System.err.println("  " + file1 + ": " + img1.getType());
          System.err.println("  " + file2 + ": " + img2.getType());
          System.exit(1);
          return;
        }
    */

    // compute ScalarMaps from type components
    FunctionType ftype = (FunctionType) img1.getType();
    RealTupleType dtype = ftype.getDomain();
    RealTupleType rtype = (RealTupleType) ftype.getRange();

    /* map domain elements to spatial axes */
    final int dLen = dtype.getDimension();
    for (int i = 0; i < dLen; i++) {
      ScalarType scalT;
      DisplayRealType dpyRT;

      switch (i) {
        case 0:
          dpyRT = Display.XAxis;
          break;
        case 1:
          dpyRT = Display.YAxis;
          break;
        case 2:
          dpyRT = Display.ZAxis;
          break;
        default:
          dpyRT = null;
          break;
      }

      if (dpyRT != null) {
        dpys[0].addMap(new ScalarMap((RealType) dtype.getComponent(i), dpyRT));
      }
    }

    /* map range elements to colors */
    final int rLen = rtype.getDimension();
    for (int i = 0; i < rLen; i++) {
      ScalarType scalT;
      DisplayRealType dpyRT;

      switch (i) {
        case 0:
          dpyRT = Display.Red;
          break;
        case 1:
          dpyRT = Display.Green;
          break;
        case 2:
          dpyRT = Display.Blue;
          break;
        default:
          dpyRT = null;
          break;
      }

      if (dpyRT != null) {
        dpys[0].addMap(new ScalarMap((RealType) rtype.getComponent(i), dpyRT));
      }
    }

    dpys[0].addReference(ref1, null);
    dpys[0].addReference(ref2, null);

    dpys[0].addActivityHandler(new SwitchGIFs(dpys[0]));
  }