Package uk.ac.rdg.resc.edal.util.cdm
Class CdmUtils
- java.lang.Object
-
- uk.ac.rdg.resc.edal.util.cdm.CdmUtils
-
public final class CdmUtils extends Object
Contains static helper methods for reading data and metadata from NetCDF files, OPeNDAP servers and other data sources using the Unidata Common Data Model.- Author:
- Jon Blower, Guy Griffiths, Mike Grant, Plymouth Marine Labs
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HorizontalGrid
createHorizontalGrid(ucar.nc2.dt.GridCoordSystem coordSys)
static ReferenceableAxis<Double>
createReferenceableAxis(ucar.nc2.dataset.CoordinateAxis1D axis)
Creates aReferenceableAxis
from the givenCoordinateAxis1D
.static ReferenceableAxis<Double>
createReferenceableAxis(ucar.nc2.dataset.CoordinateAxis1D axis, boolean isLongitude)
Creates aReferenceableAxis
from the givenCoordinateAxis1D
.static TimeAxis
createTimeAxis(ucar.nc2.dataset.CoordinateAxis1DTime timeAxis)
Creates a time axis from the givenGridCoordSystem
static VerticalAxis
createVerticalAxis(ucar.nc2.dataset.CoordinateAxis1D zAxis, boolean isPositive)
static List<File>
expandGlobExpression(String globExpression)
Expands a glob expression to give a List of paths to files.static Array2D<Number>
get2DCoordinateValues(ucar.nc2.dataset.CoordinateAxis2D axis)
static ucar.nc2.dt.grid.GridDataset
getGridDataset(ucar.nc2.dataset.NetcdfDataset ncDataset)
static DataReadingStrategy
getOptimumDataReadingStrategy(ucar.nc2.dataset.NetcdfDataset nc)
Estimates the optimumDataReadingStrategy
from the given NetcdfDataset.
-
-
-
Method Detail
-
getGridDataset
public static ucar.nc2.dt.grid.GridDataset getGridDataset(ucar.nc2.dataset.NetcdfDataset ncDataset) throws DataReadingException, IOException
- Parameters:
ncDataset
- TheNetcdfDataset
to get aGridDataset
from- Returns:
- A
GridDataset
from the givenNetcdfDataset
- Throws:
DataReadingException
- If the givenNetcdfDataset
doesn't contain anyGridDataset
sIOException
-
getOptimumDataReadingStrategy
public static DataReadingStrategy getOptimumDataReadingStrategy(ucar.nc2.dataset.NetcdfDataset nc)
Estimates the optimumDataReadingStrategy
from the given NetcdfDataset. Essentially, if the data are remote (e.g. OPeNDAP) or compressed, this will returnDataReadingStrategy.BOUNDING_BOX
, which makes a single i/o call, minimizing the overhead. If the data are local and uncompressed this will returnDataReadingStrategy.SCANLINE
, which reduces the amount of data read.- Parameters:
nc
- The NetcdfDataset from which data will be read.- Returns:
- an optimum DataReadingStrategy for reading from the dataset
-
createHorizontalGrid
public static HorizontalGrid createHorizontalGrid(ucar.nc2.dt.GridCoordSystem coordSys)
- Parameters:
coordSys
- TheGridCoordSystem
to create aHorizontalGrid
from- Returns:
- two-dimensional referenceable grid from the given grid coordinate
system. Will return more specific subclasses (
RectilinearGrid
orRegularGrid
) if appropriate for the passed-in coordinate system. The grid's coordinate system will be a WGS84 longitude-latitude system. TODO May want to be careful about datum shifts - model data is often in spherical coordinates, not strict WGS84
-
get2DCoordinateValues
public static Array2D<Number> get2DCoordinateValues(ucar.nc2.dataset.CoordinateAxis2D axis)
-
createVerticalAxis
public static VerticalAxis createVerticalAxis(ucar.nc2.dataset.CoordinateAxis1D zAxis, boolean isPositive)
- Parameters:
zAxis
- theCoordinateAxis1D
to create aVerticalAxis
fromisPositive
- Whether increasing values- Returns:
- The resulting
VerticalAxis
-
createTimeAxis
public static TimeAxis createTimeAxis(ucar.nc2.dataset.CoordinateAxis1DTime timeAxis)
Creates a time axis from the givenGridCoordSystem
- Parameters:
timeAxis
- theCoordinateAxis1DTime
defining the axis- Returns:
- a new
TimeAxis
-
createReferenceableAxis
public static ReferenceableAxis<Double> createReferenceableAxis(ucar.nc2.dataset.CoordinateAxis1D axis)
Creates aReferenceableAxis
from the givenCoordinateAxis1D
. Creates a longitude axis if axis.getAxisType()==AxisType.Lon.- Parameters:
axis
- TheCoordinateAxis1D
to convert to aReferenceableAxis
- Returns:
- An equivalent
ReferenceableAxis
-
createReferenceableAxis
public static ReferenceableAxis<Double> createReferenceableAxis(ucar.nc2.dataset.CoordinateAxis1D axis, boolean isLongitude)
Creates aReferenceableAxis
from the givenCoordinateAxis1D
.- Parameters:
axis
- TheCoordinateAxis1D
to convert to aReferenceableAxis
isLongitude
- true if this is a longitude axis (i.e. wraps at 360 degrees).- Returns:
- The equivalent
ReferenceableAxis
-
-