NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

R: Help on Data Transect

Hi

I noticed I had inverted rt_lon and rt_lat in the domain used by the
Gridded2DDoubleSet of "makeLatitudeLineSet" and "makeLongitudeLineSet"...

The code works now correctly!


Thanks

Antonio Benvenuti



-----Messaggio originale-----
Da: Antonio Benvenuti [mailto:antonio.benvenuti@xxxxxxxxx] 
Inviato: martedì 26 settembre 2006 14.37
A: 'dmurray@xxxxxxxxxxxxxxxx'
Cc: 'visad@xxxxxxxxxxxxxxxx'
Oggetto: R: Help on Data Transect


Hi Don

I have tried integrating the IDV's data transect as suggested by you, but
found it too expensive for the time I have to spend on the project.
So I tried to implement a simple data transect functionality as the
P6_05.java example.
The example is very simple, but I can not understand why I get Nan values
for the transect line that results from the intersection of a flatfield and
a line.

Could you please give me a hint?

Here is my code:


        // Displays the transect line on the main display
        try {
            ConstantMap[] cMaps = { new ConstantMap( 1.0f, Display.Red ),
                                    new ConstantMap( 1.0f, Display.Green ),
                                    new ConstantMap( 1.0f, Display.Blue ),
                                    new ConstantMap( 5.50f,
Display.PointSize )  };
            
            final int numberOfPoints = 1000;
            
            // Line transect
            final double initLatitude
currentRangeLat[0]+(currentRangeLat[1]-currentRangeLat[0])/2;
            final double initLongitude
currentRangeLon[0]+(currentRangeLon[1]-currentRangeLon[0])/2;
            
            Real cursorCoords;
            
            if (cutLongitude == true) {
                cursorCoords  = new Real(rt_lon, initLongitude);    
            }
            else {
                cursorCoords  = new Real(rt_lat, initLatitude);
            }
            
                ...

                // White Point
                cursorDataRef = new DataReferenceImpl("cursorDataRef");
                cursorDataRef.setData(cursorCoords);
                
                // White Line
                wLineDataRef = new DataReferenceImpl("wLineDataRef");
                                
                display.addReferences( new DirectManipulationRendererJ3D(),
cursorDataRef, cMaps );
                display.addReference(wLineDataRef);

                if (cutLongitude == true) {
                    whiteLine = (Set) makeLongitudeLineSet(initLatitude,
numberOfPoints);
                }
                else {
                    whiteLine = (Set) makeLatitudeLineSet(initLongitude,
numberOfPoints);
                }
                
                wLineDataRef.setData(whiteLine);
                
                // Transect Line
                tLineDataRef = new DataReferenceImpl("tLineDataRef");

                ConstantMap[] tLineMaps = { new ConstantMap(2.0f,
Display.PointSize) };
                transectDisplay.addReference(tLineDataRef, tLineMaps);

                surfsField = (FlatField) baseMap_sequence;
                transectLine = (FlatField) surfsField.resample(whiteLine);
                tLineDataRef.setData(transectLine);

                CellImpl cell = new CellImpl() {
                    public void doAction() throws RemoteException,
VisADException {

                        if (cutLongitude == true) {
                            Real lon = (Real) cursorDataRef.getData();
                            double lat = initLatitude;

                            // Make a new line
                            whiteLine = (Set)
makeLongitudeLineSet(lon.getValue(), numberOfPoints);
                        }
                        else {
                            double lon = initLongitude;
                            Real lat = (Real) cursorDataRef.getData();

                            // Make a new line
                            whiteLine = (Set)
makeLatitudeLineSet(lat.getValue(), numberOfPoints);
                        }                        

                        // Re-set Data, will update display
                        wLineDataRef.setData(whiteLine);

                        // Transect Data
                        surfsField = (FlatField) baseMap_sequence;
                        
                        int resampMode = Data.NEAREST_NEIGHBOR;
                        int errorMode = Data.NO_ERRORS;
                        
                        transectLine = (FlatField)
surfsField.resample(whiteLine,          <--------------------------------
 
resampMode,             <- HERE I GET ONLY "NAN" VALUES! |
 
errorMode);             <--------------------------------
                        tLineDataRef.setData(transectLine);
                    }
                };
                cell.addReference(cursorDataRef);

                ...

        }
        catch (Exception e) {
                ...
        }


And the make line methods that seem to work correctly:


    private Set makeLongitudeLineSet(double northingValue, int pointsPerLine
)
        throws VisADException, RemoteException {

        // Arbitrary easting end values of the line
        double lowVal =  currentRangeLat[0];
        double hiVal  =  currentRangeLat[1];
        

        double[][] domainSamples = new double[2][pointsPerLine];

        double lonVal = lowVal;
        double increment = ( hiVal - lowVal )/ (double) (pointsPerLine-1) ;
        for(int i=0;i<pointsPerLine;i++){
            domainSamples[0][i] = lonVal;
            domainSamples[1][i] = northingValue;
            lonVal += increment;
        }
        
        RealTupleType domain = new RealTupleType(rt_lon, rt_lat);

        return new Gridded2DDoubleSet( domain, domainSamples,
pointsPerLine);
    }

    private Set makeLatitudeLineSet(double eastingValue, int pointsPerLine )
        throws VisADException, RemoteException {

        // Arbitrary northing end values of the line
        double lowVal =  currentRangeLon[0];
        double hiVal  =  currentRangeLon[1];


        double[][] domainSamples = new double[2][pointsPerLine];

        double latVal = lowVal;
        double increment = ( hiVal - lowVal )/ (double) (pointsPerLine-1) ;
        for(int i=0;i<pointsPerLine;i++){
            domainSamples[0][i] = eastingValue;
            domainSamples[1][i] = latVal;
            latVal += increment;
        }
        
        RealTupleType domain = new RealTupleType(rt_lon, rt_lat);

        return new Gridded2DDoubleSet( domain, domainSamples,
pointsPerLine);
    }


Thanks

Antonio Benvenuti



-----Messaggio originale-----
Da: Don Murray [mailto:dmurray@xxxxxxxxxxxxxxxx]
Inviato: lunedì 11 settembre 2006 15.55
A: Antonio Benvenuti
Cc: visad@xxxxxxxxxxxxxxxx
Oggetto: Re: Help on Data Transect

Hi Antonio-

Antonio Benvenuti wrote:

> I would like to implement a functionality like IDV's "Data Transect" 
> in my application.
> I am actually representing a base map from a netcdf file, mapping 
> latitude, longitude respectively on the Y, X axes and the altitude as RGB
values.
> Could you suggest me a way to do it?

The easiest thing would be too look through the
ucar.unidata.idv.control.DataTransectControl and work your way back. But for
a quick summary the IDV has:

3 Data References with RealTuples (XYZ) in them for the selector points (two
end points, one mid point).
1 Data Reference with a Gridded2DSet on a 1D manifold (for the line)
ActionImpls that listen for changes when the selector points are directly
manipulated and update the postions of the line and other points.

A listener on the line so that when it changes:
  - A sampling set of points along the line is generated
    (see ucar.unidata.data.grid.GridUtil.sliceAlongLatLonLine)
  - the data field is resamples along that line.

You could reinvent this all, or just use the pieces of the IDV library that
we've already developed.

Don
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
*************************************************************


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.3/447 - Release Date: 13/09/2006
 

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.9/456 - Release Date: 25/09/2006
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.9/456 - Release Date: 25/09/2006
 


==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


  • 2006 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: