Package dap4.dap4lib.cdm
Class CDMUtil
- java.lang.Object
-
- dap4.dap4lib.cdm.CDMUtil
-
public abstract class CDMUtil extends Object
CDM related Constants and utilities common to client and server code
-
-
Field Summary
Fields Modifier and Type Field Description static ucar.ma2.IndexSCALAR
-
Constructor Summary
Constructors Constructor Description CDMUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ucar.ma2.IndexcdmIndexToIndex(ucar.ma2.Index cdmidx)static int[]computeEffectiveShape(List<DapDimension> dimset)Compute the shape inferred from a set of slices.static booleancontainsVLEN(List<ucar.nc2.Dimension> dimset)Test if any dimension is variable lengthstatic ObjectconvertVector(DapType dsttype, DapType srctype, Object src)Convert an array of one type of values to another typestatic List<ucar.ma2.Range>createCDMRanges(List<Slice> slices)static List<Slice>createSlices(List<ucar.ma2.Range> rangelist)Convert a list of ucar.ma2.Range to a list of Slice More or less the inverst of create CDMRangesstatic List<ucar.ma2.Range>dimsetToRanges(List<DapDimension> dimset)static StringgetChecksumString(byte[] checksum)static booleanhasVLEN(List<ucar.ma2.Range> ranges)static booleanhasVLEN(ucar.nc2.Variable v)Test if any dimension is variable lengthstatic ucar.ma2.IndexindexToCcMIndex(ucar.ma2.Index d4)static List<Slice>indexToSlices(ucar.ma2.Index indices)Convert DataIndex to list of slicesstatic booleanisWhole(List<ucar.ma2.Range> rangelist, List<DapDimension> dimset, int start, int stop)Test a Listagainst a List to see if the range list represents the whole set of dimensions within the specified indices. static booleanisWhole(List<ucar.ma2.Range> rangelist, List<Slice> slices)Test a Listagainst a List to see if the range list is whole wrt the slices static booleanisWhole(List<ucar.ma2.Range> rangelist, ucar.nc2.Variable var)Test a Listagainst the CDM variable's dimensions to see if the range list is whole wrt the dimensions static List<Slice>shapeToSlices(int[] shape)static ucar.ma2.IndexslicesToIndex(List<Slice> slices)If a set of slices refers to a single position, then return the corresponding Index.static ucar.nc2.Variableunwrap(ucar.nc2.Variable var)NetcdfDataset can end up wrapping a variable in multiple wrapping classes (e.g.static ucar.nc2.NetcdfFileunwrapfile(ucar.nc2.NetcdfFile file)NetcdfDataset can wrap a NetcdfFile.
-
-
-
Method Detail
-
createSlices
public static List<Slice> createSlices(List<ucar.ma2.Range> rangelist) throws DapException
Convert a list of ucar.ma2.Range to a list of Slice More or less the inverst of create CDMRanges- Parameters:
rangelist- the set of ucar.ma2.Range- Returns:
- the equivalent list of Slice
- Throws:
DapException
-
isWhole
public static boolean isWhole(List<ucar.ma2.Range> rangelist, List<DapDimension> dimset, int start, int stop) throws DapException
Test a Listagainst a List to see if the range list represents the whole set of dimensions within the specified indices. - Parameters:
rangelist- the set of ucar.ma2.Rangedimset- the set of DapDimensionsstart- start looking herestop- stop looking here- Returns:
- true if rangelist is whole; false otherwise.
- Throws:
DapException
-
isWhole
public static boolean isWhole(List<ucar.ma2.Range> rangelist, List<Slice> slices) throws DapException
Test a Listagainst a List to see if the range list is whole wrt the slices - Parameters:
rangelist- the set of ucar.ma2.Rangeslices- the set of slices- Returns:
- true if rangelist is whole wrt slices; false otherwise.
- Throws:
DapException
-
isWhole
public static boolean isWhole(List<ucar.ma2.Range> rangelist, ucar.nc2.Variable var) throws DapException
Test a Listagainst the CDM variable's dimensions to see if the range list is whole wrt the dimensions - Parameters:
rangelist- the set of ucar.ma2.Rangevar- the cdm var- Returns:
- true if rangelist is whole wrt slices; false otherwise.
- Throws:
DapException
-
createCDMRanges
public static List<ucar.ma2.Range> createCDMRanges(List<Slice> slices) throws DapException
- Throws:
DapException
-
unwrap
public static ucar.nc2.Variable unwrap(ucar.nc2.Variable var)
NetcdfDataset can end up wrapping a variable in multiple wrapping classes (e.g. VariableDS). Goal of this procedure is to get down to the lowest level Variable instance- Parameters:
var- possibly wrapped variable- Returns:
- the lowest level Variable instance
-
unwrapfile
public static ucar.nc2.NetcdfFile unwrapfile(ucar.nc2.NetcdfFile file)
NetcdfDataset can wrap a NetcdfFile. Goal of this procedure is to get down to the lowest level NetcdfFile instance.- Parameters:
file- NetcdfFile or NetcdfDataset- Returns:
- the lowest level NetcdfFile instance
-
hasVLEN
public static boolean hasVLEN(List<ucar.ma2.Range> ranges)
-
hasVLEN
public static boolean hasVLEN(ucar.nc2.Variable v)
Test if any dimension is variable length
-
containsVLEN
public static boolean containsVLEN(List<ucar.nc2.Dimension> dimset)
Test if any dimension is variable length
-
computeEffectiveShape
public static int[] computeEffectiveShape(List<DapDimension> dimset)
Compute the shape inferred from a set of slices. 'Effective' means that any trailing vlen will be ignored.- Parameters:
dimset- from which to generate shape- Returns:
- effective shape
-
convertVector
public static Object convertVector(DapType dsttype, DapType srctype, Object src)
Convert an array of one type of values to another type- Parameters:
dsttype- target typesrctype- source typesrc- array of values to convert- Returns:
- resulting array of converted values as an object
-
getChecksumString
public static String getChecksumString(byte[] checksum)
-
dimsetToRanges
public static List<ucar.ma2.Range> dimsetToRanges(List<DapDimension> dimset) throws DapException
- Throws:
DapException
-
shapeToSlices
public static List<Slice> shapeToSlices(int[] shape) throws DapException
- Throws:
DapException
-
cdmIndexToIndex
public static ucar.ma2.Index cdmIndexToIndex(ucar.ma2.Index cdmidx)
-
indexToCcMIndex
public static ucar.ma2.Index indexToCcMIndex(ucar.ma2.Index d4)
-
indexToSlices
public static List<Slice> indexToSlices(ucar.ma2.Index indices) throws DapException
Convert DataIndex to list of slices- Parameters:
indices- to convert- Returns:
- list of corresponding slices
- Throws:
DapException
-
slicesToIndex
public static ucar.ma2.Index slicesToIndex(List<Slice> slices) throws DapException
If a set of slices refers to a single position, then return the corresponding Index. Otherwise, throw Exception.- Parameters:
slices-- Returns:
- Index corresponding to slices
- Throws:
DapException
-
-