Skip to content
Snippets Groups Projects
Commit f4075004 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

use util

parent fb69129f
No related branches found
No related tags found
2 merge requests!128Production Release | nshmp-ws-static,!127Resolves - Handle Multiple NetCDF Files for AASHTO Service
package gov.usgs.earthquake.nshmp.netcdf;
import java.io.IOException;
import java.nio.file.Path;
import gov.usgs.earthquake.nshmp.netcdf.reader.NetcdfUtils;
import gov.usgs.earthquake.nshmp.netcdf.reader.NetcdfUtils.Key;
import ucar.nc2.dataset.NetcdfDatasets;
/**
* Supported NetCDF data types.
*/
......@@ -21,12 +19,7 @@ public enum NetcdfDataType {
* @param netcdfPath Path to NetCDF file
*/
public static NetcdfDataType getDataType(Path netcdfPath) {
try (var ncd = NetcdfDatasets.openDataset(netcdfPath.toString())) {
var group = ncd.getRootGroup();
var vDataType = group.attributes().findAttribute(Key.DATA_TYPE);
return NetcdfDataType.valueOf(vDataType.getStringValue());
} catch (IOException e) {
throw new RuntimeException("Could not read Netcdf file [" + netcdfPath + " ]");
}
return NetcdfDataType
.valueOf(NetcdfUtils.readAttribute(Key.DATA_TYPE, netcdfPath).getStringValue());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment