Java Code Examples for ucar.nc2.units.DateUnit#getStandardOrISO()

The following examples show how to use ucar.nc2.units.DateUnit#getStandardOrISO() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NidsRadialAdapter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void setStartDate() {

    String start_datetime = ds.getRootGroup().findAttributeString("time_coverage_start", null);
    if (start_datetime != null) {
      startDate = DateUnit.getStandardOrISO(start_datetime);
      return;
    } else {
      CoordinateAxis axis = ds.findCoordinateAxis(AxisType.Time);
      if (axis != null) {
        double val = axis.getMinValue();
        startDate = dateUnits.makeDate(val);
        return;
      }
    }
    parseInfo.append("*** start_datetime not Found\n");
  }
 
Example 2
Source File: NidsRadialAdapter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void setEndDate() {

    String end_datetime = ds.getRootGroup().findAttributeString("time_coverage_end", null);
    if (end_datetime != null) {
      endDate = DateUnit.getStandardOrISO(end_datetime);
    } else {
      CoordinateAxis axis = ds.findCoordinateAxis(AxisType.Time);
      if (axis != null) {
        double val = axis.getMaxValue();
        endDate = dateUnits.makeDate(val);
        return;
      }
    }

    parseInfo.append("*** end_datetime not Found\n");
  }
 
Example 3
Source File: UnidataObsDatasetHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Date getStartDate(NetcdfDataset ds) {
  Attribute att = ds.findGlobalAttributeIgnoreCase("time_coverage_start");
  if (null == att)
    throw new IllegalArgumentException("Must have a time_coverage_start global attribute");

  if (att.getDataType() == DataType.STRING) {
    return DateUnit.getStandardOrISO(att.getStringValue());
  } else {
    throw new IllegalArgumentException("time_coverage_start must be a ISO or udunit date string");
  }
}
 
Example 4
Source File: UnidataObsDatasetHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Date getEndDate(NetcdfDataset ds) {
  Attribute att = ds.findGlobalAttributeIgnoreCase("time_coverage_end");
  if (null == att)
    throw new IllegalArgumentException("Must have a time_coverage_end global attribute");

  Date result;
  if (att.getDataType() == DataType.STRING) {
    result = DateUnit.getStandardOrISO(att.getStringValue());
  } else {
    throw new IllegalArgumentException("time_coverage_end must be a ISO or udunit date string");
  }

  return result;
}
 
Example 5
Source File: NsslRadialAdapter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void setStartDate() {
  String start_datetime = ds.getRootGroup().findAttributeString("time_coverage_start", null);
  if (start_datetime != null)
    startDate = DateUnit.getStandardOrISO(start_datetime);
  else
    parseInfo.append("*** start_datetime not Found\n");
}
 
Example 6
Source File: NsslRadialAdapter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void setEndDate() {
  String end_datetime = ds.getRootGroup().findAttributeString("time_coverage_end", null);
  if (end_datetime != null)
    endDate = DateUnit.getStandardOrISO(end_datetime);
  else
    parseInfo.append("*** end_datetime not Found\n");
}
 
Example 7
Source File: Nidsiosp.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Read the data for each variable passed in
 */
public Array readData(Variable v2, Section section) throws InvalidRangeException {
  // subset
  Object data;
  Array outputData;
  byte[] vdata;
  Nidsheader.Vinfo vinfo;
  ByteBuffer bos;
  List<Range> ranges = section.getRanges();
  vinfo = (Nidsheader.Vinfo) v2.getSPobject();

  vdata = headerParser.getUncompData((int) vinfo.doff, 0);
  bos = ByteBuffer.wrap(vdata);


  if (v2.getShortName().equals("azimuth")) {
    if (pcode == 176)
      data = readOneScanGenericData(bos, vinfo, v2.getShortName());
    else
      data = readRadialDataAzi(bos, vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().equals("gate")) {
    data = readRadialDataGate(vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().equals("elevation")) {
    data = readRadialDataEle(bos, vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().equals("latitude")) {
    double lat = ncfile.findGlobalAttribute("RadarLatitude").getNumericValue().doubleValue();
    data = readRadialDataLatLonAlt(lat, vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().equals("longitude")) {
    double lon = ncfile.findGlobalAttribute("RadarLongitude").getNumericValue().doubleValue();
    data = readRadialDataLatLonAlt(lon, vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().equals("altitude")) {
    double alt = ncfile.findGlobalAttribute("RadarAltitude").getNumericValue().doubleValue();
    data = readRadialDataLatLonAlt(alt, vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().equals("distance")) {
    data = readDistance(vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().equals("rays_time")) {
    String rt = ncfile.findGlobalAttribute("time_coverage_start").getStringValue();
    java.util.Date pDate = DateUnit.getStandardOrISO(rt);
    double lt = pDate.getTime();
    double[] dd = new double[vinfo.yt];
    for (int radial = 0; radial < vinfo.yt; radial++) {
      dd[radial] = (float) lt;
    }
    outputData = Array.factory(v2.getDataType(), v2.getShape(), dd);

  } else if (v2.getShortName().startsWith("EchoTop") || v2.getShortName().startsWith("VertLiquid")
      || v2.getShortName().startsWith("BaseReflectivityComp") || v2.getShortName().startsWith("LayerCompReflect")) {
    data = readOneArrayData(bos, vinfo, v2.getShortName());
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().startsWith("PrecipArray")) {
    data = readOneArrayData1(bos, vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().startsWith("Precip") && !vinfo.isRadial) {
    data = readOneArrayData(bos, vinfo, v2.getShortName());
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);

  } else if (v2.getShortName().equals("unlinkedVectorStruct")) {
    outputData = readUnlinkedVectorData(v2.getShortName(), bos, vinfo);
  } else if (v2.getShortName().equals("linkedVectorStruct")) {
    outputData = readLinkedVectorData(v2.getShortName(), bos, vinfo);
  } else if (v2.getShortName().startsWith("textStruct")) {
    outputData = readTextStringData(v2.getShortName(), bos, vinfo);
  } else if (v2.getShortName().startsWith("VADWindSpeed")) {
    outputData = readWindBarbData(v2.getShortName(), bos, vinfo, null);
  } else if (v2.getShortName().startsWith("VectorArrow")) {
    outputData = readVectorArrowData(v2.getShortName(), bos, vinfo);
  } else if (v2.getShortName().startsWith("TabMessagePage")) {
    data = readTabAlphaNumData(bos, vinfo);
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);
  } else if (v2.getShortName().startsWith("circleStruct")) {
    outputData = readCircleStructData(v2.getShortName(), bos, vinfo);
  } else if (v2.getShortName().startsWith("hail") || v2.getShortName().startsWith("TVS")) {
    outputData = readGraphicSymbolData(v2.getShortName(), bos, vinfo);
  } else if (v2.getShortName().startsWith("DigitalInstantaneousPrecipitationRate")) {
    data = readOneScanGenericData(bos, vinfo, v2.getShortName());
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);
  } else {
    data = readOneScanData(bos, vinfo, v2.getShortName());
    outputData = Array.factory(v2.getDataType(), v2.getShape(), data);
  }

  return outputData.sectionNoReduce(ranges);
}