Package xtc.typical

Examples of xtc.typical.Transformer$Attribute


    numSamplesPerBandDim = new Dimension(
            this.numSamplesPerBandDimName,
            numSamplesPerBand);

    // Read nominal resolution information
    nominalResolutionAtt = new Attribute( nominalResolutionAttName,
                                          (String) headerInfo.get( HeaderInfoTitle.NOMINAL_RESOLUTION.toString()));

    // Read bands per scanlin information.
    bandsPerScanlineAtt = new Attribute( bandsPerScanlineAttName,
                                         Integer.valueOf( (String) headerInfo.get( HeaderInfoTitle.BANDS_PER_SCANLINE.toString())));

    // Read bytes per smaple information
    bytesPerSampleAtt = new Attribute( bytesPerSampleAttName,
                                       Integer.valueOf( (String) headerInfo.get( HeaderInfoTitle.BYTES_PER_SAMPLE.toString())));;

    // Read byte offset for band 1 information.
    byteOffsetBand1Att = new Attribute( byteOffsetBand1AttName,
                                        Integer.valueOf( (String) headerInfo.get( HeaderInfoTitle.BYTE_OFFSET_BAND_1.toString())));

    // Read byte offset for band 2 information.
    byteOffsetBand2Att = new Attribute( byteOffsetBand2AttName,
                                        Integer.valueOf( (String) headerInfo.get( HeaderInfoTitle.BYTE_OFFSET_BAND_2.toString())));

    // Band 1 description
    band1Att = new Attribute( band1AttName, (String) headerInfo.get( HeaderInfoTitle.BAND_1.toString()));

    // Band 2 description
    band2Att = new Attribute( band2AttName, (String) headerInfo.get( HeaderInfoTitle.BAND_2.toString()));

    // Band organization
    bandOrganizationAtt = new Attribute( bandOrganizationAttName,
                                         (String) headerInfo.get( HeaderInfoTitle.ORGANIZATION.toString()));

    // thermal offset
    thermalOffsetAtt = new Attribute( thermalOffsetAttName,
                                      (String) headerInfo.get( HeaderInfoTitle.THERMAL_OFFSET.toString()));

    // thermal scale
    thermalScaleAtt = new Attribute( thermalScaleAttName,
                                      (String) headerInfo.get( HeaderInfoTitle.THERMAL_SCALE.toString()));

    // percent daylight
    percentDaylightAtt = new Attribute( percentDaylightAttName,
                                        Double.valueOf( (String) headerInfo.get( HeaderInfoTitle.PERCENT_DAYLIGHT.toString())));

    // percent full moon
    percentFullMoonAtt = new Attribute( percentFullMoonAttName,
                                        Double.valueOf( (String) headerInfo.get( HeaderInfoTitle.PERCENT_FULL_MOON.toString())));

    // percent terminator evident
    percentTerminatorEvidentAtt = new Attribute( percentTerminatorEvidentAttName,
                                        Double.valueOf( (String) headerInfo.get( HeaderInfoTitle.PERCENT_TERMINATOR_EVIDENT.toString())));
  }
View Full Code Here


   * Parse the sensor information from the header.
   */
  private void handleQCInformation()
  {
    // QC flags
    qcFlagsAtt = new Attribute( qcFlagsAttName,
                                (String) headerInfo.get( HeaderInfoTitle.QC_FLAGS.toString()));

  }
