From 2ff52bbbb83b5133a2e7a84937288a22956c6085 Mon Sep 17 00:00:00 2001 From: Hailey Johnson Date: Tue, 9 Jul 2024 10:59:41 -0700 Subject: [PATCH] fix CF version and min/max dates --- .../main/java/ucar/nc2/ft/point/writer/CFPointWriter.java | 7 ++++++- .../ucar/nc2/ft/point/writer/WriterCFPointCollection.java | 2 ++ .../ucar/nc2/ft/point/writer2/WriterCFPointAbstract.java | 4 +++- .../java/ucar/nc2/ft2/coverage/writer/CoverageAsPoint.java | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cdm/core/src/main/java/ucar/nc2/ft/point/writer/CFPointWriter.java b/cdm/core/src/main/java/ucar/nc2/ft/point/writer/CFPointWriter.java index d4dcc3bc0f..12ad5ec57a 100644 --- a/cdm/core/src/main/java/ucar/nc2/ft/point/writer/CFPointWriter.java +++ b/cdm/core/src/main/java/ucar/nc2/ft/point/writer/CFPointWriter.java @@ -39,7 +39,6 @@ *
  • netcdf3: use indexed ragged array representation
  • * */ -@Deprecated public abstract class CFPointWriter implements Closeable { private static final Logger logger = LoggerFactory.getLogger(CFPointWriter.class); private static final String CF_VERSION = "CF-1.9"; @@ -861,6 +860,12 @@ public void finish() throws IOException { writer.updateAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getUpperRightPoint().getLongitude())); } + 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(); } diff --git a/cdm/core/src/main/java/ucar/nc2/ft/point/writer/WriterCFPointCollection.java b/cdm/core/src/main/java/ucar/nc2/ft/point/writer/WriterCFPointCollection.java index 4d37a7e1a6..394b380c0a 100644 --- a/cdm/core/src/main/java/ucar/nc2/ft/point/writer/WriterCFPointCollection.java +++ b/cdm/core/src/main/java/ucar/nc2/ft/point/writer/WriterCFPointCollection.java @@ -37,6 +37,8 @@ public class WriterCFPointCollection extends CFPointWriter { public WriterCFPointCollection(String fileOut, List globalAtts, List dataVars, CalendarDateUnit timeUnit, String altUnits, CFPointWriterConfig config) throws IOException { super(fileOut, globalAtts, dataVars, timeUnit, altUnits, config); + writer.addGroupAttribute(null, new Attribute(CF.FEATURE_TYPE, CF.FeatureType.point.name())); + writer.addGroupAttribute(null, new Attribute(CF.DSG_REPRESENTATION, "Point Data, H.1")); } public WriterCFPointCollection(String fileOut, List globalAtts, List dataVars, diff --git a/cdm/core/src/main/java/ucar/nc2/ft/point/writer2/WriterCFPointAbstract.java b/cdm/core/src/main/java/ucar/nc2/ft/point/writer2/WriterCFPointAbstract.java index a2dba6ea4a..c66ee0f821 100644 --- a/cdm/core/src/main/java/ucar/nc2/ft/point/writer2/WriterCFPointAbstract.java +++ b/cdm/core/src/main/java/ucar/nc2/ft/point/writer2/WriterCFPointAbstract.java @@ -40,6 +40,8 @@ abstract class WriterCFPointAbstract implements Closeable { private static final Logger logger = LoggerFactory.getLogger(WriterCFPointAbstract.class); + private static final String CF_VERSION = "CF-1.9"; + static final String recordName = "obs"; static final String recordDimName = "obs"; static final String latName = "latitude"; @@ -126,7 +128,7 @@ abstract class WriterCFPointAbstract implements Closeable { } private void addGlobalAtts(AttributeContainer atts) { - writerb.addAttribute(new Attribute(CDM.CONVENTIONS, isExtendedModel ? CDM.CF_EXTENDED : "CF-1.6")); + writerb.addAttribute(new Attribute(CDM.CONVENTIONS, isExtendedModel ? CDM.CF_EXTENDED : CF_VERSION)); writerb.addAttribute(new Attribute(CDM.HISTORY, "Written by CFPointWriter")); for (Attribute att : atts) { if (!reservedGlobalAtts.contains(att.getShortName())) diff --git a/cdm/core/src/main/java/ucar/nc2/ft2/coverage/writer/CoverageAsPoint.java b/cdm/core/src/main/java/ucar/nc2/ft2/coverage/writer/CoverageAsPoint.java index 33111d775b..9786053d31 100644 --- a/cdm/core/src/main/java/ucar/nc2/ft2/coverage/writer/CoverageAsPoint.java +++ b/cdm/core/src/main/java/ucar/nc2/ft2/coverage/writer/CoverageAsPoint.java @@ -27,7 +27,7 @@ import ucar.unidata.util.StringUtil2; /** - * Write DSG CF-1.6 file from a Coverage Dataset + * Write DSG CF-1.9 file from a Coverage Dataset * * @author caron * @since 7/8/2015