|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.visad.Util
public final class Util
Provides support for utility functions.
| Field Summary | |
|---|---|
static String |
REALTYPE_ROOT
The default root name for generic RealTypes |
static String |
TEXT_IDENTIFIER
The suffix added to text type names |
| Method Summary | |
|---|---|
static Real |
bearingDistance(EarthLocation el1,
EarthLocation el2)
Return the distance from a bearing as Real |
static ucar.unidata.geoloc.Bearing |
calculateBearing(LatLonPoint pt1,
LatLonPoint pt2,
ucar.unidata.geoloc.Bearing result)
Calculate the bearing between the 2 points. |
static String |
cleanName(String name)
Make a valid VisAD RealType name from the string. |
static String |
cleanTypeName(MathType mathType)
Remove any of the extra unit suffixes that get added to the type name |
static String |
cleanTypeName(String name)
A utility to strip off the unit name that gets appended to the real type name. |
static Data |
clone(Data data,
MathType type)
Clones a data object, replacing the MathType. |
static Data |
clone(Data data,
MathType type,
boolean unitOverride,
boolean copy)
Clones a data object, replacing the MathType. |
static Field |
clone(Field field,
Set domain)
Clones a Field replacing the domain Set and copying the range values. |
static Field |
clone(Field field,
Set domain,
boolean copyRange)
Clones a Field replacing the domain Set. |
static FlatField |
clone(FlatField flatField,
Set domain,
boolean copyRange)
Clones a FlatField replacing the domain Set. |
static RealType |
clone(RealType realType,
String name)
Clones a RealType but changes the name. |
static Set |
clone(Set set,
CoordinateSystem coordSys)
Clones a set, replacing the CoordinateSystem. |
static Field |
convertDomain(Field field,
RealTupleType newDomainType,
CoordinateSystem coordinateSystem)
Converts the MathType of the domain of a Field. |
static FlatField |
convertDomain(FlatField field,
RealTupleType newDomainType,
CoordinateSystem coordinateSystem)
Converts the domain of a FlatField. |
static SampledSet |
convertDomain(SampledSet oldDomain,
RealTupleType newDomainType,
CoordinateSystem coordinateSystem)
Converts a SampledSet domain. |
static double |
distance(LatLonPoint p1,
LatLonPoint p2)
Return the distance between the 2 points |
static void |
dumpTypes(Data d)
Wrapper for JPythonMethods.dumpTypes(Data) |
static Set |
ensureCoordinateSystem(Set set,
CoordinateSystem coordSys)
Ensures that a set has a particular CoordinateSystem. |
static Field |
ensureDomain(Field field,
RealTupleType newDomainType,
CoordinateSystem coordinateSystem)
Ensures that a Field has a particular domain MathType. |
static Field |
ensureDomain(Field field,
Set domain)
Ensures that a Field has a particular domain Set. |
static FlatField |
ensureFlatFieldRangeType(FlatField flatField,
RealType realType)
Ensures that the MathType of the range of a FlatField is a specified RealType. |
static Data |
ensureMathType(Data data,
MathType type)
Ensures that a data object has a particular MathType. |
static Field |
ensureTupleRange(Field field)
Ensures that the range of a Field is a Tuple. |
static RealType[] |
ensureUnit(RealType[] types,
Unit u)
Ensure that the units for the array of RealTypes are compatible with the given unit. |
static RealType |
ensureUnit(RealType type,
Unit u)
Ensure that the units for the RealType are compatible with the given unit. |
static boolean |
exportAsNetcdf(Data data)
Export the data object as a netCDF file |
static int |
findIndex(Set set,
Real value)
_more_ |
static String |
formatAltitude(Real alt)
Format an Altitude |
static String |
formatEarthLocation(EarthLocation el,
boolean includeAlt)
Format a EarthLocation as a lat/lon/(alt) string. |
static String |
formatLatLonPoint(LatLonPoint llp)
Format an LatLonPoint as a lat/lon string. |
static String |
formatReal(Real r)
Format a real value to a nice looking number |
static String |
formatUtcDate(DateTime dt,
String pattern)
Deprecated. use UtcDate.formatUtcDate(DateTime, String) |
static String |
getCompatibleUnitName(Unit u)
Replace illegal RealType characters in a Unit spec with underscores. |
static Unit[] |
getDefaultRangeUnits(FieldImpl field)
Gets the default units of the (flat) components of the range of a FlatField. |
protected static Unit[] |
getDefaultUnits(FlatField field,
int[] indexes,
RealType[] types)
Gets the default units of the given range components of a FlatField. |
static int |
getIndex(TupleType tupleType,
String lookingFor)
Find the index of the MathType in the given tuple type whose cleaned name is equals to the lookingFor parameter. |
static GraphicsConfiguration |
getPreferredConfig(GraphicsDevice d,
boolean is3D,
boolean useStereo)
Get graphics configuration for the screen |
static CoordinateSystem |
getRangeCoordinateSystem(Field field)
Gets the coordinate sytem of the RealTuple range of a Field. |
static CoordinateSystem[] |
getRangeCoordinateSystems(Field field)
Gets the coordinate sytems of the components of the range of a Field. |
static SampledSet |
getRangeSampledSet(Field field,
MathType type)
Extracts the given range component from a Field as a SampledSet. |
static Unit[] |
getRangeUnits(FlatField field)
Gets the units of the (flat) components of the range of a FlatField. |
static double[] |
getRayPositionAtZ(VisADRay ray,
double zValue)
Get the position of the ray at a particular Z value. |
static Real |
getReal(double value,
String unitString)
Get a Real with the specified value and Unit |
static Real |
getReal(double value,
Unit unit)
Get a Real with the specified value and Unit |
static RealType |
getRealType(RealTupleType type,
String start)
Get the RealType from the RealTupleType that corresponds to one that begins with start. |
static RealType |
getRealType(Unit unit)
Get a realtype with the unit |
static RealTuple |
getSample(Set set,
int index)
Deprecated. use visad.util.DataUtility.getSample() now |
static double |
getValueAs(Real r,
String unitString)
Get the value of a Real in the unit specified |
static double[] |
getVWorldCoords(DisplayImpl display,
int x,
int y,
double[] retVals)
Get the VisAD Virtual World x,y coordinates for the given screen coords |
static FieldImpl |
indexedField(Data[] datas,
boolean copy)
Get a FieldImpl with a domain of index and the range of the datas. |
static boolean |
isCompatible(Data data,
MathType type)
Indicates if a Data object is compatible with a MathType. |
static boolean |
isSorted(float[] values)
Indicates if an array is sorted. |
static boolean |
isStrictlySorted(float[] values)
Indicates if an array is strictly sorted. |
static TwoFacedObject |
labeledReal(Real r)
Wrap a Real as a TwoFacedObject with a formatted label |
static TwoFacedObject |
labeledReal(Real r,
boolean includeUnit)
Wrap a Real as a TwoFacedObject with a formatted label |
static void |
main(String[] args)
Test |
static Date |
makeDate(DateTime dttm)
_more_ |
static List |
makeDates(DateTime[] timesArray)
_more_ |
static GriddedSet |
makeEarthDomainSet(float[] lats,
float[] lons,
float[] alts)
|
static EarthLocation |
makeEarthLocation(double lat,
double lon)
Utility to make an earth location with a 0 altitude |
static EarthLocation |
makeEarthLocation(LatLonPoint llp)
Utility to make an earth location with a 0 altitude |
static FlatField |
makeField(float lon1,
float lon2,
int length1,
float lat1,
float lat2,
int length2,
float fill,
String unitString)
_more_ |
static FlatField |
makeField(Image image,
boolean makeNansForAnyAlpha)
Create a VisAD Data object from the given Image |
static MapProjection |
makeMapProjection(double lat1,
double lon1,
double lat2,
double lon2)
_more_ |
static RealType |
makeRealType(String name,
String alias,
Unit unit)
|
static RealType |
makeRealType(String name,
Unit unit)
Create a RealType from the name and unit. |
static Data |
makeTimeField(Data range,
List times)
This makes a field of T->range for the times in the list. |
static FieldImpl |
makeTimeField(List ranges,
List times)
|
static Data |
makeTimeRangeField(Data range,
List times)
This makes a field of T->range for the times in the list. |
static Set |
makeTimeSet(List times)
_more_ |
static SampledSet |
newSampledSet(int[] manifoldLengths,
RealTupleType newSampledSetType,
double[][] newValues,
CoordinateSystem coordinateSystem,
Unit[] newUnits,
ErrorEstimate[] newErrors)
Creates a new SampledSet using a given manifold dimensionality. |
static SampledSet |
newSampledSet(int[] manifoldLengths,
RealTupleType newSampledSetType,
float[][] newValues,
CoordinateSystem coordinateSystem,
Unit[] newUnits,
ErrorEstimate[] newErrors)
Creates a new SampledSet using a given manifold dimensionality. |
static SampledSet |
newSampledSet(MathType type,
float[][] values,
int[] manifoldLengths,
CoordinateSystem coordinateSystem,
Unit[] units,
ErrorEstimate[] errors,
boolean copy)
Creates a new SampledSet. |
static SampledSet |
newSampledSet(SampledSet oldSampledSet,
double[][] newValues,
int[] manifoldLengths)
Creates a new SampledSet based on an existing SampledSet and new values. |
static SampledSet |
newSampledSet(SampledSet oldSampledSet,
float[][] newValues,
int[] manifoldLengths)
Creates a new SampledSet based on an existing SampledSet and new values. |
static SampledSet |
newSampledSet(SampledSet oldSampledSet,
RealTupleType newSampledSetType,
double[][] newValues,
CoordinateSystem coordinateSystem,
Unit[] newUnits,
ErrorEstimate[] newErrors)
Creates a new SampledSet using the topology of an existing SampledSet. |
static SampledSet |
newSampledSet(SampledSet oldSampledSet,
RealTupleType newSampledSetType,
float[][] newValues,
CoordinateSystem coordinateSystem,
Unit[] newUnits,
ErrorEstimate[] newErrors)
Creates a new SampledSet using the topology of an existing SampledSet. |
static Unit |
parseUnit(String unitIdentifier)
Parse a unit string specification and return the appropriate unit. |
static Unit |
parseUnit(String unitIdentifier,
String unitName)
Parse a unit string specification and return the appropriate unit. |
static boolean |
propertySet(Object object,
String name,
Object value,
boolean ignoreError)
Use reflection to find the Method with name "set" + Name. |
static int[] |
sortedIndexes(double[] values,
boolean increasing)
Returns the element indexes that would sort an array. |
static int[] |
sortedIndexes(float[] values,
boolean increasing)
Returns the element indexes that would sort an array. |
static int[] |
strictlySortedIndexes(double[] values,
boolean increasing)
Returns the element indexes that would strictly sort an array. |
static int[] |
strictlySortedIndexes(float[] values,
boolean increasing)
Returns the element indexes that would strictly sort an array. |
static float[] |
take(float[] values,
int[] indexes)
Takes indicated values from an array. |
static ucar.unidata.geoloc.LatLonPointImpl |
toLatLonPoint(LatLonPoint llp)
|
static List |
toList(Set set)
Convert the elements in the set to a List |
static ucar.unidata.geoloc.LatLonPoint |
toLLP(EarthLocation el)
|
static ucar.unidata.geoloc.LatLonPoint |
toLLP(LatLonPoint llp)
|
static Real |
toReal(String value)
Parses the given String and returns the Real (if possible) that the string represents. |
static Real |
toReal(String value,
String unitOpener,
String unitCloser)
|
static Data |
vetType(MathType type,
Data data)
Vets a data object against a MathType. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String TEXT_IDENTIFIER
public static String REALTYPE_ROOT
| Method Detail |
|---|
protected static Unit[] getDefaultUnits(FlatField field,
int[] indexes,
RealType[] types)
throws IllegalArgumentException,
TypeException,
VisADException
field - The field to be examined.indexes - Indexes of the components in the range of the
field.types - Expected, compatible types for the components.
IllegalArgumentException - field == null ||
indexes.length != types.length,
or indexes out-of-bounds.
TypeException - Type of component in range of field not
compatible with expected type.
VisADException - Couldn't create necessary VisAD object.
public static RealType clone(RealType realType,
String name)
throws VisADException
realType - The realtype to be cloned.name - The new name for the clone.
VisADException - Couldn't create necessary VisAD object.
public static boolean isCompatible(Data data,
MathType type)
throws VisADException,
RemoteException
Data object is compatible with a MathType.
data - The Data object.type - The MathType.
true if and only if the given
Data object is compatible with the given
MathType.
VisADException - if a VisAD failure occurs.
RemoteException - if a Java RMI failure occurs.
public static Data vetType(MathType type,
Data data)
throws TypeException,
VisADException,
RemoteException
This method should probably become MathType.vet(Data).
type - The MathType that the data object must be
compatible with.data - The data object.
data (as a programming
convenience).
TypeException - The MathType and data object are incompatible.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static RealType ensureUnit(RealType type,
Unit u)
throws VisADException
type - RealType to checku - unit to check
VisADException - couldn't get a new RealTypepublic static String getCompatibleUnitName(Unit u)
u - Unit
public static String cleanName(String name)
name - name to clean
public static RealType[] ensureUnit(RealType[] types,
Unit u)
throws VisADException
types - array of RealTypes to checku - unit to check
VisADException - couldn't get a new RealType
public static Data ensureMathType(Data data,
MathType type)
throws UnimplementedException,
VisADException,
RemoteException
This method should probably become "abstract Data Data.ensureMathType(MathType)" with subclass-dependent implementations.
data - The data object.type - The type for the returned data object. Must be
compatible with the current type of the data
object. The data object will be cloned only
if necessary.
UnimplementedException - Method not yet implemented.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static Field ensureDomain(Field field,
Set domain)
throws UnimplementedException,
VisADException,
RemoteException
field - The Field the have a particular domain Set.domain - The particular domain Set for the Field to have.
Must be compatible with the Field's existing
domain set.
UnimplementedException - Can't yet clone the class of the Field.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static Field ensureDomain(Field field,
RealTupleType newDomainType,
CoordinateSystem coordinateSystem)
throws UnimplementedException,
VisADException,
RemoteException
field - The Field the have a particular domain Set.newDomainType - The particular MathType for the domain of the
Field to have. Coordinate conversions are
done if and when necessary and possible.coordinateSystem - The CoordinateSystem which, together with
newDomainType, form the basis for
the desired domain. May be null.
UnimplementedException - Can't yet clone the class of the Field.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static Field ensureTupleRange(Field field)
throws RemoteException,
VisADException
field - The Field.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static Field clone(Field field,
Set domain)
throws UnimplementedException,
VisADException,
RemoteException
field - The Field to be cloned..domain - The domain Set for the cloned Field to have.
Must be compatible with the Field's existing
domain set.
UnimplementedException - Can't yet clone the class of the Field.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static Field clone(Field field,
Set domain,
boolean copyRange)
throws UnimplementedException,
VisADException,
RemoteException
field - The Field to be cloned.domain - The domain Set for the cloned Field to have.
Need only be topologically equivalent to the
Field's existing domain set.copyRange - If true then the range of the old
Field will be copied to the new Field;
otherwise not.
UnimplementedException - Can't yet clone the class of the Field.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static FlatField clone(FlatField flatField,
Set domain,
boolean copyRange)
throws VisADException,
RemoteException
flatField - The FlatField to be cloned.domain - The domain Set for the cloned FlatField to have.
Need only be topologically equivalent to
existing domain.copyRange - If true then the range of the old
FlatField will be copied to the new Field;
otherwise not.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static Field convertDomain(Field field,
RealTupleType newDomainType,
CoordinateSystem coordinateSystem)
throws UnimplementedException,
VisADException,
RemoteException
field - The Field to be converted.newDomainType - The MathType of the domain for the converted
Field to have. Coordinate conversions are
done if and when necessary and possible.coordinateSystem - The CoordinateSystem which, together with
newDomainType, form the basis for
the desired domain. May be null.
UnimplementedException - Can't yet clone the class of the Field.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static FlatField convertDomain(FlatField field,
RealTupleType newDomainType,
CoordinateSystem coordinateSystem)
throws VisADException,
RemoteException
field - The FlatField to be converted.newDomainType - The MathType for the converted FlatField.
Coordinate conversions are done if and when
necessary and possible.coordinateSystem - The CoordinateSystem which, together with
newDomainType, form the basis for
the desired domain. May be null.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static SampledSet convertDomain(SampledSet oldDomain,
RealTupleType newDomainType,
CoordinateSystem coordinateSystem)
throws VisADException,
RemoteException
oldDomain - The domain to be converted.newDomainType - The type of the new domain.coordinateSystem - The CoordinateSystem which, together with
newDomainType, form the basis for
the desired domain. May be null.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static SampledSet newSampledSet(SampledSet oldSampledSet,
float[][] newValues,
int[] manifoldLengths)
throws VisADException,
RemoteException
oldSampledSet - The existing SampledSet.newValues - The values for the new SampledSet.manifoldLengths - The manifold dimensionality (i.e. the
number and size of each dimension). May be
null in which case an IrregularSet
is created and returned; otherwise, the first
element is the size of the innermost dimension,
etc.
VisADException - Couldn't perform necessary VisAD operation.
RemoteException - Java RMI failure.
public static SampledSet newSampledSet(SampledSet oldSampledSet,
double[][] newValues,
int[] manifoldLengths)
throws VisADException,
RemoteException
oldSampledSet - The existing SampledSet.newValues - The values for the new SampledSet.manifoldLengths - The manifold dimensionality (i.e. the
number and size of each dimension). May be
null in which case an IrregularSet
is created and returned; otherwise, the first
element is the size of the innermost dimension,
etc.
VisADException - Couldn't perform necessary VisAD operation.
RemoteException - Java RMI failure.
public static SampledSet newSampledSet(SampledSet oldSampledSet,
RealTupleType newSampledSetType,
float[][] newValues,
CoordinateSystem coordinateSystem,
Unit[] newUnits,
ErrorEstimate[] newErrors)
throws VisADException,
RemoteException
oldSampledSet - The old SampledSet to be used for the topology
of the new SampledSet.newSampledSetType - The type of the new SampledSet.newValues - The values for the new SampledSet.coordinateSystem - The CoordinateSystem for the new SampledSet.newUnits - The units for the new SampledSet.newErrors - The new ErrorEstimate-s for the new SampledSet.
VisADException - Couldn't perform necessary VisAD operation.
RemoteException - Java RMI failure.
public static SampledSet newSampledSet(SampledSet oldSampledSet,
RealTupleType newSampledSetType,
double[][] newValues,
CoordinateSystem coordinateSystem,
Unit[] newUnits,
ErrorEstimate[] newErrors)
throws VisADException,
RemoteException
oldSampledSet - The old SampledSet to be used for the topology
of the new SampledSet.newSampledSetType - The type of the new SampledSet.newValues - The values for the new SampledSet.coordinateSystem - The CoordinateSystem for the new SampledSet.newUnits - The units for the new SampledSet.newErrors - The new ErrorEstimate-s for the new SampledSet.
VisADException - Couldn't perform necessary VisAD operation.
RemoteException - Java RMI failure.
public static SampledSet newSampledSet(int[] manifoldLengths,
RealTupleType newSampledSetType,
double[][] newValues,
CoordinateSystem coordinateSystem,
Unit[] newUnits,
ErrorEstimate[] newErrors)
throws VisADException,
RemoteException
manifoldLengths - The manifold dimensionality (i.e. the
number and size of each dimension). May be
null in which case an IrregularSet
is created and returned; otherwise, the first
element is the size of the innermost dimension,
etc.newSampledSetType - The type of the new SampledSet.newValues - The values for the new SampledSet.coordinateSystem - The CoordinateSystem for the new SampledSet.newUnits - The units for the new SampledSet.newErrors - The new ErrorEstimate-s for the new SampledSet.
VisADException - Couldn't perform necessary VisAD operation.
RemoteException - Java RMI failure.
public static SampledSet newSampledSet(int[] manifoldLengths,
RealTupleType newSampledSetType,
float[][] newValues,
CoordinateSystem coordinateSystem,
Unit[] newUnits,
ErrorEstimate[] newErrors)
throws VisADException,
RemoteException
manifoldLengths - The manifold dimensionality (i.e. the
number and size of each dimension). May be
null in which case an IrregularSet
is created and returned; otherwise, the first
element is the size of the innermost dimension,
etc.newSampledSetType - The type of the new SampledSet.newValues - The values for the new SampledSet.coordinateSystem - The CoordinateSystem for the new SampledSet.newUnits - The units for the new SampledSet.newErrors - The new ErrorEstimate-s for the new SampledSet.
VisADException - Couldn't perform necessary VisAD operation.
RemoteException - Java RMI failure.
public static CoordinateSystem getRangeCoordinateSystem(Field field)
throws VisADException,
RemoteException
field - The Field.
null.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.
public static CoordinateSystem[] getRangeCoordinateSystems(Field field)
throws VisADException,
RemoteException
field - The Field.
null.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.public static Unit[] getRangeUnits(FlatField field)
field - The FlatField.
null.public static Unit[] getDefaultRangeUnits(FieldImpl field)
field - The FlatField.
null.
public static Data clone(Data data,
MathType type)
throws UnimplementedException,
VisADException,
RemoteException
This method should probably become "abstract Data Data.clone(MathType)" with subclass-dependent implementations.
data - The data object to be cloned.type - The type for the returned data object. Must be
compatible with the current type of the data
object.
UnimplementedException - Method not yet implemented.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.public static Data c