Package flex2.compiler.fxg

Examples of flex2.compiler.fxg.FlexFXG2SWFTranscoder$Variable


        for (int j=0; j<nparams; j++) {
            int tp=type[j];
            var_name=data_name[tp];
            for (int jj=0; jj<number_sweeps; jj++) {
                if (number_sweeps > 1) {  var_name=data_name[tp]+"_sweep_"+(jj+1); }
                v[j][jj]=new Variable(ncfile, null, null, var_name);
                v[j][jj].setDataType(DataType.FLOAT);
                dims2.add(radial);
                dims2.add(gateR[jj]);
                v[j][jj].setDimensions(dims2);
                v[j][jj].addAttribute(new Attribute( "long_name", var_name));
                v[j][jj].addAttribute(new Attribute( "units", unit[tp]));
                String coordinates="time elevationR azimuthR distanceR";
                v[j][jj].addAttribute(new Attribute(_Coordinate.Axes, coordinates));
                v[j][jj].addAttribute(new Attribute("missing_value", -999.99f));
                ncfile.addVariable(null, v[j][jj]);
                varList.add(v[j][jj]);
                dims2.clear();
            }
        }
        tsu_sec=new int[number_sweeps];
        String[] tsu=new String[number_sweeps];
        String[] time_units=new String[number_sweeps];
        tsu_sec=volScan.getStartSweep();
        for (int i=0; i< number_sweeps; i++) {
            String st1=Short.toString(month);
            if (st1.length() < 2) st1="0"+st1;
            String st2=Short.toString(day);
            if (st2.length() < 2) st2="0"+st2;
            date0=String.valueOf(year)+"-"+st1+"-"+st2;
            tsu[i]=date0+"T"+calcTime(tsu_sec[i],0)+"Z";
        }
        for (int j=0; j<number_sweeps; j++) { time_units[j]="secs since "+tsu[j]; }

        dims0.add(radial);
        // add "time" variable
        Variable[] time=new Variable[number_sweeps];
        String tm="time";   String tm_name="";
        for (int j=0; j<number_sweeps; j++) {  tm_name=tm;
        if (number_sweeps > 1) { tm_name=tm+"_sweep_"+(j+1)}
        time[j]=new Variable(ncfile, null, null, tm_name);
        time[j].setDataType(DataType.INT);
        time[j].setDimensions(dims0);
        time[j].addAttribute(new Attribute("long_name", "time from start of sweep"));
        time[j].addAttribute(new Attribute("units", time_units[j]));
        time[j].addAttribute( new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
        time[j].addAttribute(new Attribute("missing_value", -99));
        ncfile.addVariable(null, time[j]);
        varList.add(time[j]);
        }

        // add "elevationR" variable
        Variable[] elevationR=new Variable[number_sweeps];
        String ele="elevationR";   String ele_name="";
        for (int j=0; j<number_sweeps; j++) {  ele_name=ele;
        if (number_sweeps > 1) { ele_name=ele+"_sweep_"+(j+1)}
        elevationR[j]=new Variable(ncfile, null, null, ele_name);
        elevationR[j].setDataType(DataType.FLOAT);
        elevationR[j].setDimensions(dims0);
        elevationR[j].addAttribute(new Attribute("long_name", "elevation angle"));
        elevationR[j].addAttribute(new Attribute("units", "degrees"));
        elevationR[j].addAttribute(new Attribute(_Coordinate.AxisType, AxisType.RadialElevation.toString()));
        elevationR[j].addAttribute(new Attribute("missing_value", -999.99f));
        ncfile.addVariable(null, elevationR[j]);
        varList.add(elevationR[j]);
        }

        // add "azimuthR" variable
        Variable[] azimuthR=new Variable[number_sweeps];
        String azim="azimuthR";   String azim_name="";
        for (int j=0; j<number_sweeps; j++) {  azim_name=azim;
        if (number_sweeps > 1) { azim_name=azim+"_sweep_"+(j+1)}
        azimuthR[j]=new Variable(ncfile, null, null, azim_name);
        azimuthR[j].setDataType(DataType.FLOAT);
        azimuthR[j].setDimensions(dims0);
        azimuthR[j].addAttribute(new Attribute("long_name", "azimuth angle"));
        azimuthR[j].addAttribute(new Attribute("units", "degrees"));
        azimuthR[j].addAttribute(new Attribute(_Coordinate.AxisType, AxisType.RadialAzimuth.toString()));
        azimuthR[j].addAttribute(new Attribute("missing_value", -999.99f));
        ncfile.addVariable(null, azimuthR[j]);
        varList.add(azimuthR[j]);
        }

        // add "distanceR" variable
        Variable[] distanceR=new Variable[number_sweeps];
        String dName="distanceR";
        String dist_name="";
        for (int j=0; j<number_sweeps; j++) {  dist_name=dName;
        if (number_sweeps > 1) { dist_name=dName+"_sweep_"+(j+1)}
        distanceR[j]=new Variable(ncfile, null, null, dist_name);
        distanceR[j].setDataType(DataType.FLOAT);
        dims1.add(gateR[j]);
        distanceR[j].setDimensions(dims1);
        distanceR[j].addAttribute(new Attribute("long_name", "radial distance"));
        distanceR[j].addAttribute(new Attribute("units", "m"));
        distanceR[j].addAttribute(new Attribute(_Coordinate.AxisType, AxisType.RadialDistance.toString()));
        ncfile.addVariable(null, distanceR[j]);
        varList.add(distanceR[j]);
        dims1.clear();
        }
        // add "numGates" variable
        dims3.add(scanR);
        Variable numGates=new Variable(ncfile, null, null, "numGates");
        numGates.setDataType(DataType.INT);
        numGates.setDimensions(dims3);
        numGates.addAttribute(new Attribute("long_name", "number of gates in the sweep"));
        ncfile.addVariable(null, numGates);
        varList.add(numGates);

        // add global attributes
        ncfile.addAttribute(null, new Attribute("definition", "SIGMET-IRIS RAW"));
View Full Code Here


                    }

                }

                Dimension dim       = ds.findDimension("MSL_alt");
                Variable  dimV      = ds.findVariable("MSL_alt");
                Array     dimU      = dimV.read();
                int       inscr = (dimU.getFloat(1) - dimU.getFloat(0)) > 0
                                  ? 1
                                  : 0;
                int       n         = dim.getLength();
                double    incr      = (stop - start) / n;

                String    timeUnits = "seconds since 1980-01-06 00:00:00";
                Variable timeVar = new VariableDS(ds, null, null, "time",
                                       DataType.DOUBLE, dim.getName(),
                                       timeUnits, null);
                ds.addVariable(null, timeVar);
                timeVar.addAttribute(new Attribute("units", timeUnits));
                timeVar.addAttribute(new Attribute(_Coordinate.AxisType,
                        AxisType.Time.toString()));
                int dir = ds.readAttributeInteger(null, "irs", 1);
                ArrayDouble.D1 data =
                    (ArrayDouble.D1) Array.factory(DataType.DOUBLE,
                        new int[] { n });
                if (inscr == 0) {
                    if (dir == 1) {
                        for (int i = 0; i < n; i++) {
                            data.set(i, start + i * incr);
                        }
                    } else {
                        for (int i = 0; i < n; i++) {
                            data.set(i, stop - i * incr);
                        }
                    }
                } else {
                    for (int i = 0; i < n; i++) {
                        data.set(i, stop - i * incr);
                    }
                }
                timeVar.setCachedData(data, false);
            }

            Variable v = ds.findVariable("Lat");
            if (v == null) {
                v = ds.findVariable("GEO_lat");
            }
            v.addAttribute(new Attribute(_Coordinate.AxisType,
                                         AxisType.Lat.toString()));
            Variable v1 = ds.findVariable("Lon");
            if (v1 == null) {
                v1 = ds.findVariable("GEO_lon");
            }
            v1.addAttribute(new Attribute(_Coordinate.AxisType,
                                          AxisType.Lon.toString()));
        } else {
            Dimension dim = ds.findDimension("time");
            int       n   = dim.getLength();
            Variable latVar = new VariableDS(ds, null, null, "Lat",
                                             DataType.FLOAT, dim.getName(),
                                             "degree", null);
            latVar.addAttribute(new Attribute(_Coordinate.AxisType,
                    AxisType.Lat.toString()));
            ds.addVariable(null, latVar);
            Variable lonVar = new VariableDS(ds, null, null, "Lon",
                                             DataType.FLOAT, dim.getName(),
                                             "degree", null);
            lonVar.addAttribute(new Attribute(_Coordinate.AxisType,
                    AxisType.Lon.toString()));
            ds.addVariable(null, lonVar);
            Variable altVar = new VariableDS(ds, null, null, "MSL_alt",
                                             DataType.FLOAT, dim.getName(),
                                             "meter", null);
            altVar.addAttribute(new Attribute(_Coordinate.AxisType,
                    AxisType.Height.toString()));
            ds.addVariable(null, altVar);

            // cal data array
            ArrayFloat.D1 latData =
                (ArrayFloat.D1) Array.factory(DataType.FLOAT,
                    new int[] { n });
            ArrayFloat.D1 lonData =
                (ArrayFloat.D1) Array.factory(DataType.FLOAT,
                    new int[] { n });
            ArrayFloat.D1 altData =
                (ArrayFloat.D1) Array.factory(DataType.FLOAT,
                    new int[] { n });
            ArrayDouble.D1 timeData =
                (ArrayDouble.D1) Array.factory(DataType.DOUBLE,
                    new int[] { n });
            this.conventionName = "Cosmic3";

            int iyr  = ds.readAttributeInteger(null, "year", 2009);
            int mon  = ds.readAttributeInteger(null, "month", 0);
            int iday = ds.readAttributeInteger(null, "day", 0);
            int ihr  = ds.readAttributeInteger(null, "hour", 0);
            int min  = ds.readAttributeInteger(null, "minute", 0);
            int sec  = ds.readAttributeInteger(null, "second", 0);

            double start = ds.readAttributeDouble(null, "startTime",
                               Double.NaN);
            double stop = ds.readAttributeDouble(null, "stopTime",
                              Double.NaN);
            double incr = (stop - start) / n;
            int    t    = 0;
            // double julian = juday(mon, iday, iyr);
            // cal the dtheta based pm attributes
            double   dtheta = gast(iyr, mon, iday, ihr, min, sec, t);

            Variable tVar   = ds.findVariable("time");
            String timeUnits = "seconds since 1980-01-06 00:00:00"//dtime.getUnit().toString();
            tVar.removeAttributeIgnoreCase("valid_range");
            tVar.removeAttributeIgnoreCase("units");
            tVar.addAttribute(new Attribute("units", timeUnits));
            tVar.addAttribute(new Attribute(_Coordinate.AxisType,
                                            AxisType.Time.toString()));

            Variable v    = ds.findVariable("xLeo");
            Array    xLeo = v.read();
            v = ds.findVariable("yLeo");
            Array yLeo = v.read();
            v = ds.findVariable("zLeo");
            Array         zLeo   = v.read();
            Array         tArray = tVar.read();
            double        pi     = 3.1415926;
            double        a      = 6378.1370;
            double        b      = 6356.7523142;
            IndexIterator iiter0 = xLeo.getIndexIterator();
View Full Code Here

  public void testReadCompressedInt() throws IOException {
    // actually doesnt seem to be compressed ??

    NetcdfFile ncfile = TestH5.openH5("support/zip.h5");
    Variable dset = ncfile.findVariable("Data/Compressed_Data");
    assert dset != null;
    assert(dset.getDataType() == DataType.INT);

    assert(dset.getRank() == 2);
    assert(dset.getShape()[0] == 1000);
    assert(dset.getShape()[1] == 20);

    // read entire array
    Array A = dset.read();
    assert(A.getRank() == 2);
    assert(A.getShape()[0] == 1000);
    assert(A.getShape()[1] == 20);

    int[] shape = A.getShape();
View Full Code Here

  public void testReadCompressedByte() throws IOException {
    // actually doesnt seem to be compressed ??

    NetcdfFile ncfile = TestH5.openH5("msg/MSG1_8bit_HRV.H5");
    Variable dset = ncfile.findVariable("image1/image_preview");
    assert dset != null;
    assert(dset.getDataType() == DataType.BYTE);

    assert(dset.getRank() == 2);
    assert(dset.getShape()[0] == 64);
    assert(dset.getShape()[1] == 96);

    // read entire array
    Array A = dset.read();
    assert(A.getRank() == 2);
    assert(A.getShape()[0] == 64);
    assert(A.getShape()[1] == 96);

    byte[] firstRow = new byte[] {
View Full Code Here

  }

  public void testEndian() throws IOException {
    String testDir = TestN4.testDir;
    NetcdfFile ncfile = TestNC2.open(testDir+"endianTest.nc4");
    Variable v = ncfile.findVariable("TMP");
    assert v != null;
    assert v.getDataType() == DataType.FLOAT;

    Array data = v.read();
    assert data.getElementType() == float.class;

    //large values indicate incorrect inflate or byte swapping
    while (data.hasNext()) {
      float val = data.nextFloat();
View Full Code Here

  }

  public void testReadArrayType() throws IOException {
    NetcdfFile ncfile = TestH5.openH5("support/SDS_array_type.h5");

    Variable dset = null;
    assert(null != (dset = ncfile.findVariable("IntArray")));
    assert(dset.getDataType() == DataType.INT);

    assert(dset.getRank() == 3);
    assert(dset.getShape()[0] == 10);
    assert(dset.getShape()[1] == 5);
    assert(dset.getShape()[2] == 4);

    // read entire array
    Array A;
    try {
      A = dset.read();
    }
    catch (IOException e) {
      System.err.println("ERROR reading file");
      assert(false);
      return;
    }
    assert(A.getRank() == 3);

    Index ima = A.getIndex();
    int[] shape = A.getShape();

    for (int i = 0; i < shape[0]; i++)
      for (int j = 0; j < shape[1]; j++)
        for (int k = 0; k < shape[2]; k++)
          if (A.getInt(ima.set(i, j, k)) != i) {
            assert false;
          }


          // read part of array
    dset.setCachedData(null, false); // turn off caching to test read subset
    dset.setCaching(false);
    int[] origin2 = new int[3];
    int[] shape2 = new int[] {
        10, 1, 1};
    try {
      A = dset.read(origin2, shape2);
    }
    catch (InvalidRangeException e) {
      System.err.println("ERROR reading file " + e);
      assert(false);
      return;
View Full Code Here

  }

  public void testVlengthVariableChunked() throws IOException {
    NetcdfFile ncfile = TestH5.openH5("support/uvlstr.h5");

    Variable v = ncfile.findVariable("Space1");
    assert (null != v);
    assert (v.getDataType() == DataType.STRING);
    assert (v.getRank() == 1);
    assert (v.getShape()[0] == 9);

    try {
      Array data = v.read();
      assert (data.getElementType() == String.class);
      assert (data instanceof ArrayObject);
      IndexIterator iter = data.getIndexIterator();
      while (iter.hasNext()) {
        out.println(iter.next());
      }

    } catch (IOException e) {
      e.printStackTrace();
      assert false;
    }

    int[] origin = new int[]{3};
    int[] shape = new int[]{3};
    try {
      Array data2 = v.read(origin, shape);
      Index ima = data2.getIndex();
      assert (data2.getElementType() == String.class);
      assert (data2 instanceof ArrayObject);
      assert ((String) data2.getObject(ima.set(0))).startsWith("testing whether that nation");
      assert ((String) data2.getObject(ima.set(1))).startsWith("O Gloria inmarcesible!");
View Full Code Here

  } // */

  public void testVlengthVariable() throws IOException {
    NetcdfFile ncfile = TestH5.openH5("support/vlslab.h5");

    Variable v = ncfile.findVariable("Space1");
    assert (null != v);
    assert (v.getDataType() == DataType.STRING);
    assert (v.getRank() == 1);
    assert (v.getShape()[0] == 12);

    try {
      Array data = v.read();
      assert (data.getElementType() == String.class);
      assert (data instanceof ArrayObject);
      IndexIterator iter = data.getIndexIterator();
      while (iter.hasNext()) {
        out.println(iter.next());
      }

    } catch (IOException e) {
      assert false;
    }

    int[] origin = new int[]{4};
    int[] shape = new int[]{1};
    try {
      Array data2 = v.read(origin, shape);
      Index ima = data2.getIndex();
      assert (data2.getElementType() == String.class);
      assert (data2 instanceof ArrayObject);
      assert ((String) data2.getObject(ima.set(0))).equals("Five score and seven years ago our forefathers brought forth on this continent a new nation,");
    }
View Full Code Here

  }

  private void testVlenEndian(String filename, int n) throws IOException {
    NetcdfFile ncfile = NetcdfDataset.openFile(filename, null);

    Variable v = ncfile.findVariable("levels");
    assert (null != v);
    assert (v.getDataType() == DataType.INT);
    assert (v.getRank() == 2);
    assert (v.getShape()[0] == n) : v.getShape()[0];

    try {
      Array data = v.read();
      // assert(data.getElementType() instanceof ucar.ma2.ArrayInt.class) : data.getElementType();
      assert (data instanceof ArrayObject);
      IndexIterator iter = data.getIndexIterator();
      while (iter.hasNext()) {
        Array inner = (Array) iter.next();
View Full Code Here

  }

  public void test1() throws IOException {
    //H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    NetcdfFile ncfile = TestH5.open(testDir +"HIRDLS1_v4.0.2a-aIrix-c2_2003d106.he5");
    Variable dset = ncfile.findVariable("HDFEOS/SWATHS/HIRDLS_L1_Swath/Data Fields/Scaled Ch01 Radiance");
    dset.read();
  }
View Full Code Here

TOP

Related Classes of flex2.compiler.fxg.FlexFXG2SWFTranscoder$Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.