Beispiel #1
0
  public void addBandMetadata(Product product) throws ProductIOException {
    Group group = ncFile.findGroup("Geophysical_Data");
    if (productReader.getProductType() == SeadasProductReader.ProductType.Level2_Aquarius) {
      group = ncFile.findGroup("Aquarius_Data");
    }
    if (productReader.getProductType() == SeadasProductReader.ProductType.Level1B_HICO) {
      group = ncFile.findGroup("products");
    }
    if (group != null) {
      final MetadataElement bandAttributes = new MetadataElement("Band_Attributes");
      List<Variable> variables = group.getVariables();
      for (Variable variable : variables) {
        final String name = variable.getShortName();
        final MetadataElement sdsElement = new MetadataElement(name + ".attributes");
        final int dataType = getProductDataType(variable);
        final MetadataAttribute prodtypeattr = new MetadataAttribute("data_type", dataType);

        sdsElement.addAttribute(prodtypeattr);
        bandAttributes.addElement(sdsElement);

        final List<Attribute> list = variable.getAttributes();
        for (Attribute varAttribute : list) {
          addAttributeToElement(sdsElement, varAttribute);
        }
      }
      final MetadataElement metadataRoot = product.getMetadataRoot();
      metadataRoot.addElement(bandAttributes);
    }
  }
Beispiel #2
0
  private ProductData.UTC getUTCAttribute(String key, List<Attribute> globalAttributes) {
    Attribute attribute = findAttribute(key, globalAttributes);
    Boolean isModis = false;
    try {
      isModis = findAttribute("MODIS_Resolution", globalAttributes).isString();
    } catch (Exception ignored) {
    }

    if (attribute != null) {
      String timeString = attribute.getStringValue().trim();
      final DateFormat dateFormat = ProductData.UTC.createDateFormat("yyyyDDDHHmmssSSS");
      final DateFormat dateFormatModis =
          ProductData.UTC.createDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS");
      final DateFormat dateFormatOcts =
          ProductData.UTC.createDateFormat("yyyyMMdd HH:mm:ss.SSSSSS");
      try {
        if (isModis) {
          final Date date = dateFormatModis.parse(timeString);
          String milliSeconds = timeString.substring(timeString.length() - 3);
          return ProductData.UTC.create(date, Long.parseLong(milliSeconds) * 1000);
        } else if (productReader.getProductType() == SeadasProductReader.ProductType.Level1A_OCTS) {
          final Date date = dateFormatOcts.parse(timeString);
          String milliSeconds = timeString.substring(timeString.length() - 3);
          return ProductData.UTC.create(date, Long.parseLong(milliSeconds) * 1000);
        } else {
          final Date date = dateFormat.parse(timeString);
          String milliSeconds = timeString.substring(timeString.length() - 3);
          return ProductData.UTC.create(date, Long.parseLong(milliSeconds) * 1000);
        }
      } catch (ParseException ignored) {
      }
    }
    return null;
  }
Beispiel #3
0
 public SeadasFileReader(SeadasProductReader productReader) {
   this.productReader = productReader;
   ncFile = productReader.getNcfile();
   globalAttributes = ncFile.getGlobalAttributes();
 }