visad.data
Class FileFlatField

java.lang.Object
  extended by visad.ThingImpl
      extended by visad.DataImpl
          extended by visad.FunctionImpl
              extended by visad.FieldImpl
                  extended by visad.FlatField
                      extended by visad.data.FileFlatField
All Implemented Interfaces:
Serializable, Cloneable, Data, Field, FlatFieldIface, Function, Thing

public class FileFlatField
extends FlatField

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class visad.DataImpl
DataImpl.Syncher
 
Field Summary
 
Fields inherited from class visad.FlatField
RangeCoordinateSystem, RangeCoordinateSystems, RangeUnits, TupleDimension
 
Fields inherited from interface visad.Data
ABS, ACOS, ACOS_DEGREES, ADD, ASIN, ASIN_DEGREES, ATAN, ATAN_DEGREES, ATAN2, ATAN2_DEGREES, CEIL, COS, COS_DEGREES, DEGREES_TO_RADIANS, DEPENDENT, DIVIDE, EXP, FLOOR, INDEPENDENT, INV_ATAN2, INV_ATAN2_DEGREES, INV_DIVIDE, INV_POW, INV_REMAINDER, INV_SUBTRACT, LOG, MAX, MIN, MULTIPLY, NEAREST_NEIGHBOR, NEGATE, NO_ERRORS, NOP, POW, RADIANS_TO_DEGREES, REMAINDER, RINT, ROUND, SIN, SIN_DEGREES, SQRT, SUBTRACT, TAN, TAN_DEGREES, WEIGHTED_AVERAGE
 
Constructor Summary
FileFlatField(FileAccessor accessor, CacheStrategy strategy)
           
 
Method Summary
 Data adjustSamplingError(Data error, int error_mode)
          return a FlatField that clones this, except its ErrorEstimate-s are adjusted for sampling errors in error
 Data binary(Data data, int op, int sampling_mode, int error_mode)
          Pointwise binary operation between this and data.
 Data binary(Data data, int op, MathType new_type, int sampling_mode, int error_mode)
          Return new Field with value 'this op data'.
 Object clone()
          Clones this instance.
 DataShadow computeRanges(ShadowType type, DataShadow shadow)
          Recursive version of computeRanges(), called down through Data object tree.
 Field domainFactor(RealType factor)
          Factors this instance into a (nested) field-of-fields.
 Field extract(int component)
          extract field from this[].component; this is OK, when we get around to it
 Unit[] getDefaultRangeUnits()
          Get default range Unit-s for 'Flat' components.
 CoordinateSystem getDomainCoordinateSystem()
          Get the CoordinateSystem associated with the domain RealTuple
 Set getDomainSet()
          Returns the domain-set of this instance.
 Unit[] getDomainUnits()
          Returns the units of the values in the domain set.
 float[][] getFloats(boolean copy)
          Returns the range values in their default units as floats.
 int getLength()
          get number of samples
 CoordinateSystem[] getRangeCoordinateSystem()
          Returns the range CoordinateSystem assuming that the range type is a RealTupleType (and throws a TypeException if its not).
 CoordinateSystem[] getRangeCoordinateSystem(int component)
          Returns the CoordinateSystem of a component of the range.
 Unit[][] getRangeUnits()
          return array of Units associated with each RealType component of range; these may differ from default Units of range RealTypes, but must be convertable; the second index has length = 1 (since all samples have the same Units)
 Data getSample(int index)
          Get the range value at the index-th sample.
 double[][] getValues()
          Returns the range values in their default units as doubles.
 double[][] getValues(boolean copy)
          Returns the range values in their default units as doubles.
 double[] getValues(int index)
          Get values for 'Flat' components in default range Unit-s.
 boolean isFlatField()
          return true if this a FlatField or a RemoteField adapting a FlatField
 boolean isMissing()
          Test whether range values are missing
 String longString(String pre)
           
 Field resample(Set set, int sampling_mode, int error_mode)
          Resamples the range to domain samples of a given set.
 void setSample(int index, Data range)
          Set the range value at the index-th sample
 void setSample(int index, Data range, boolean copy)
          Set the range value at the index-th sample
 void setSample(RealTuple domain, Data range)
          set the range value at the sample nearest to domain
 String toString()
           
 Data unary(int op, int sampling_mode, int error_mode)
          Pointwise unary operation applied to this.
 Data unary(int op, MathType new_type, int sampling_mode, int error_mode)
          Return new FlatField with value 'this op'.
 float[][] unpackFloats()
          unpack an array of floats from field sample values according to the RangeSet-s; returns a copy
 double[][] unpackValues()
          unpack an array of doubles from field sample values according to the RangeSet-s; returns a copy
 
Methods inherited from class visad.FlatField
clearMissing, cloneDouble, cloneDouble, cloneFloat, cloneFloat, convertToField, derivative, derivative, derivative, derivative, derivative, equals, extract, fillField, getFloats, getRangeDimension, getRangeErrors, getRangeSets, getSample, getStringValues, grabBytes, main, makeField, makeField1, makeField2, makeRational, makeRational, nullRanges, pr, resampleDouble, setRangeErrors, setSamples, setSamples, setSamples, setSamples, setSamples, setSamples, setSamples, setSamples, setSamples, unpackFloats, unpackFloats, unpackOneFloatRangeComp, unpackOneFloatRangeComp, unpackOneRangeComp, unpackOneRangeComp, unpackValues, unpackValues
 
Methods inherited from class visad.FieldImpl
__getitem__, __len__, __setitem__, __setitem__, combine, combine, combine, combine, combine, domainEnumeration, domainFactor, domainMultiply, domainMultiply, domainMultiply, domainMultiply, extract, extract, setSample, setSample, setSamples
 
Methods inherited from class visad.FunctionImpl
__getitem__, __getitem__, evaluate, evaluate, evaluate, evaluate, getDomainDimension, resample
 
Methods inherited from class visad.DataImpl
__add__, __add__, __div__, __div__, __mod__, __mod__, __mul__, __mul__, __neg__, __pow__, __pow__, __radd__, __rdiv__, __rmod__, __rmul__, __rpow__, __rsub__, __sub__, __sub__, abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, notifyReferences, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees
 
Methods inherited from class visad.ThingImpl
addReference, removeReference
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface visad.Field
domainEnumeration, domainMultiply, domainMultiply, setSample
 
Methods inherited from interface visad.Function
evaluate, evaluate, evaluate, evaluate, getDomainDimension, resample
 
Methods inherited from interface visad.Data
abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees
 
Methods inherited from interface visad.Thing
addReference, removeReference
 

Constructor Detail

FileFlatField

public FileFlatField(FileAccessor accessor,
                     CacheStrategy strategy)
              throws VisADException
Throws:
VisADException
Method Detail

getSample

public Data getSample(int index)
               throws VisADException,
                      RemoteException
Description copied from class: FlatField
Get the range value at the index-th sample. FlatField does not override evaluate, but the correctness of FlatField.evaluate depends on overriding getSample

Specified by:
getSample in interface Field
Overrides:
getSample in class FlatField
Parameters:
index - index of requested range sample
Returns:
Data object (Real, RealTuple, or Tuple) corresponding to the range at the index-th sample.
Throws:
VisADException - problem getting data
RemoteException - problem getting data from remote object

getLength

public int getLength()
Description copied from class: FieldImpl
get number of samples

Specified by:
getLength in interface Field
Overrides:
getLength in class FieldImpl

getDomainUnits

public Unit[] getDomainUnits()
Description copied from class: FieldImpl
Returns the units of the values in the domain set. The units may differ from the default units of the underlying MathType of the domain, but will be convertible with them.

Specified by:
getDomainUnits in interface Function
Overrides:
getDomainUnits in class FieldImpl
Returns:
The units of the values in the domain set.

getDomainCoordinateSystem

public CoordinateSystem getDomainCoordinateSystem()
Description copied from class: FunctionImpl
Get the CoordinateSystem associated with the domain RealTuple

Specified by:
getDomainCoordinateSystem in interface Function
Overrides:
getDomainCoordinateSystem in class FieldImpl
Returns:
CoordinateSystem of the domain

getRangeCoordinateSystem

public CoordinateSystem[] getRangeCoordinateSystem()
                                            throws TypeException
Description copied from class: FlatField
Returns the range CoordinateSystem assuming that the range type is a RealTupleType (and throws a TypeException if its not). This may differ from default CoordinateSystem of range RealTupleType, but must be convertable; the index has length = 1 (since all samples have the same Units).

Specified by:
getRangeCoordinateSystem in interface Field
Overrides:
getRangeCoordinateSystem in class FlatField
Returns:
The CoordinateSystem of the RealTuple range. Will not be null and will be of length 1.
Throws:
TypeException - The type of the range is neither RealType nor RealTupleType.

getRangeCoordinateSystem

public CoordinateSystem[] getRangeCoordinateSystem(int component)
                                            throws TypeException
Description copied from class: FlatField
Returns the CoordinateSystem of a component of the range. The MathType of the range shall be a TupleType.

Specified by:
getRangeCoordinateSystem in interface Field
Overrides:
getRangeCoordinateSystem in class FlatField
Parameters:
component - The index of the component. The value shall be greater than or equal to zero and less that the number of components in the TupleType of the range.
Returns:
The CoordinateSystem of the i-th component. Won't be null and will be of length 1. The single element might be null.
Throws:
TypeException - The type of the range is either RealType or RealTupleType.

getRangeUnits

public Unit[][] getRangeUnits()
Description copied from class: FlatField
return array of Units associated with each RealType component of range; these may differ from default Units of range RealTypes, but must be convertable; the second index has length = 1 (since all samples have the same Units)

Specified by:
getRangeUnits in interface Field
Overrides:
getRangeUnits in class FlatField

getDefaultRangeUnits

public Unit[] getDefaultRangeUnits()
Description copied from class: FlatField
Get default range Unit-s for 'Flat' components.

Specified by:
getDefaultRangeUnits in interface Field
Overrides:
getDefaultRangeUnits in class FlatField
Returns:
array of the default Units for each of the RealTypes components in the flattened range.

getValues

public double[][] getValues()
                     throws VisADException
Description copied from class: FlatField
Returns the range values in their default units as doubles.

Specified by:
getValues in interface Field
Overrides:
getValues in class FlatField
Returns:
The range values in their default units as determined by the MathType of the range. Element [i][j] is the jth sample value of the ith component of the range.
Throws:
VisADException - if a VisAD object couldn't be created.

getValues

public double[][] getValues(boolean copy)
                     throws VisADException
Description copied from class: FlatField
Returns the range values in their default units as doubles.

Specified by:
getValues in interface Field
Overrides:
getValues in class FlatField
Parameters:
copy - Whether or not the returned array might be the actual range array. If true, then the returned array will not be the actual range array.
Returns:
The range values in their default units as determined by the MathType of the range. Element [i][j] is the jth sample value of the ith component of the range.
Throws:
VisADException - if a VisAD object couldn't be created.

getValues

public double[] getValues(int index)
                   throws VisADException
Description copied from class: FlatField
Get values for 'Flat' components in default range Unit-s.

Specified by:
getValues in interface FlatFieldIface
Overrides:
getValues in class FlatField
Returns:
The range values in their default units as determined by the MathType of the range. Element [i] is the value of the ith component of the flattened range.
Throws:
VisADException - if a VisAD object couldn't be created.

getFloats

public float[][] getFloats(boolean copy)
                    throws VisADException
Description copied from class: FlatField
Returns the range values in their default units as floats.

Specified by:
getFloats in interface Field
Overrides:
getFloats in class FlatField
Parameters:
copy - Whether or not the returned array might be the actual range array. If true, then the returned array will not be the actual range array.
Returns:
The range values in their default units as determined by the MathType of the range. Element [i][j] is the jth sample value of the ith component of the range.
Throws:
VisADException - if a VisAD object couldn't be created.

getDomainSet

public Set getDomainSet()
Description copied from class: FieldImpl

Returns the domain-set of this instance. The actual set is returned: it is not a copy or a clone.

Note that it is possible to simultaneously modify the domain-set of both this instance and of a clone by modifying the values in the array returned by invoking getSamples(false) on the domain-set of either this instance or the clone. Don't do this unless you enjoy debugging.

Specified by:
getDomainSet in interface Field
Overrides:
getDomainSet in class FieldImpl
Returns:
The actual domain-set of this instance.

setSample

public void setSample(int index,
                      Data range)
               throws VisADException,
                      RemoteException
Description copied from class: FlatField
Set the range value at the index-th sample

Specified by:
setSample in interface Field
Overrides:
setSample in class FlatField
Parameters:
index - index to set
range - range value to set
Throws:
VisADException - if range's MathType is incompatible or some other error.
RemoteException - if the Remote object couldn't be created.

setSample

public void setSample(RealTuple domain,
                      Data range)
               throws VisADException,
                      RemoteException
Description copied from interface: Field
set the range value at the sample nearest to domain

Specified by:
setSample in interface Field
Overrides:
setSample in class FieldImpl
Throws:
VisADException
RemoteException

setSample

public void setSample(int index,
                      Data range,
                      boolean copy)
               throws VisADException,
                      RemoteException
Description copied from class: FlatField
Set the range value at the index-th sample

Specified by:
setSample in interface Field
Overrides:
setSample in class FlatField
Parameters:
index - index to set
range - range value to set
copy - flag to copy values - meaningless for FlatField
Throws:
VisADException - if range's MathType is incompatible or some other error.
RemoteException - if the Remote object couldn't be created.

isMissing

public boolean isMissing()
Description copied from class: FlatField
Test whether range values are missing

Specified by:
isMissing in interface Data
Overrides:
isMissing in class FlatField
Returns:
true if the range values have not been set

binary

public Data binary(Data data,
                   int op,
                   int sampling_mode,
                   int error_mode)
            throws VisADException,
                   RemoteException
Description copied from class: DataImpl
Pointwise binary operation between this and data. Applies to Reals, Tuples (recursively to components), and to Field ranges (Field domains implicitly resampled if necessary). Does not apply to Field domains or Sets (regarded as domains of Fields wthout ranges). Data.ADD is only op defined for Text, interpreted as concatenate. MathTypes of this and data must match, or one may match the range of the other if it is a FunctionType.

Specified by:
binary in interface Data
Overrides:
binary in class DataImpl
Parameters:
data - other Data operand for binary operation
op - may be Data.ADD, Data.SUBTRACT, etc; these include all binary operations defined for Java primitive data types
sampling_mode - may be Data.NEAREST_NEIGHBOR or Data.WEIGHTED_AVERAGE
error_mode - may be Data.INDEPENDENT, Data.DEPENDENT or Data.NO_ERRORS;
Returns:
result, which takes the MathType of this unless the default Units of that MathType conflict with Units of the result, in which case a generic MathType with appropriate Units is constructed
Throws:
VisADException - a VisAD error occurred
RemoteException - an RMI error occurred

binary

public Data binary(Data data,
                   int op,
                   MathType new_type,
                   int sampling_mode,
                   int error_mode)
            throws VisADException,
                   RemoteException
Description copied from class: FlatField
Return new Field with value 'this op data'. test for various relations between types of this and data; note return type may not be FlatField, in case data is a Field and this matches its range

Specified by:
binary in interface Data
Overrides:
binary in class FlatField
Parameters:
data - object to operate on
op - operation to perform (e.g. ADD, SUB, MULT)
new_type - MathType of new object
sampling_mode - sampling mode to use (e.g., NEAREST_NEIGHBOR, WEIGHTED_AVERAGE)
error_mode - error estimate mode (e.g., NO_ERROR, DEPENDENT, independent)
Returns:
new Field corresponding to the requested operation
Throws:
VisADException - couldn't create new VisAD object
RemoteException - couldn't create new Remote object

unary

public Data unary(int op,
                  int sampling_mode,
                  int error_mode)
           throws VisADException,
                  RemoteException
Description copied from class: DataImpl
Pointwise unary operation applied to this. Applies to Reals, Tuples (recursively to components), and to Field ranges (Field domains implicitly resampled if necessary). Does not apply to Field domains, Sets (regarded as domains of Fields wthout ranges) or Text.

Specified by:
unary in interface Data
Overrides:
unary in class DataImpl
Parameters:
op - may be Data.ABS, Data.ACOS, etc; these include all unary operations defined for Java primitive data types
sampling_mode - may be Data.NEAREST_NEIGHBOR or Data.WEIGHTED_AVERAGE
error_mode - may be Data.INDEPENDENT, Data.DEPENDENT or Data.NO_ERRORS;
Returns:
result of operation, which takes the MathType of this unless the default Units of that MathType conflict with Units of the result, in which case a generic MathType with appropriate Units is constructed
Throws:
VisADException - a VisAD error occurred
RemoteException - an RMI error occurred

unary

public Data unary(int op,
                  MathType new_type,
                  int sampling_mode,
                  int error_mode)
           throws VisADException
Description copied from class: FlatField
Return new FlatField with value 'this op'.

Specified by:
unary in interface Data
Overrides:
unary in class FlatField
Parameters:
op - operation to perform (e.g., NOP, ABS, COS)
new_type - MathType of new object
sampling_mode - sampling mode to use (e.g., NEAREST_NEIGHBOR, WEIGHTED_AVERAGE)
error_mode - error estimate mode (e.g., NO_ERROR, DEPENDENT, independent)
Returns:
new FlatField corresponding to the requested operation
Throws:
VisADException - couldn't create new VisAD object

