示例#1
0
 static double getValue(CompoundData compoundData, String name) throws IOException {
   CompoundType type = compoundData.getType();
   int memberIndex = type.getMemberIndex(name);
   double v = compoundData.getDouble(memberIndex);
   double scalingFactor = getScalingFactor(type.getMember(memberIndex));
   return v * scalingFactor;
 }
示例#2
0
 private void readCalibrationCoefficients(int rawY, int[] calibCoeff) throws IOException {
   CompoundData dataRecord = noaaFile.getDataRecord(rawY);
   SequenceData calibration_coefficients = dataRecord.getSequence("CALIBRATION_COEFFICIENTS");
   for (int i = 0; i < calibCoeff.length; i++) {
     calibCoeff[i] = calibration_coefficients.getInt(i);
   }
 }
示例#3
0
  @Override
  public final Calibrator createCalibrator(int i) throws IOException {
    final SequenceData coefficientsSequence = provider.getCalibrationCoefficients(i);
    final CompoundData coefficients = coefficientsSequence.getCompound(channelIndex);
    final double slope = coefficients.getInt(0) * slopeScaleFactor;
    final double intercept = coefficients.getInt(1) * interceptScaleFactor;

    return new CoefficientCalibrator(this, slope, intercept);
  }
示例#4
0
 public MetadataElement getAsMetadataElement(CompoundData compoundData) throws IOException {
   CompoundType type = compoundData.getType();
   final int memberCount = type.getMemberCount();
   MetadataElement metadataElement = new MetadataElement(type.getName());
   for (int i = 0; i < memberCount; i++) {
     String typeName = type.getMemberName(i);
     CompoundMember member = type.getMember(i);
     FormatMetadata formatMetadata = (FormatMetadata) member.getMetadata();
     if (typeName.equals("fill")) {
       // ignore
     } else if (formatMetadata != null && formatMetadata.getType().equals("string")) {
       String stringValue = getAsString(compoundData.getSequence(i));
       Map<Object, String> map = getMetaData(member).getItemMap();
       if (map != null) {
         stringValue = map.get(stringValue);
       }
       ProductData data = ProductData.createInstance(stringValue);
       MetadataAttribute attribute = new MetadataAttribute(typeName, data, true);
       attribute.setDescription(getDescription(member));
       attribute.setUnit(getUnits(member));
       metadataElement.addAttribute(attribute);
     } else if (member.getType().getName().equals("DATE")) {
       CompoundData dateCompound = compoundData.getCompound(i);
       ProductData data = createDate(dateCompound);
       MetadataAttribute attribute = new MetadataAttribute(typeName, data, true);
       attribute.setDescription(getDescription(member));
       attribute.setUnit(getUnits(member));
       metadataElement.addAttribute(attribute);
     } else if (member.getType().isSequenceType()) {
       SequenceData sequence = compoundData.getSequence(i);
       for (int j = 0; j < sequence.getType().getElementCount(); j++) {
         CompoundData compound = sequence.getCompound(j);
         metadataElement.addElement(getAsMetadataElement(compound));
       }
     } else if (member.getType().isCompoundType()) {
       metadataElement.addElement(getAsMetadataElement(compoundData.getCompound(i)));
     } else if (member.getType().isSimpleType()) {
       int intValue = compoundData.getInt(i);
       Map<Object, String> map = getMetaData(member).getItemMap();
       ProductData data;
       if (map != null) {
         String stringValue = map.get(intValue);
         data = ProductData.createInstance(stringValue);
       } else {
         double scalingFactor = getMetaData(member).getScalingFactor();
         if (scalingFactor == 1.0) {
           data = ProductData.createInstance(new int[] {intValue});
         } else {
           data = ProductData.createInstance(new double[] {intValue * scalingFactor});
         }
       }
       MetadataAttribute attribute = new MetadataAttribute(typeName, data, true);
       attribute.setDescription(getDescription(member));
       attribute.setUnit(getUnits(member));
       metadataElement.addAttribute(attribute);
     } else {
       System.out.println("not handled: name=" + typeName);
       System.out.println("member = " + member.getType());
     }
   }
   return metadataElement;
 }
示例#5
0
 static ProductData.UTC createDate(CompoundData dateCompound) throws IOException {
   int year = dateCompound.getInt("year");
   int dayOfYear = dateCompound.getInt("dayOfYear");
   int millisInDay = dateCompound.getInt("UTCmillis");
   return HeaderUtil.createUTCDate(year, dayOfYear, millisInDay);
 }