Commit 14480e21 authored by rink's avatar rink
Browse files

A consistency check is not supported. Non-degenerate grids are trusted.

Enhance the documentation a bit.
parent d23b9ac5
...@@ -29,8 +29,13 @@ package visad; ...@@ -29,8 +29,13 @@ package visad;
import java.io.*; import java.io.*;
/** /**
GriddedLatLonSet represents a finite set of samples of R^2.<P> *
*/ * @author rink
*
* GriddedLatLonSet represents a finite set of samples with a 2D grid topology on the surface
* of the Earth mapped to R^2: (Longitude, Latitude) or (Latitude, Longitude). This class
* exists primarily to override valueToGrid and gridToValue.
*/
public class GriddedLatLonSet extends Gridded2DSet { public class GriddedLatLonSet extends Gridded2DSet {
int LengthX, LengthY, TrackLen, latI, lonI; int LengthX, LengthY, TrackLen, latI, lonI;
...@@ -46,7 +51,7 @@ public class GriddedLatLonSet extends Gridded2DSet { ...@@ -46,7 +51,7 @@ public class GriddedLatLonSet extends Gridded2DSet {
null errors, CoordinateSystem and Units are defaults from type */ null errors, CoordinateSystem and Units are defaults from type */
public GriddedLatLonSet(MathType type, float[][] samples, int lengthX, int lengthY) public GriddedLatLonSet(MathType type, float[][] samples, int lengthX, int lengthY)
throws VisADException { throws VisADException {
this(type, samples, lengthX, lengthY, null, null, null, false, false); this(type, samples, lengthX, lengthY, null, null, null, false);
} }
/** a 2-D set whose topology is a lengthX x lengthY grid; /** a 2-D set whose topology is a lengthX x lengthY grid;
...@@ -59,23 +64,14 @@ public class GriddedLatLonSet extends Gridded2DSet { ...@@ -59,23 +64,14 @@ public class GriddedLatLonSet extends Gridded2DSet {
public GriddedLatLonSet(MathType type, float[][] samples, int lengthX, int lengthY, public GriddedLatLonSet(MathType type, float[][] samples, int lengthX, int lengthY,
CoordinateSystem coord_sys, Unit[] units, CoordinateSystem coord_sys, Unit[] units,
ErrorEstimate[] errors) throws VisADException { ErrorEstimate[] errors) throws VisADException {
this(type, samples, lengthX, lengthY, coord_sys, units, errors, this(type, samples, lengthX, lengthY, coord_sys, units, errors, false);
true, true);
} }
public GriddedLatLonSet(MathType type, float[][] samples, int lengthX, int lengthY, public GriddedLatLonSet(MathType type, float[][] samples, int lengthX, int lengthY,
CoordinateSystem coord_sys, Unit[] units, CoordinateSystem coord_sys, Unit[] units,
ErrorEstimate[] errors, boolean copy) ErrorEstimate[] errors, boolean copy)
throws VisADException { throws VisADException {
this(type, samples, lengthX, lengthY, coord_sys, units, errors, super(type, samples, lengthX, lengthY, coord_sys, units, errors, copy, false);
copy, true);
}
public GriddedLatLonSet(MathType type, float[][] samples, int lengthX, int lengthY,
CoordinateSystem coord_sys, Unit[] units,
ErrorEstimate[] errors, boolean copy, boolean test)
throws VisADException {
super(type, samples, lengthX, lengthY, coord_sys, units, errors, copy, test);
LowX = Low[0]; LowX = Low[0];
HiX = Hi[0]; HiX = Hi[0];
...@@ -136,15 +132,17 @@ public class GriddedLatLonSet extends Gridded2DSet { ...@@ -136,15 +132,17 @@ public class GriddedLatLonSet extends Gridded2DSet {
System.arraycopy(lons, lons0.length, lons1, 0, lons1.length); System.arraycopy(lons, lons0.length, lons1, 0, lons1.length);
System.arraycopy(lats, lats0.length, lats1, 0, lats1.length); System.arraycopy(lats, lats0.length, lats1, 0, lats1.length);
granules[0] = new GriddedLatLonSet(type, new float[][] {lons0, lats0}, LengthX, TrackLen0, coord_sys, units, errors, copy, test); granules[0] = new GriddedLatLonSet(type, new float[][] {lons0, lats0}, LengthX, TrackLen0, coord_sys, units, errors, copy);
granules[1] = new GriddedLatLonSet(type, new float[][] {lons1, lats1}, LengthX, TrackLen1, coord_sys, units, errors, copy, test); granules[1] = new GriddedLatLonSet(type, new float[][] {lons1, lats1}, LengthX, TrackLen1, coord_sys, units, errors, copy);
} }
} }
/** transform an array of non-integer grid coordinates to an array /** transform an array of non-integer grid coordinates to an array of values in (Longitude, Latitude).
of values in R^DomainDimension */ * Returns nearest neighbor if the cell which contains the grid coordinate straddles
* the dateline or prime meridian.
*/
public float[][] gridToValue(float[][] grid) throws VisADException { public float[][] gridToValue(float[][] grid) throws VisADException {
if (grid.length != ManifoldDimension) { if (grid.length != ManifoldDimension) {
throw new SetException("Gridded2DSet.gridToValue: grid dimension " + throw new SetException("Gridded2DSet.gridToValue: grid dimension " +
...@@ -258,6 +256,16 @@ public class GriddedLatLonSet extends Gridded2DSet { ...@@ -258,6 +256,16 @@ public class GriddedLatLonSet extends Gridded2DSet {
return valueToGrid(value, null); return valueToGrid(value, null);
} }
/** transform an array of values in R^2 (Longitude, Latitude) to an array
* of non-integer grid coordinates by walking the grid from guess to incoming
* target values by minimizing the angle between vectors from Earth center to the
* their respective Earth coordinates.
* @param value (Longitude, Latitude)
* @param guess Integer grid coordinate. Is replaced by last valid grid located
* the search. If null, center points of domain is used as guess.
* @return Fractional grid coordinates for incoming values
* @throws visad.VisADException
*/
@Override @Override
public synchronized float[][] valueToGrid(float[][] value, int[] guess) throws VisADException { public synchronized float[][] valueToGrid(float[][] value, int[] guess) throws VisADException {
......
...@@ -31,9 +31,10 @@ package visad; ...@@ -31,9 +31,10 @@ package visad;
* @author rink * @author rink
* *
* Specialized extension to GriddedLatLonSet for a contiguous collection of spatially overlapping sets * Specialized extension to GriddedLatLonSet for a contiguous collection of spatially overlapping sets
* wherein samples of an individual set are spatially coherent (they pass the consistency test: no bow-ties). * wherein it's trusted that samples of an individual set are spatially coherent (non-degenerative: no bow-ties).
* Examples are MODIS and VIIRS whose granules are comprised of multiple scans, each with a fixed number of * Examples are MODIS and VIIRS whose granules are comprised of multiple scans, each with a fixed number of
* detectors, and perpendicular to the polar orbit track. Its primary purpose is to override valueToGrid. * detectors, and perpendicular to the polar orbit track, but may overlap when navigated to the Earth's surface.
* The primary purpose of this class is to override valueToGrid.
* *
*/ */
public class XTrackScanLatLonSet extends GriddedLatLonSet { public class XTrackScanLatLonSet extends GriddedLatLonSet {
...@@ -45,7 +46,7 @@ public class XTrackScanLatLonSet extends GriddedLatLonSet { ...@@ -45,7 +46,7 @@ public class XTrackScanLatLonSet extends GriddedLatLonSet {
int lastSetIdx; int lastSetIdx;
public XTrackScanLatLonSet(MathType type, float[][] samples, int XTrackLen, int TrackLen, int linesPerScan) throws VisADException { public XTrackScanLatLonSet(MathType type, float[][] samples, int XTrackLen, int TrackLen, int linesPerScan) throws VisADException {
super(type, samples, XTrackLen, TrackLen, null, null, null, false, false); super(type, samples, XTrackLen, TrackLen, null, null, null, false);
if ((TrackLen % linesPerScan) != 0) { if ((TrackLen % linesPerScan) != 0) {
throw new VisADException("There must be an intergral number of scans with detectorsPerScan: "+linesPerScan+" per " throw new VisADException("There must be an intergral number of scans with detectorsPerScan: "+linesPerScan+" per "
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment