public abstract class View extends Object
Modifier and Type | Class and Description |
---|---|
protected class |
View.DataIterator
Iterates over the virtual VisAD data objects of this view.
|
protected class |
View.Domain
The convention-dependent domain of a netCDF variable.
|
Modifier | Constructor and Description |
---|---|
protected |
View(ucar.netcdf.Netcdf netcdf,
QuantityDB quantityDB)
Constructs from a netCDF dataset.
|
protected |
View(ucar.netcdf.Netcdf netcdf,
QuantityDB quantityDB,
boolean charToText)
Constructs from a netCDF dataset.
|
Modifier and Type | Method and Description |
---|---|
protected String |
getAttributeString(String name)
Returns a string-valued global attribute.
|
protected String |
getAttributeString(ucar.netcdf.Variable var,
String name)
Returns a string-valued global attribute or a netCDF variable attribute.
|
protected static String |
getConventionsString(ucar.netcdf.Netcdf netcdf)
Returns the value of the global "Conventions" attribute.
|
protected ucar.netcdf.Variable |
getCoordinateVariable(ucar.netcdf.Dimension dim)
Returns the netCDF coordinate variable associated with a netCDF
dimension.
|
VirtualData |
getData(String name)
Returns the virtual VisAD data object corresponding to a named netCDF
variable.
|
protected VirtualData |
getData(ucar.netcdf.Variable var)
Returns the virtual VisAD data object corresponding to a netCDF
variable.
|
protected ucar.netcdf.Dimension[] |
getDimensions(ucar.netcdf.Variable var)
Returns the netCDF dimensions of a netCDF variable.
|
protected abstract View.Domain |
getDomain(ucar.netcdf.Variable var)
Returns the domain of a netCDF variable.
|
protected Gridded1DSet |
getDomainSet(ucar.netcdf.Dimension dim)
Returns the VisAD
Gridded1DSet corresponding to a netCDF
dimension. |
static View |
getInstance(ucar.netcdf.Netcdf netcdf,
QuantityDB db)
Returns a view of a netCDF dataset.
|
static View |
getInstance(ucar.netcdf.Netcdf netcdf,
QuantityDB db,
boolean charToText)
Returns a view of a netCDF dataset.
|
protected String |
getLongName(ucar.netcdf.Variable var)
Returns the long name of a netCDF variable according to the variable's
long_name attribute. |
ucar.netcdf.Netcdf |
getNetcdf()
Returns the underlying netCDF dataset.
|
Set |
getOuterDimensionNameSet()
Returns the factorName object
|
protected SimpleSet |
getRangeSet(ucar.netcdf.Variable var)
Gets the representational set for the values of a netCDF variable.
|
protected RealType |
getRealType(ucar.netcdf.Dimension dim)
Returns the VisAD
MathType of the domain corresponding to a
netCDF dimension. |
protected RealType |
getRealType(ucar.netcdf.Variable var)
Returns the VisAD
RealType of a netCDF variable. |
protected RealType |
getRealTypeFromLongName(ucar.netcdf.Variable var)
Returns the VisAD RealType corresponding to the
long_name
attribute of a netCDF variable. |
protected RealType |
getRealTypeFromName(ucar.netcdf.Variable var)
Returns the VisAD
RealType corresponding to the name of a
netCDF variable. |
protected ScalarType |
getScalarType(ucar.netcdf.Variable var)
Gets the type of the values of a netCDF variable.
|
protected TextType |
getTextType(ucar.netcdf.Variable var)
Return the VisAD TextType of a netCDF variable.
|
protected Unit |
getUnitFromAttribute(ucar.netcdf.Variable var)
Returns the unit of a netCDF variable according to the variable's unit
attribute.
|
protected String |
getUnitString(ucar.netcdf.Variable var)
Returns the string value of the unit attribute of a netCDF variable.
|
protected ucar.netcdf.Variable |
getVariable(String name)
Returns the named netCDF variable.
|
protected visad.data.netcdf.in.Vetter |
getVetter(ucar.netcdf.Variable var)
Returns a value-vetter for a netCDF variable.
|
VirtualDataIterator |
getVirtualDataIterator()
Returns an iterator over the virtual VisAD data objects of this view.
|
boolean |
isCharToText()
Does this View handle text.
|
protected boolean |
isCoordinateVariable(ucar.netcdf.Variable var)
Indicates if a netCDF variable is a coordinate variable (i.e.
|
protected abstract boolean |
isIgnorable(ucar.netcdf.Variable var)
Indicates if a given variable should be ignored by the
VirtualDataIterator during iteration over the virtual VisAD data objects
in the netCDF dataset. |
protected boolean |
isLatitude(RealType type)
Indicates if a VisAD
RealType represents latitude. |
protected boolean |
isLongitude(RealType type)
Indicates if a VisAD
RealType represents longitude. |
protected boolean |
isLongitude(ucar.netcdf.Variable var)
Indicates if a netCDF dimension represents longitude.
|
protected boolean |
isNumeric(String name)
Indicates if the netCDF variable with a given name is numeric.
|
protected boolean |
isNumeric(ucar.netcdf.Variable var)
Indicates if the given netCDF variable is numeric.
|
protected boolean |
isTime(ucar.netcdf.Dimension dim)
Indicates if a netCDF dimension represents time.
|
protected boolean |
isTime(Unit unit)
Indicates if a unit is a unit of time.
|
protected String |
newName(ucar.netcdf.Variable var)
Returns a name for a given variable that is slightly different that the
variable's name and is guarenteed not to have been returned before.
|
void |
setOuterDimensionNameSet(Set nameSet)
Defines the names of domain components to factor out.
|
protected View(ucar.netcdf.Netcdf netcdf, QuantityDB quantityDB)
netcdf
- The netCDF dataset.quantityDB
- The quantity database to use to map netCDF
variables to VisAD Quantity-s.NullPointerException
- if either argument is null
.protected View(ucar.netcdf.Netcdf netcdf, QuantityDB quantityDB, boolean charToText)
netcdf
- The netCDF dataset.quantityDB
- The quantity database to use to map netCDF
variables to VisAD Quantity-s.charToText
- Specifies whether the View should map char
variables to VisAD Text objectsNullPointerException
- if either argument is null
.public static View getInstance(ucar.netcdf.Netcdf netcdf, QuantityDB db)
netcdf
- The netCDF dataset.db
- A quantity database to be used to map netCDF
variables to VisAD Quantity
s.public static View getInstance(ucar.netcdf.Netcdf netcdf, QuantityDB db, boolean charToText)
netcdf
- The netCDF dataset.db
- A quantity database to be used to map netCDF
variables to VisAD Quantity
s.charToText
- Specifies whether the View should map char
variables to VisAD Text objectspublic boolean isCharToText()
public ucar.netcdf.Netcdf getNetcdf()
protected static String getConventionsString(ucar.netcdf.Netcdf netcdf)
Returns the value of the global "Conventions" attribute. If the
attribute doesn't exist or is invalid, then null
is
returned. If the attribute exists but is not string-valued, then an
error message is printed to System.err
and null
is
returned.
netcdf
- The netCDF dataset.protected ucar.netcdf.Variable getVariable(String name)
null
if the
variable doesn't exist.name
- The name of the netCDF variable.null
.NullPointerException
- if the name is null
.protected boolean isNumeric(String name)
name
- The name of the netCDF variable.true
if and only if the
variable exists has numeric values.protected boolean isNumeric(ucar.netcdf.Variable var)
var
- The netCDF variable.true
if and only if the
variable is numeric.NullPointerException
- if the argument is null
.protected boolean isLongitude(ucar.netcdf.Variable var) throws VisADException
getRealType(Variable)
and isLongitude(RealType)
.var
- A netCDF dimension.true
if an only if dim
represents longitude.VisADException
- Couldn't create necessary VisAD object.protected boolean isLongitude(RealType type)
RealType
represents longitude.protected boolean isLatitude(RealType type)
RealType
represents latitude.protected RealType getRealType(ucar.netcdf.Dimension dim) throws TypeException
Returns the VisAD MathType
of the domain corresponding to a
netCDF dimension.
This implementation supports coordinate variables and uses getCoordinateVariable(Dimension)
and getRealType(Variable)
.
dim
- A netCDF dimension.dim
. Won't be null
.TypeException
- if a corresponding RealType
needed
to be created but couldn't.protected RealType getRealType(ucar.netcdf.Variable var) throws TypeException
Returns the VisAD RealType
of a netCDF variable.
This implementation returns the value of getRealTypeFromLongName(Variable)
if that is non-null
;
otherwise, the value of getRealTypeFromName(Variable)
is
returned.
var
- The netCDF variable.NullPointerException
- if the argument is null
.TypeException
- if a corresponding RealType
needed
to be created but couldn't.protected RealType getRealTypeFromLongName(ucar.netcdf.Variable var)
long_name
attribute of a netCDF variable. If the unit attribute of the variable
is incompatible with the unit of the long_name
attribute,
then a new RealType is created whose default unit is that of the
attribute.
This implementation first checks if the variable has a
long_name
attribute via getLongName(Variable)
,
if it doesn't, then null
is returned; otherwise, the
long name is used to query the quantity database. If the quantity
database doesn't contain a match, then null
is returned;
otherwise, the variable's unit attribute -- obtained via getUnitFromAttribute(Variable)
-- is checked. If the unit attribute
doesn't exist, then the RealType
is returned; otherwise, the unit
attribute is compared against the default unit of the RealType
.
If the two are convertible, then the RealType
is returned;
otherwise, an attempt is made to create a new RealType
with a
slightly different name than the variable's but with the same unit as the
variable's and that RealType
is returned.
var
- The netCDF variable.null
if no corresponding type
was found or could be created.protected RealType getRealTypeFromName(ucar.netcdf.Variable var) throws TypeException
Returns the VisAD RealType
corresponding to the name of a
netCDF variable. null
is never returned.
This implementation first obtains the variable's unit via getUnitFromAttribute(Variable)
. It then queries the quantity database
for a match to the variable's name. If a match is found, then variable's
unit is checked. If the unit is null
, then the RealType
from the database is returned; otherwise, the unit is checked
against the default unit of the obtained RealType
. If the two
units are convertible, then the RealType
is returned; otherwise,
a new RealType
is created that has a slightly different name than
the variable's but with the variable's unit and that RealType
is returned. If the quantity database doesn't contain a match, then
the variable's unit is checked. If it's null
, then
the value of RealType.getRealType(String)
-- when given the
variable's name -- is returned; otherwise, the return value of RealType.getRealType(String, Unit)
-- when invoked with the variable's
name and unit -- is checked. If it's non-null
, then that
RealType
is returned; otherwise, a new RealType
is
created that has a slightly different name than the variable's but with
the variable's unit and that RealType
is returned.
var
- The netCDF variable.TypeException
- if a corresponding RealType
needed
to be created but couldn't.protected String newName(ucar.netcdf.Variable var)
var
- The netCDF variable.protected ScalarType getScalarType(ucar.netcdf.Variable var) throws TypeException, VisADException
Gets the type of the values of a netCDF variable.
This implementation returns the value of #getRealType(Variable)}
or getTextType(Variable)
-- depending on the value of isNumeric(Variable)
.
var
- A netCDF variable.TypeException
- if a corresponding RealType
needed
to be created but couldn't.VisADException
- if a VisAD object can't be created.protected TextType getTextType(ucar.netcdf.Variable var) throws VisADException
var
- The netCDF variable.var
.VisADException
- if a VisAD object couldn't be created.IllegalArgumentException
- if the netCDF variable is not textual.protected SimpleSet getRangeSet(ucar.netcdf.Variable var) throws TypeException, VisADException
null
is returned.
This implementation uses getRealType(Variable)
, getVetter(Variable)
, and getUnitFromAttribute(Variable)
.
var
- A netCDF variable.null
.TypeException
- if a corresponding RealType
needed
to be created but couldn't.VisADException
- Couldn't create necessary VisAD object.protected String getAttributeString(String name)
Returns a string-valued global attribute. If the attribute doesn't
exist or is invalid, then null
is returned. If the
attribute exists but is not string-valued, then an error message is
printed to System.err
and null
is returned.
This implementation uses getAttributeString(Variable, String)
.
name
- The name of the attribute.null
.protected String getAttributeString(ucar.netcdf.Variable var, String name)
null
is
returned. If the attribute exists but is not string-valued, then an
error message is printed to System.err
and null
is
returned.var
- A netCDF variable or null
to
indicate a global attribute.name
- The name of the attribute.null
.protected String getLongName(ucar.netcdf.Variable var)
Returns the long name of a netCDF variable according to the variable's
long_name
attribute. If the attribute doesn't exist, then
null
is returned.
This method uses getAttributeString(Variable, String)
.
var
- A netCDF variable.var
or
null
.ClassCastException
- if the attribute exists but its value isn't a
String.protected String getUnitString(ucar.netcdf.Variable var)
Returns the string value of the unit attribute of a netCDF variable.
Returns null
if the unit attribute is missing or
invalid.
This method uses getAttributeString(Variable, String)
--
first with the name "units" and then with the name "unit".
var
- A netCDF variable.var
or
null
.protected Unit getUnitFromAttribute(ucar.netcdf.Variable var)
Returns the unit of a netCDF variable according to the variable's unit
attribute. Returns null
if the unit attribute is missing
or invalid. If a unit specification exists but can't be decoded, then
a warning message is printed to System.err
.
This method uses getUnitString(Variable)
.
var
- A netCDF variable.var
or
null
.protected visad.data.netcdf.in.Vetter getVetter(ucar.netcdf.Variable var)
var
- A netCDF variable.protected Gridded1DSet getDomainSet(ucar.netcdf.Dimension dim) throws VisADException, IOException
Returns the VisAD Gridded1DSet
corresponding to a netCDF
dimension.
This implementation supports coordinate variables, longitude,
and the discovery of an arithmetic progression. It uses isLongitude(Variable)
, getRealType(Dimension)
, and getUnitFromAttribute(Variable)
.
dim
- A netCDF dimension.GriddedSet
corresponding to
the dimension.VisADException
- if a VisAD object couldn't be created.IOException
- if a netCDF read-error occurs.ClassCastException
- if the dimension has a coordinate variable of
improper type.protected ucar.netcdf.Variable getCoordinateVariable(ucar.netcdf.Dimension dim)
Returns the netCDF coordinate variable associated with a netCDF
dimension. If no such variable exists, then null
is
returned.
This implementation uses isNumeric(Variable)
.
dim
- A netCDF dimension.null
if there is no coordinate variable.public void setOuterDimensionNameSet(Set nameSet)
Defines the names of domain components to factor out. This only works if this names correspond to the outermost dimension. The list of names may be changed after calling this.
The Set should contain only String(s).
Typically, a TreeSet will be used. For example:
TreeSet ts = new TreeSet();
ts.add("myParameter");
view.setOuterDimensionNameSet(ts);
nameSet
- A Set containing the names (as Strings) of
the dimensions to factor out.public Set getOuterDimensionNameSet()
Returns the factorName object
protected boolean isTime(ucar.netcdf.Dimension dim) throws VisADException, IOException
Indicates if a netCDF dimension represents time.
This implementation supports coordinate variables and uses getRealType(Dimension)
.
If setOuterDimensionNameSet() has been called, this list of names will also logically be considered factorable.
dim
- A netCDF dimension.true
if and only if the dimension
represents time.VisADException
- Couldn't create necessary VisAD object.IOException
- I/O failure.protected boolean isTime(Unit unit)
unit
- A unit.true
if and only if the unit
is a unit of time.protected ucar.netcdf.Dimension[] getDimensions(ucar.netcdf.Variable var)
var
- A netCDF variable.var
in
netCDF order.protected boolean isCoordinateVariable(ucar.netcdf.Variable var)
Indicates if a netCDF variable is a coordinate variable (i.e. has only one netCDF dimension and that dimension has the same name).
This implementation uses isNumeric(Variable)
.
var
- A netCDF variable.true
if and only if
var
is a coordinate variable.public VirtualDataIterator getVirtualDataIterator()
protected abstract boolean isIgnorable(ucar.netcdf.Variable var)
Indicates if a given variable should be ignored by the VirtualDataIterator
during iteration over the virtual VisAD data objects
in the netCDF dataset.
true
if and only if the variable
should be ignored.protected abstract View.Domain getDomain(ucar.netcdf.Variable var) throws TypeException, IOException
var
- A netCDF variable.IllegalArgumentException
- if the rank of the variable is zero.TypeException
- if a RealType
needed to be created but
couldn't.IOException
- if a netCDF read-error occurs.public VirtualData getData(String name) throws TypeException, VisADException, IOException
Returns the virtual VisAD data object corresponding to a named netCDF variable.
This implementation uses getData(Variable)
.
name
- The name of the netCDF variable.NullPointerException
- if the argument is null
.IllegalArgumentException
- if the netCDF variable doesn't exist.TypeException
- if a RealType
needed to be created
but couldn't.VisADException
- if a VisAD object couldn't be created.IOException
- if a netCDF read-error occurs.protected VirtualData getData(ucar.netcdf.Variable var) throws TypeException, VisADException, IOException
Returns the virtual VisAD data object corresponding to a netCDF variable.
This implementation uses getRealType(Variable)
, getRangeSet(Variable)
, getUnitFromAttribute(Variable)
, getVetter(Variable)
, and getDomain(Variable)
.
var
- The netCDF variable.NullPointerException
- if the argument is null
.TypeException
- if a RealType
needed to be created
but couldn't.VisADException
- if a VisAD object couldn't be created.IOException
- if a netCDF read-error occurs.Copyright © 1996–2023 The SSEC Visualization Project. All rights reserved.