// // Set.java // /* VisAD system for interactive analysis and visualization of numerical data. Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and Tommy Jasmin. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ package visad; import java.rmi.*; // // TO DO: // // finish GriddednDSet using VisAD Enumerated logic. // // add MultiGridded for union of grids // Field evalualtion as mean of non-missing values in each grid // // Field and FlatField: options (mode?) for Interpolated and NotInterpolated // // Field and FlatField: test for operations on IntegerSet and optimize // // change lots of methods to default protection (visible within package only) // // /** *. RETURN_VALUESet is the abstract superclass of the VisAD hierarchy of sets.
* *
Set-s are subsets of R^n for n>0. For the most part, Set objects are * immutable (but see {@link SampledSet#getSamples(boolean)}).
*/ public abstract class Set extends DataImpl implements SetIface { int DomainDimension; // this is a subset of R^DomainDimension int Length; // number of samples CoordinateSystem DomainCoordinateSystem; transient boolean hashCodeSet = false; transient int hashCode = 0; Unit[] SetUnits; ErrorEstimate[] SetErrors; /** caches of Set-s that return false and true to equals(); useful for GriddedSet and other Set subclasses which have expensive equals tests; WLH 6 Nov 97 - don't use these. they hinder garbage collection and won't accomplish much practical private static final int CACHE_LENGTH = 10; private Set[] NotEqualsCache; private int LastNotEquals; private Set[] EqualsCache; private int LastEquals; */ /** construct a Set object */ public Set(MathType type) throws VisADException { this(type, null, null, null); } /** * Constructs a Set object with a non-default CoordinateSystem.
* * @param type The type of the Set. * @param coord_sys The CoordinateSystem associated with this * Set. */ public Set(MathType type, CoordinateSystem coord_sys) throws VisADException { this(type, coord_sys, null, null); } /** * Constructs a Set object with a non-default CoordinateSystem, non-default * Unit-s, and non-default errors. This is the most general constructor.
* * @param type The MathType of the set. May be a RealType, * a RealTupleType, or a SetType. * @param coord_sys Optional coordinate system for the domain of the * set. May be
null, in which case * the default coordinate system of the domain is * used. * @param units Optional units for the values. May * benull, in which case * the default units of the domain are * used. If theith element is * non-nulland the RealType of the * corresponding domain component is an interval, * then the unit that is actually used is* units[i].getAbsoluteUnit(). * @param errors Error estimates. May benull. *errors[i]is the error estimate * for thei-th component and may be *null. */ public Set(MathType type, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors) throws VisADException { super(adjustType(type)); Length = 0; DomainDimension = getDimension(type); RealTupleType DomainType = ((SetType) Type).getDomain(); CoordinateSystem cs = DomainType.getCoordinateSystem(); if (coord_sys == null) { DomainCoordinateSystem = cs; } else { if (cs == null || !cs.getReference().equals(coord_sys.getReference())) { throw new CoordinateSystemException( "Set: coord_sys " + coord_sys.getReference() + " must match Type.DefaultCoordinateSystem " + (cs == null ? null : cs.getReference())); } DomainCoordinateSystem = coord_sys; } if (DomainCoordinateSystem != null && !Unit.canConvertArray(DomainCoordinateSystem.getCoordinateSystemUnits(), DomainType.getDefaultUnits())) { throw new UnitException("Set: CoordinateSystem Units must be " + "convertable with DomainType default Units"); } if (units == null) { SetUnits = (DomainCoordinateSystem == null) ? DomainType.getDefaultUnits() : DomainCoordinateSystem.getCoordinateSystemUnits(); } else { if (units.length != DomainDimension) { throw new UnitException("Set: units dimension " + units.length + " does not match Domain dimension " + DomainDimension); } SetUnits = new Unit[DomainDimension]; Unit[] dunits = DomainType.getDefaultUnits(); for (int i=0; inull [i]* is the unit of thei-th component * and may benull. */ public Unit[] getSetUnits() { return Unit.copyUnitsArray(SetUnits); } /** * Returns the error estimates of the values in the set. * @return Error estimates for the set. Will not be *null. RETURN_VALUE[i]* is the error estimate for thei-th * component and may benull. */ public ErrorEstimate[] getSetErrors() { return ErrorEstimate.copyErrorsArray(SetErrors); } /** * Gets the coordinate system of this domain set (DomainCoordinateSystem). * @return The coordinate system of this domain * set. This will be the coordinate * system passed to the constructor if * non-null; otherwise, the * (default) coordinate system of the * underlying RealTupleType (which may be *null). */ public CoordinateSystem getCoordinateSystem() { return DomainCoordinateSystem; } /** get DomainDimension (i.e., this is a subset of R^DomainDimension) */ public int getDimension() { return DomainDimension; } /** for non-SimpleSet, ManifoldDimension = DomainDimension */ public int getManifoldDimension() { return DomainDimension; } /** get the number of samples */ public int getLength() throws VisADException { return Length; } /** * A wrapper around {@link #getLength() getLength} for JPython. * * @return The number of elements in the Set */ public int __len__() throws VisADException { return Length; } /** return an enumeration of sample indices in a spatially coherent order; this is useful for efficiency */ public int[] getWedge() { int[] wedge = new int[Length]; for (int i=0; i1) { // set indices for values in this int[] test_indices = set.doubleToIndex(values); try { for (int i=0; i -1) set_indices[test_indices[i]] = false; } } catch (ArrayIndexOutOfBoundsException aioobe) { throw new VisADException("Cannot merge sets"); } } else { double[][] set_values = set.getDoubles(); double set_val = set_values[0][0]; double min = Double.MAX_VALUE; // double max = Double.MIN_VALUE; double max = -Double.MAX_VALUE; for (int i=0; i max) max = values[0][i]; if (values[0][i] < min) min = values[0][i]; } double delt = (max - min) / length; //System.out.println("min = " + min + " max = " + max + " delt = " + delt); if ((min - delt) <= set_val && set_val <= (max + delt)) { set_indices[0] = false; } } // now set_indices = true for indices of set not covered by this int num_new = 0; for (int i=0; i RETURN_VALUE [i][j]is the *jth component of sample-point *i. * @throws VisADException if a VisAD failure occurs. */ public double[][] indexToDouble(int[] index) throws VisADException { return floatToDouble(indexToValue(index)); } public int[] doubleToIndex(double[][] value) throws VisADException { return valueToIndex(doubleToFloat(value)); } public static double[][] floatToDouble(float[][] value) { if (value == null) return null; double[][] val = new double[value.length][]; for (int i=0; iReturns the indexes of the neighboring points for every point * in the set. neighbors.lengthshould be at least *getLength(). On return,neighbors[i][j]* will be the index of thej-th neighboring point of * pointi. This method will allocate and set the array *neighbors[i]for alli. * *This implementation always throws an {@link UnimplementedException}.
* * @param neighbors The array to contain the indexes of the * neighboring points. * @throws NullPointerException if the array isnull. * @throws ArrayIndexOutOfBoundsException * ifneighbors.length < getLength() *. * @throws VisADException if a VisAD failure occurs. */ public void getNeighbors( int[][] neighbors ) throws VisADException { throw new UnimplementedException("Set: getNeighbors()"); } public void getNeighbors( int[][] neighbors, float[][] weights ) throws VisADException { throw new UnimplementedException("Set: getNeighbors()"); } /** *Returns the indexes of the neighboring points along a manifold * dimesion for every point in the set. Elements
* *[i][0]* and[i][1]of the returned array are the indexes of the * neighboring sample points in the direction of decreasing and increasing * manifold index, respectively, for sample pointi. If a sample * point doesn't have a neighboring point (because it is an exterior point, * for example) then the value of the corresponding index will be -1.This implementation always throws an {@link UnimplementedException}.
* * @param dimension The index of the manifold dimension along * which to return the neighboring points. * @throws ArrayIndexOutOfBoundsException * ifmanifoldIndex < 0 || * manifoldIndex >= getManifoldDimension() *. * @throws VisADException if a VisAD failure occurs. * @see #getManifoldDimension() */ public int[][] getNeighbors(int dimension) throws VisADException { throw new UnimplementedException("Set: getNeighbors()"); } /** test set against a cache of Set-s not equal to this */ public boolean testNotEqualsCache(Set set) { /* WLH 6 Nov 97 if (NotEqualsCache == null || set == null) return false; for (int i=0; i(TupleType.java:47) at visad.Set.main(Set.java:155) FunctionType (Real): (Latitude(degrees), Longitude(degrees)) -> (vis_radiance, ir_radiance) FunctionType (Real): (ir_radiance) -> count FlatField missing FlatField missing Linear2DSet: Length = 16384 Dimension 1: Length = 128 Range = 0 to 127 Dimension 2: Length = 128 Range = 0 to 127 Linear1DSet: Length = 256 Range = 0 to 255 Integer2DSet: Length = 16384 Dimension 1: Length = 128 Dimension 2: Length = 128 Integer1DSet: Length = 256 iset1d iset2d 1 12 12 14 12 10 iris 236% */ }
Ads help maintain this website.