Package org.wymiwyg.knobot

Examples of org.wymiwyg.knobot.BaseItemPostHandler$Dimension


        } else {
            for (int kk=0; kk < nparams; kk++) {  sweep_bins[kk]=bins;  }
        }

        // add Dimensions
        Dimension scanR=new Dimension("scanR", number_sweeps, true);
        Dimension radial=new Dimension("radial", num_rays, true);
        Dimension[] gateR=new Dimension[number_sweeps];
        String dim_name="gateR";
        for (int j=0; j<number_sweeps; j++) {
            if (number_sweeps > 1) { dim_name="gateR_sweep_"+(j+1); }
            gateR[j]=new Dimension(dim_name, sweep_bins[j], true);
        }
        ncfile.addDimension(null, scanR);
        ncfile.addDimension(null, radial);
        for (int j=0; j<number_sweeps; j++) {
            ncfile.addDimension(null, gateR[j]);
View Full Code Here


                        start = top;
                    }

                }

                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);

View Full Code Here

        timeDates[count++] = d;
      }

      // if we encountered NaNs, shorten it up
      if (count != ncoords) {
        Dimension localDim = new Dimension(getShortName(), count, false);
        setDimension(0, localDim);

        // set the shortened values
        Array shortData = Array.factory(data.getElementType(), new int[]{count});
        Index ima = shortData.getIndex();
View Full Code Here

    return false;
  }

  private boolean isStaggered2(CoordinateAxis axis, int dimIndex) {
    if (axis == null) return false;
    Dimension dim = axis.getDimension(dimIndex);
    if (dim == null) return false;
    if (dim.getName().endsWith("stag")) return true;
    return false;
}
View Full Code Here

    }
    return null;
  }

  static public String getDimensionName(NetcdfDataset ds, String key, Formatter errlog) {
    Dimension d = getDimension(ds, key, errlog);
    return (d == null) ? null : d.getName();
  }
