/** * Get this as a CalendarDate * * @return CalendarDate */ public CalendarDate getCalendarDate() { return isPresent() ? CalendarDate.present() : date; }
/** * Get this as a CalendarDate * * @return CalendarDate */ public CalendarDate getCalendarDate() { return isPresent() ? CalendarDate.present() : date; }
/** * Get this as a CalendarDate * * @return CalendarDate */ public CalendarDate getCalendarDate() { return isPresent() ? CalendarDate.present() : date; }
if (size <= minElements) return; if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCache {} cleanup started at {} for maxElements={}", name, CalendarDate.present(), maxElements); if (debugCleanup) System.out.printf(" FileCache %s cleanup started at %s for maxElements=%d%n", name, CalendarDate.present(), maxElements);
public static void main(String arg[]) { CalendarDate cd = CalendarDate.present(); /* {"S", "M", "L", "F", "-"} System.out.printf("%s%n", DateTimeFormat.forStyle("SS").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("MM").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("LL").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("FF").print(cd.getDateTime())); */ System.out.printf("%s%n", cd); System.out.printf("%s%n", toDateTimeStringISO(cd)); System.out.printf("%s%n", toDateTimeString(cd)); System.out.printf("%s%n", toDateString(cd)); Date d = new Date(); System.out.printf("%s%n", toDateTimeString(d)); DateFormatter df = new DateFormatter(); System.out.printf("%s%n", df.toDateTimeString(d)); System.out.printf("%s%n", df.toDateOnlyString(d)); }
public static void main(String arg[]) { CalendarDate cd = CalendarDate.present(); /* {"S", "M", "L", "F", "-"} System.out.printf("%s%n", DateTimeFormat.forStyle("SS").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("MM").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("LL").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("FF").print(cd.getDateTime())); */ System.out.printf("%s%n", cd); System.out.printf("toDateTimeStringISO=%s%n", toDateTimeStringISO(cd)); System.out.printf(" toDateTimeString=%s%n", toDateTimeString(cd)); System.out.printf(" toDateString=%s%n", toDateString(cd)); System.out.printf(" toTimeUnits=%s%n", toTimeUnits(cd)); System.out.printf("===============================%n"); Date d = cd.toDate(); System.out.printf("cd.toDate()=%s%n", toDateTimeString(d)); SimpleDateFormat udunitDF = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.US); udunitDF.setTimeZone(TimeZone.getTimeZone("UTC")); udunitDF.applyPattern("yyyy-MM-dd HH:mm:ss.SSS 'UTC'"); System.out.printf(" udunitDF=%s%n", udunitDF.format(d)); System.out.printf("===============================%n"); DateFormatter df = new DateFormatter(); System.out.printf(" toTimeUnits(date)=%s%n", toTimeUnits(cd)); System.out.printf("toDateTimeString(date)=%s%n", df.toDateTimeString(d)); System.out.printf("toDateOnlyString(date)=%s%n", df.toDateOnlyString(d)); }
public static void main(String arg[]) { CalendarDate cd = CalendarDate.present(); /* {"S", "M", "L", "F", "-"} System.out.printf("%s%n", DateTimeFormat.forStyle("SS").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("MM").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("LL").print(cd.getDateTime())); System.out.printf("%s%n", DateTimeFormat.forStyle("FF").print(cd.getDateTime())); */ System.out.printf("%s%n", cd); System.out.printf("toDateTimeStringISO=%s%n", toDateTimeStringISO(cd)); System.out.printf(" toDateTimeString=%s%n", toDateTimeString(cd)); System.out.printf(" toDateString=%s%n", toDateString(cd)); System.out.printf(" toTimeUnits=%s%n", toTimeUnits(cd)); System.out.printf("===============================%n"); Date d = cd.toDate(); System.out.printf("cd.toDate()=%s%n", toDateTimeString(d)); SimpleDateFormat udunitDF = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.US); udunitDF.setTimeZone(TimeZone.getTimeZone("UTC")); udunitDF.applyPattern("yyyy-MM-dd HH:mm:ss.SSS 'UTC'"); System.out.printf(" udunitDF=%s%n", udunitDF.format(d)); System.out.printf("===============================%n"); DateFormatter df = new DateFormatter(); System.out.printf(" toTimeUnits(date)=%s%n", toTimeUnits(cd)); System.out.printf("toDateTimeString(date)=%s%n", df.toDateTimeString(d)); System.out.printf("toDateOnlyString(date)=%s%n", df.toDateOnlyString(d)); }
if (size <= minElements) return; if (cacheLog.isDebugEnabled()) cacheLog.debug("FileCache {} cleanup started at {} for maxElements={}", name, CalendarDate.present(), maxElements); if (debugCleanup) System.out.printf(" FileCache %s cleanup started at %s for maxElements=%d%n", name, CalendarDate.present(), maxElements);
dateWanted = CalendarDate.present(); else dateWanted = (CalendarDate) params.get(SubsetParams.time);
private void addGlobalAttributes(NetcdfFileWriter writer, ucar.nc2.dt.GridDataset gds, LatLonRect llbb) { // global attributes for (Attribute att : gds.getGlobalAttributes()) { if (att.getShortName().equals(CDM.FILE_FORMAT)) continue; if (att.getShortName().equals(_Coordinate._CoordSysBuilder)) continue; writer.addGroupAttribute(null, att); } Attribute att = gds.findGlobalAttributeIgnoreCase(CDM.CONVENTIONS); if (att == null || !att.getStringValue().startsWith("CF-")) // preserve previous version of CF Convention if it exists writer.addGroupAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1.0")); writer.addGroupAttribute(null, new Attribute("History", "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter2)\n" + "Original Dataset = " + gds.getLocation() + "; Translation Date = " + CalendarDate.present())); // this will replace any existing writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLatMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getLatMax())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLonMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getLonMax())); }
private void writeGlobalAttributes(NetcdfFileWriter writer, ucar.nc2.dt.GridDataset gds, LatLonRect llbb) { // global attributes for (Attribute att : gds.getGlobalAttributes()) { if (att.getShortName().equals(CDM.FILE_FORMAT)) continue; if (att.getShortName().equals(_Coordinate._CoordSysBuilder)) continue; writer.addGroupAttribute(null, att); } Attribute att = gds.findGlobalAttributeIgnoreCase(CDM.CONVENTIONS); if (att == null || !att.getStringValue().startsWith("CF-")) // preserve previous version of CF Convention if it exists writer.addGroupAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1.0")); writer.addGroupAttribute(null, new Attribute("History", "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter)\n" + "Original Dataset = " + gds.getLocationURI() + "; Translation Date = " + CalendarDate.present())); // this will replace any existing writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLatMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getLatMax())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLonMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getLonMax())); }
private void addGlobalAttributes(NetcdfFileWriter writer, ucar.nc2.dt.GridDataset gds, LatLonRect llbb) { // global attributes for (Attribute att : gds.getGlobalAttributes()) { if (att.getShortName().equals(CDM.FILE_FORMAT)) continue; if (att.getShortName().equals(_Coordinate._CoordSysBuilder)) continue; writer.addGroupAttribute(null, att); } Attribute att = gds.findGlobalAttributeIgnoreCase(CDM.CONVENTIONS); if (att == null || !att.getStringValue().startsWith("CF-")) // preserve previous version of CF Convention if it exists writer.addGroupAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1.0")); writer.addGroupAttribute(null, new Attribute("History", "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter2)\n" + "Original Dataset = " + gds.getLocationURI() + "; Translation Date = " + CalendarDate.present())); // this will replace any existing writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLatMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getLatMax())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLonMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getLonMax())); }
private void writeGlobalAttributes(NetcdfFileWriter writer, ucar.nc2.dt.GridDataset gds, LatLonRect llbb) { // global attributes for (Attribute att : gds.getGlobalAttributes()) { if (att.getShortName().equals(CDM.FILE_FORMAT)) continue; if (att.getShortName().equals(_Coordinate._CoordSysBuilder)) continue; writer.addGroupAttribute(null, att); } Attribute att = gds.findGlobalAttributeIgnoreCase(CDM.CONVENTIONS); if (att == null || !att.getStringValue().startsWith("CF-")) // preserve previous version of CF Convention if it exists writer.addGroupAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1.0")); writer.addGroupAttribute(null, new Attribute("History", "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridWriter)\n" + "Original Dataset = " + gds.getLocation() + "; Translation Date = " + CalendarDate.present())); // this will replace any existing writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLatMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getLatMax())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLonMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getLonMax())); }
public void finish() throws IOException { if (llbb != null) { writer.updateAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLowerLeftPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getUpperRightPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getUpperRightPoint().getLongitude())); } if (!noTimeCoverage) { if (minDate == null) minDate = CalendarDate.present(); if (maxDate == null) maxDate = CalendarDate.present(); writer.updateAttribute(null, new Attribute(ACDD.TIME_START, CalendarDateFormatter.toDateTimeStringISO(minDate))); writer.updateAttribute(null, new Attribute(ACDD.TIME_END, CalendarDateFormatter.toDateTimeStringISO(maxDate))); } writer.close(); }
public void finish() throws IOException { if (llbb != null) { writer.updateAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLowerLeftPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getUpperRightPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getUpperRightPoint().getLongitude())); } if (!noTimeCoverage) { if (minDate == null) minDate = CalendarDate.present(); if (maxDate == null) maxDate = CalendarDate.present(); writer.updateAttribute(null, new Attribute(ACDD.TIME_START, CalendarDateFormatter.toDateTimeStringISO(minDate))); writer.updateAttribute(null, new Attribute(ACDD.TIME_END, CalendarDateFormatter.toDateTimeStringISO(maxDate))); } writer.close(); }
private void addGlobalAttributes(CoverageCollection gds, NetcdfFileWriter writer) { // global attributes for (Attribute att : gds.getGlobalAttributes()) { if (att.getShortName().equals(CDM.FILE_FORMAT)) continue; if (att.getShortName().equals(_Coordinate._CoordSysBuilder)) continue; writer.addGroupAttribute(null, att); } Attribute att = gds.findAttributeIgnoreCase(CDM.CONVENTIONS); if (att == null || !att.getStringValue().startsWith("CF-")) // preserve prev version of CF Convention if exists writer.addGroupAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1.0")); writer.addGroupAttribute(null, new Attribute("History", "Translated to CF-1.0 Conventions by Netcdf-Java CDM (CFGridCoverageWriter2)\n" + "Original Dataset = " + gds.getName() + "; Translation Date = " + CalendarDate.present())); LatLonRect llbb = gds.getLatlonBoundingBox(); if (llbb != null) { // this will replace any existing writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLatMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getLatMax())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLonMin())); writer.addGroupAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getLonMax())); } }
public void finish() throws IOException { writer.updateAttribute(null, new Attribute(CDM.LAT_MIN, llbb.getLowerLeftPoint().getLatitude())); writer.updateAttribute(null, new Attribute(CDM.LAT_MAX, llbb.getUpperRightPoint().getLatitude())); writer.updateAttribute(null, new Attribute(CDM.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(CDM.LON_MAX, llbb.getUpperRightPoint().getLongitude())); if((writer.getNetcdfFile().findAttribute("@"+CDM.TIME_START) != null) && (writer.getNetcdfFile().findAttribute("@"+CDM.TIME_END) != null )){ if (minDate == null) minDate = CalendarDate.present(); if (maxDate == null) maxDate = CalendarDate.present(); writer.updateAttribute(null, new Attribute(CDM.TIME_START, CalendarDateFormatter.toDateTimeStringISO(minDate))); writer.updateAttribute(null, new Attribute(CDM.TIME_END, CalendarDateFormatter.toDateTimeStringISO(maxDate))); } writer.close(); }
public Optional<TimeOffsetAxis> subsetFromTime(SubsetParams params, CalendarDate runDate) { CoordAxisHelper helper = new CoordAxisHelper(this); CoverageCoordAxisBuilder builder = null; if (params.isTrue(SubsetParams.timePresent)) { double offset = getOffsetInTimeUnits(runDate, CalendarDate.present()); builder = helper.subsetClosest(offset); } CalendarDate dateWanted = (CalendarDate) params.get(SubsetParams.time); if (dateWanted != null) { // convertFrom, convertTo double offset = getOffsetInTimeUnits(runDate, dateWanted); builder = helper.subsetClosest(offset); } Integer stride = (Integer) params.get(SubsetParams.timeStride); if (stride == null || stride < 0) stride = 1; CalendarDateRange dateRange = (CalendarDateRange) params.get(SubsetParams.timeRange); if (dateRange != null) { double min = getOffsetInTimeUnits(runDate, dateRange.getStart()); double max = getOffsetInTimeUnits(runDate, dateRange.getEnd()); Optional<CoverageCoordAxisBuilder> buildero = helper.subset(min, max, stride); if (buildero.isPresent()) builder = buildero.get(); else return Optional.empty(buildero.getErrorMessage()); } assert (builder != null); // all the offsets are reletive to rundate builder.setReferenceDate(runDate); return Optional.of(new TimeOffsetAxis(builder)); }