View Full Code Here

            Dimension ncDim = new Dimension(name, size, true);
            ncFile.addDimension(null, ncDim);
            if (name.equals(ENS_VAR)) {
                v = new Variable(ncFile, null, null, name, DataType.STRING,
                                 name);
                v.addAttribute(new Attribute("standard_name", "ensemble"));
                v.addAttribute(new Attribute(_Coordinate.AxisType,
                                             AxisType.Ensemble.toString()));
                List<String> names =
                    gradsDDF.getEnsembleDimension().getEnsembleNames();
                String[] nameArray = new String[names.size()];
                for (int i = 0; i < nameArray.length; i++) {
                    nameArray[i] = names.get(i);
                }
                Array dataArray = Array.factory(DataType.STRING,
                                      new int[] { nameArray.length },
                                      nameArray);
                v.setCachedData(dataArray, false);
            } else {
                double[] vals = dim.getValues();
                v = new Variable(ncFile, null, null, name, DataType.DOUBLE,
                                 name);
                v.addAttribute(new Attribute("units", dim.getUnit()));
                if (name.equals(Y_VAR)) {
                    v.addAttribute(new Attribute("long_name", "latitude"));
                    v.addAttribute(new Attribute("standard_name",
                            "latitude"));
                    v.addAttribute(new Attribute("axis", "Y"));
                    sizeY = dim.getSize();
                    v.addAttribute(new Attribute(_Coordinate.AxisType,
                            AxisType.Lat.toString()));
                } else if (name.equals(X_VAR)) {
                    v.addAttribute(new Attribute("long_name", "longitude"));
                    v.addAttribute(new Attribute("standard_name",
                            "longitude"));
                    v.addAttribute(new Attribute("axis", "X"));
                    v.addAttribute(new Attribute(_Coordinate.AxisType,
                            AxisType.Lon.toString()));
                    sizeX = dim.getSize();
                } else if (name.equals(Z_VAR)) {
                    numZ = size;
                    zDims.put(name, ncDim);
                    v.addAttribute(new Attribute("long_name", "level"));
                    addZAttributes(dim, v);
                } else if (name.equals(TIME_VAR)) {
                    v.addAttribute(new Attribute("long_name", "time"));
                    v.addAttribute(new Attribute(_Coordinate.AxisType,
                            AxisType.Time.toString()));
                }
                ArrayDouble.D1 varArray = new ArrayDouble.D1(size);
                for (int i = 0; i < vals.length; i++) {
                    varArray.set(i, vals[i]);
                }
                v.setCachedData(varArray, false);
            }
            ncFile.addVariable(null, v);
        }
        if (numZ > 0) {
            GradsDimension zDim = gradsDDF.getZDimension();
            double[]       vals = zDim.getValues();
            for (GradsVariable var : vars) {
                int nl = var.getNumLevels();
                if ((nl > 0) && (nl != numZ)) {
                    String name = Z_VAR + nl;
                    if (zDims.get(name) == null) {
                        Dimension ncDim = new Dimension(name, nl, true);
                        ncFile.addDimension(null, ncDim);
                        Variable vz = new Variable(ncFile, null, null, name,
                                          DataType.DOUBLE, name);
                        vz.addAttribute(new Attribute("long_name", name));
                        vz.addAttribute(new Attribute("units",
                                zDim.getUnit()));
                        addZAttributes(zDim, vz);
                        ArrayDouble.D1 varArray = new ArrayDouble.D1(nl);
                        for (int i = 0; i < nl; i++) {
                            varArray.set(i, vals[i]);
                        }
                        vz.setCachedData(varArray, false);
                        ncFile.addVariable(null, vz);
                        zDims.put(name, ncDim);
                    }
                }
            }
        }
        zDims = null;
        for (GradsVariable var : vars) {
            String coords = "latitude longitude";
            int    nl     = var.getNumLevels();
            if (nl > 0) {
                if (nl == numZ) {
                    coords = "level " + coords;
                } else {
                    coords = Z_VAR + nl + " " + coords;
                }
            }
            coords = "time " + coords;
            if (gradsDDF.getEnsembleDimension() != null) {
                coords = "ensemble " + coords;
            }
            v = new Variable(ncFile, null, null, var.getName(),
                             DataType.FLOAT, coords);
            v.addAttribute(new Attribute("long_name", var.getDescription()));
            if (var.getUnitName() != null) {
                v.addAttribute(new Attribute("units", var.getUnitName()));
            }
            v.addAttribute(
                new Attribute(
                    "_FillValue", new Float(gradsDDF.getMissingValue())));
            v.addAttribute(
                new Attribute(
                    "missing_value", new Float(gradsDDF.getMissingValue())));
            for (GradsAttribute attr : attrs) {
                if (attr.getVariable().equalsIgnoreCase(var.getName())) {
                    // TODO: what to do about a UINT16/32
                    if (attr.getType().equalsIgnoreCase(
                            GradsAttribute.STRING)) {
                        v.addAttribute(new Attribute(attr.getName(),
                                attr.getValue()));
                    } else if (attr.getType().equalsIgnoreCase(
                            GradsAttribute.BYTE)) {
                        try {
                            v.addAttribute(new Attribute(attr.getName(),
                                    new Byte(attr.getValue())));
                        } catch (NumberFormatException nfe) {}
                    } else if (attr.getType().equalsIgnoreCase(
                            GradsAttribute.INT16)) {
                        try {
                            v.addAttribute(new Attribute(attr.getName(),
                                    new Short(attr.getValue())));
                        } catch (NumberFormatException nfe) {}
                    } else if (attr.getType().equalsIgnoreCase(
                            GradsAttribute.INT32)) {
                        try {
                            v.addAttribute(new Attribute(attr.getName(),
                                    new Integer(attr.getValue())));
                        } catch (NumberFormatException nfe) {}
                    } else if (attr.getType().equalsIgnoreCase(
                            GradsAttribute.FLOAT32)) {
                        try {
                            v.addAttribute(new Attribute(attr.getName(),
                                    new Float(attr.getValue())));
                        } catch (NumberFormatException nfe) {}
                    } else if (attr.getType().equalsIgnoreCase(
                            GradsAttribute.FLOAT64)) {
                        try {
                            v.addAttribute(new Attribute(attr.getName(),
                                    new Double(attr.getValue())));
                        } catch (NumberFormatException nfe) {}
                    }
                }
            }
            ncFile.addVariable(null, v);
        }
        // Global Attributes
        ncFile.addAttribute(null, new Attribute("Conventions", "CF-1.0"));
        ncFile.addAttribute(
            null,
            new Attribute(
                "history",
                "Direct read of GrADS binary grid into NetCDF-Java 4 API"));
        String title = gradsDDF.getTitle();
        if ((title != null) && !title.isEmpty()) {
            ncFile.addAttribute(null, new Attribute("title", title));
        }
        for (GradsAttribute attr : attrs) {
            if (attr.getVariable().equalsIgnoreCase(GradsAttribute.GLOBAL)) {
                ncFile.addAttribute(null,
                                    new Attribute(attr.getName(),
                                        attr.getValue()));
            }
        }

    }