View Full Code Here

    Dimension d = getDimension(ds, key, errlog);
    return (d == null) ? null : d.getName();
  }

  static public Dimension getDimension(NetcdfDataset ds, String key, Formatter errlog) {
    Dimension d = null;
    String s = getLiteral(ds, key, errlog);
    if (s != null) {
      d = ds.findDimension(s); // LOOK use group
      if ((d == null) && (errlog != null))
        errlog.format(" Cant find Variable %s from %s\n", s, key);
View Full Code Here

  private static Config buildConfig( NetcdfDataset ncd )
  {
    // Check that only one dimension and that it is named "time".
    List list = ncd.getRootGroup().getDimensions();
    if ( list.size() != 1) return null;
    Dimension d = (Dimension) list.get(0);
    if ( ! d.getName().equals( timeDimName)) return null;

    Config trajConfig = new Config();
    trajConfig.setTimeDim( d);

    // Check that have variable time(time) with units that are udunits time
    Variable var = ncd.getRootGroup().findVariable( timeVarName);
    if ( var == null) return null;
    list = var.getDimensions();
    if ( list.size() != 1) return null;
    d = (Dimension) list.get(0);
    if ( ! d.getName().equals( timeDimName)) return null;
    String units = var.findAttribute( "units").getStringValue();
    Date date = DateUnit.getStandardDate( "0 " + units);
    if ( date == null) return null;

    trajConfig.setTimeVar( var);

    // Check for variable latitude(time) with units of "deg".
    var = ncd.getRootGroup().findVariable( latVarName);
    if ( var == null ) return null;
    list = var.getDimensions();
    if ( list.size() != 1) return null;
    d = (Dimension) list.get(0);
    if ( ! d.getName().equals( timeDimName)) return null;
    units = var.findAttribute( "units").getStringValue();
    if ( ! SimpleUnit.isCompatible( units, "degrees_north")) return null;

    trajConfig.setLatVar( var);

    // Check for variable longitude(time) with units of "deg".
    var = ncd.getRootGroup().findVariable( lonVarName);
    if ( var == null ) return null;
    list = var.getDimensions();
    if ( list.size() != 1) return null;
    d = (Dimension) list.get(0);
    if ( ! d.getName().equals( timeDimName)) return null;
    units = var.findAttribute( "units").getStringValue();
    if ( ! SimpleUnit.isCompatible( units, "degrees_east")) return null;

    trajConfig.setLonVar( var);

    // Check for variable altitude(time) with units of "m".
    var = ncd.getRootGroup().findVariable( elevVarName);
    if ( var == null) return null;
    list = var.getDimensions();
    if ( list.size() != 1) return null;
    d = (Dimension) list.get(0);
    if ( ! d.getName().equals( timeDimName)) return null;
    units = var.findAttribute( "units").getStringValue();
    if ( ! SimpleUnit.isCompatible( units, "meters")) return null;

    trajConfig.setElevVar( var);
View Full Code Here

  {
    // Check that only one dimension and that it is named "time".

    List list = ncd.getRootGroup().getDimensions();
    if ( list.size() != 1) return null;
    Dimension d = (Dimension) list.get(0);
    if ( ! d.getName().equals( dimName)) return null;

    TrajectoryObsDatasetImpl.Config trajConfig = new TrajectoryObsDatasetImpl.Config();
    trajConfig.setTrajectoryDim( d);

    // Check that have variable time(time) with units that are udunits time
    Variable var = ncd.getRootGroup().findVariable( dimVarName);
    if ( var == null) return null;
    list = var.getDimensions();
    if ( list.size() != 1) return null;
    d = (Dimension) list.get(0);
    if ( ! d.getName().equals( dimName)) return null;
    String units = var.findAttribute( "units").getStringValue();
    if ( ! SimpleUnit.isCompatible( units, "km")) return null;

    trajConfig.setDimensionVar( var);

    // Check for variable latitude(time) with units of "deg".
    var = ncd.getRootGroup().findVariable( latVarName);
    if ( var == null ) return null;
    list = var.getDimensions();
    if ( list.size() != 1) return null;
    d = (Dimension) list.get(0);
    if ( ! d.getName().equals( dimName)) return null;
    units = var.findAttribute( "units").getStringValue();
    if ( ! SimpleUnit.isCompatible( units, "deg")) return null;

    trajConfig.setLatVar( var);

    // Check for variable longitude(time) with units of "deg".
    var = ncd.getRootGroup().findVariable( lonVarName);
    if ( var == null ) return null;
    list = var.getDimensions();
    if ( list.size() != 1) return null;
    d = (Dimension) list.get(0);
    if ( ! d.getName().equals( dimName)) return null;
    units = var.findAttribute( "units").getStringValue();
    if ( ! SimpleUnit.isCompatible( units, "deg")) return null;

    trajConfig.setLonVar( var);

    // Check for variable altitude(time) with units of "m".
    var = ncd.getRootGroup().findVariable( elevVarName);
    if ( var == null) return null;
    list = var.getDimensions();
    if ( list.size() != 1) return null;
    d = (Dimension) list.get(0);
    if ( ! d.getName().equals( dimName)) return null;
    units = var.findAttribute( "units").getStringValue();
    if ( ! SimpleUnit.isCompatible( units, "km")) return null;

    trajConfig.setElevVar( var);
View Full Code Here

    varElem.setAttribute("name", grid.getFullName());

    StringBuilder buff = new StringBuilder();
    List dims = grid.getDimensions();
    for (int i = 0; i < dims.size(); i++) {
      Dimension dim = (Dimension) dims.get(i);
      if (i > 0) buff.append(" ");
      if (dim.isShared())
        buff.append(dim.getName());
      else
        buff.append(dim.getLength());
    }
    if (buff.length() > 0)
      varElem.setAttribute("shape", buff.toString());

    DataType dt = grid.getDataType();
View Full Code Here

    if(format != null) {
        if(format.startsWith("nssl/netcdf"))
            return true;
    }

    Dimension az = ds.findDimension("Azimuth");
    Dimension gt = ds.findDimension("Gate");

    if ((null != az) && (null !=  gt)) {
        return true;
    }
        return false;
View Full Code Here

TOP

Related Classes of org.wymiwyg.knobot.BaseItemPostHandler$Dimension

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.