1- /* Copyright Unidata */
1+ /*
2+ * Copyright (c) 1998-2025 John Caron and University Corporation for Atmospheric Research/Unidata
3+ * See LICENSE.txt for license information.
4+ */
5+
26package ucar .nc2 .internal .ncml ;
37
48import java .io .IOException ;
1115import javax .annotation .Nullable ;
1216import thredds .inventory .MFile ;
1317import ucar .ma2 .Array ;
18+ import ucar .ma2 .DataType ;
1419import ucar .ma2 .InvalidRangeException ;
1520import ucar .ma2 .Range ;
1621import ucar .ma2 .Section ;
@@ -32,7 +37,8 @@ class AggDatasetOuter extends AggDataset {
3237 @ Nullable
3338 final String coordValue ; // if theres a coordValue on the netcdf element - may be multiple, blank separated
3439 final Date coordValueDate ; // if its a date
35- final boolean isStringValued ; // if coordinat is a String
40+ final DataType coordDataType ; // coordinate data type
41+ final String coordUdunit ; // coordinate udunit string, if numeric
3642
3743 // not final because of deffered read
3844 int ncoord ; // number of coordinates in outer dimension
@@ -68,18 +74,18 @@ class AggDatasetOuter extends AggDataset {
6874 }
6975 }
7076
71- boolean isString = false ;
77+ DataType aggCoordDataType = DataType . DOUBLE ;
7278 if ((aggregationOuter .type == Type .joinNew ) || (aggregationOuter .type == Type .joinExistingOne )
7379 || (aggregationOuter .type == Type .forecastModelRunCollection )) {
7480 if (coordValueS == null ) {
7581 coordValueS = extractCoordNameFromFilename (this .getLocation ());
76- isString = true ;
82+ aggCoordDataType = DataType . STRING ;
7783 } else {
7884 // we just need to know if its string valued
7985 try {
8086 Double .parseDouble (coordValueS );
8187 } catch (NumberFormatException e ) {
82- isString = true ;
88+ aggCoordDataType = DataType . STRING ;
8389 }
8490 }
8591 }
@@ -90,8 +96,10 @@ class AggDatasetOuter extends AggDataset {
9096 this .ncoord = stoker .countTokens ();
9197 }
9298
93- this . isStringValued = isString ; // LOOK ??
99+ coordDataType = aggCoordDataType ;
94100 this .coordValue = coordValueS ;
101+ // not dealing with scan
102+ this .coordUdunit = "" ;
95103 this .coordValueDate = null ; // LOOK why isnt this set?
96104 }
97105
@@ -115,13 +123,21 @@ private String extractCoordNameFromFilename(String loc) {
115123 // default is that the coordinates are just the filenames
116124 // this can be overriden by an explicit declaration, which will replace the variable after ther agg is processed in
117125 // NcMLReader
126+ DataType aggCoordDataType = DataType .DOUBLE ;
127+ String coordUdunit = "" ;
118128 if ((aggregationOuter .type == Type .joinNew ) || (aggregationOuter .type == Type .joinExistingOne )
119129 || (aggregationOuter .type == Type .forecastModelRunCollection )) {
120130 coordValueS = extractCoordNameFromFilename (this .getLocation ());
121- this .isStringValued = true ;
122- } else {
123- this .isStringValued = false ; // LOOK ??
131+ if (aggregationOuter .numericTimeSettings != null ) {
132+ String [] settings = aggregationOuter .numericTimeSettings .split (" " , 2 );
133+ aggCoordDataType = DataType .getType (settings [0 ]);
134+ coordUdunit = settings [1 ];
135+ } else {
136+ aggCoordDataType = DataType .STRING ;
137+ }
124138 }
139+ this .coordDataType = aggCoordDataType ;
140+ this .coordUdunit = coordUdunit ;
125141
126142 if (null != aggregationOuter .dateFormatMark ) {
127143 String filename = cd .getName (); // LOOK operates on name, not path
0 commit comments