unpackValues

public double[][] unpackValues()
                        throws VisADException
unpack an array of doubles from field sample values according to the RangeSet-s; returns a copy

Overrides:
unpackValues in class FlatField
Throws:
VisADException

unpackFloats

public float[][] unpackFloats()
                       throws VisADException
unpack an array of floats from field sample values according to the RangeSet-s; returns a copy

Overrides:
unpackFloats in class FlatField
Throws:
VisADException

extract

public Field extract(int component)
              throws VisADException,
                     RemoteException
Description copied from class: FlatField
extract field from this[].component; this is OK, when we get around to it

Specified by:
extract in interface Field
Overrides:
extract in class FlatField
Throws:
VisADException
RemoteException

domainFactor

public Field domainFactor(RealType factor)
                   throws VisADException,
                          RemoteException
Description copied from class: FieldImpl
Factors this instance into a (nested) field-of-fields. The type of the domain of the outer field will be the type specified. The type of the domains of the inner fields will be the remainder of the original domain after the outer domain is factored out. Range data is not copied for FieldImpls, but will be for FlatFields.

Specified by:
domainFactor in interface Field
Overrides:
domainFactor in class FieldImpl
Parameters:
factor - The type of the domain for the outer field.
Returns:
The field-of-fields realization of this instance.
Throws:
DomainException - The domain of this instance cannot be factored as requested.
VisADException - VisAD failure.
RemoteException - Java RMI failure.
See Also:
for copy information

resample

public Field resample(Set set,
                      int sampling_mode,
                      int error_mode)
               throws VisADException,
                      RemoteException
Description copied from class: FlatField
Resamples the range to domain samples of a given set. Resampling is either by nearest neighbor or mulit-linear interpolation. NOTE: This code is very similar to FieldImpl.resample(Set,int,int).

Specified by:
resample in interface Function
Overrides:
resample in class FlatField
Parameters:
set - The set of points at which to resample this field.
sampling_mode - Resampling mode: Data.NEAREST_NEIGHBOR or Data.WEIGHTED_AVERAGE
error_mode - Error estimation mode: Data.DEPENDENT, Data.INDEPENDENT, or Data.NO_ERRORS.
Returns:
Field of resampled data. RangeSet objects in result are set to DoubleSet. NOTE: May return this (i.e., not a copy).
Throws:
VisADException - unable to resample function
RemoteException - Java RMI exception

computeRanges

public DataShadow computeRanges(ShadowType type,
                                DataShadow shadow)
                         throws VisADException
Description copied from interface: Data
Recursive version of computeRanges(), called down through Data object tree.

Specified by:
computeRanges in interface Data
Overrides:
computeRanges in class FlatField
Parameters:
type - ShadowType generated for MathType of this
shadow - DataShadow instance whose contained double[][] array and animation sampling Set are modified according to RealType values in this, and used as return value
Returns:
DataShadow instance containing double[][] array of RealType ranges, and an animation sampling Set
Throws:
VisADException - a VisAD error occurred

adjustSamplingError

public Data adjustSamplingError(Data error,
                                int error_mode)
                         throws VisADException,
                                RemoteException
Description copied from class: FlatField
return a FlatField that clones this, except its ErrorEstimate-s are adjusted for sampling errors in error

Specified by:
adjustSamplingError in interface Data
Overrides:
adjustSamplingError in class FlatField
error_mode - may be Data.INDEPENDENT, Data.DEPENDENT or Data.NO_ERRORS;
Returns:
clone of this, except with ErrorEstimates set according to values in error
Throws:
VisADException - a VisAD error occurred
RemoteException - an RMI error occurred

isFlatField

public boolean isFlatField()
Description copied from interface: Field
return true if this a FlatField or a RemoteField adapting a FlatField

Specified by:
isFlatField in interface Field
Overrides:
isFlatField in class FlatField

clone

public Object clone()
Clones this instance. This implementation violates the general clone() contract in that the returned object will compare unequal to this instance. As such, this method should probably not be invoked.

Overrides:
clone in class FlatField
Returns:
A clone of this instance.

toString

public String toString()
Overrides:
toString in class FlatField
Returns:
a String representation of this

longString

public String longString(String pre)
Specified by:
longString in interface Data
Overrides:
longString in class FlatField
Parameters:
pre - String added to start of each line
Returns:
a longer String than returned by toString(), indented by pre (a string of blanks)