View Full Code Here

     * @param zDim  The GrADS Z dimension
     * @param v     the variable to augment
     */
    private void addZAttributes(GradsDimension zDim, Variable v) {
        if (zDim.getUnit().indexOf("Pa") >= 0) {
            v.addAttribute(new Attribute("positive", "down"));
            v.addAttribute(new Attribute(_Coordinate.AxisType,
                                         AxisType.Pressure.toString()));
        } else {
            v.addAttribute(new Attribute("positive", "up"));
            v.addAttribute(new Attribute(_Coordinate.AxisType,
                                         AxisType.Height.toString()));
        }
    }
View Full Code Here

    } catch (ParseException e) {
      throw new RuntimeException("Cant read start_date="+start_date);
    }

    Variable v = ds.findVariable("time_offset");
    v.addAttribute(new Attribute( "units", "seconds since "+dfo.toDateTimeString(start)));

    Group root = ds.getRootGroup();
    root.addAttribute(new Attribute( "Convention", "Suomi-Station-CDM"));   
    ds.finish();
  }
View Full Code Here

    StringTokenizer stoker = new StringTokenizer( timeVars, ", ");
    while (stoker.hasMoreTokens()) {
      String vname = stoker.nextToken();
      Variable v = ds.findVariable(vname);
      if (v != null) {
        v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
      } else {
        parseInfo.format(" cant find time variable %s\n", vname);
      }
    }

    String locVars = ds.findAttValueIgnoreCase(null, "stationLocationVariables", "");
    stoker = new StringTokenizer( locVars, ", ");
    int count = 0;
    while (stoker.hasMoreTokens()) {
      String vname = stoker.nextToken();
      Variable v = ds.findVariable(vname);
      if (v != null) {
        AxisType atype = count == 0 ? AxisType.Lat : count == 1 ? AxisType.Lon : AxisType.Height;
        v.addAttribute(new Attribute(_Coordinate.AxisType, atype.toString()));
      } else {
        parseInfo.format(" cant find time variable %s\n",vname);
      }
      count++;
    }
View Full Code Here

      v.addAttribute(ncatt);
    }

    // this is the case where its (probably) a Grid, and so _Coordinate.Axes has been assigned, but if
    // theres also a coordinates attribute, need to add that info
    Attribute axes = v.findAttribute("coordinates");
    Attribute _axes = v.findAttribute(_Coordinate.Axes);
    if ((null != axes) && (null != _axes)) {
      v.addAttribute(new Attribute(_Coordinate.Axes, axes.getStringValue() + " " + _axes.getStringValue()));
    }
  }
View Full Code Here

    }

    setDimensions( dims);
    setDataType( DODSNetcdfFile.convertToNCType(array.bt));
    if (DODSNetcdfFile.isUnsigned( array.bt)) {
      addAttribute(new Attribute("_Unsigned", "true"));
    }

    DODSAttribute att = new DODSAttribute(_Coordinate.Axes, sbuff.toString());
    this.addAttribute( att);
  }
View Full Code Here

        ds.addVariable(null, v);

        String xname = findCoordinateName(ds, AxisType.GeoX);
        String yname = findCoordinateName(ds, AxisType.GeoY);
        if (xname != null && yname != null)
          v.addAttribute(new Attribute(_Coordinate.Axes, xname + " " + yname));
      }
      ds.finish();
    }
View Full Code Here

        Variable lat = ncDataset.findVariable("radar_latitude");
        Variable lon = ncDataset.findVariable("radar_longitude");
        float    latv = (float)lat.readScalarDouble();
        float    lonv = (float)lon.readScalarDouble();
        Variable pv = ncDataset.findVariable("Projection");
        pv.addAttribute(new Attribute("longitude_of_projection_origin", lonv) );
        pv.addAttribute(new Attribute("latitude_of_projection_origin", latv) );

        Variable sdate = ncDataset.findVariable("start_date");
        Variable stime = ncDataset.findVariable("start_time");
        Variable tvar = ncDataset.findVariable("time");
        String dateStr = sdate.readScalarString();
View Full Code Here

TOP

Related Classes of xtc.typical.Transformer$Attribute

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.