Re: scalar map choices with map projections and grids

Hi Stuart,

> Hi all, I have a model grid based on some projection, say LambertCC, and a
> base map.  Of course the base map values are lat,lon, as would be any obs
> etc, so I define a MapProjectionAdapter as a display side coord sys
> (snarfed from visad/examples and also from the idv code base), so I
> get scalarmaps for RealType.Latitude, Longitude to Display.YAxis and
> Display.XAxis.

If you have a display-side coord sys don't you use ScalarMaps of
RealType.Latitude, RealType.Longitude to your new DisplayRealTypes
rather than to XAxis, YAxis?

> Now, for my grid, I used to do this (assume projection has false
> easting/northing such that grid point 1,1 maps to 0 meters in x and y)
>
> addGrid( int rows, int cols, int spacing ) {
>
> RealType x = RealType.getRealType( "x" );
> same for y
>
> RealTypeTuple rtt = new RealTupleType( x, y );
> Linear2DSet domain = new Linear2DSet( rtt, 0, rows-1*spacing, 0,
> cols -1 * spacing, cols );
>
> ScalarMap sx = new ScalarMap( x, Display.XAxis );
> same for y, add maps sx, sy to display

Here you are ScalarMap'ping x, y to XAxis, YAxis and presumably
x, y are not equal to RealType.Latitude, RealType.Longitude,
which are also ScalarMap'ed to XAxis, YAxis?

> So data of type x,y use their own scalar maps to display axes,
> independently of any lat,lon typed data.
>
> Now, as I delve into visad more, and noting some comments by Bill, I see
> that I could do it this alternate way
>
> addGrid( int rows, cols, spacing ) {
>
> RealType x = RealType.getRealType( "x", CommonUnit.METER );
> same for y
>
> RealTupleType ref = new RealTupleType( x, y, mapProjection.getReference()
> );
>
> and build the domain as before (supplying coordsys units from the
> mapprojection).  No scalar maps for any x or y realType are needed.
>
> So, is there a "best way" of the two??  Seems to me that the latter is
> cleaner but more expensive?  For each grid point, we use the projection's
> coord sys to transform grid x,y -> lat, lon but then to map that value to
> the display side we have to go through the inverse?  If I had scalar maps
> straight from x and y I would avoid this (??)
>
> Performance looks about the same on initial testing, but not much to go as
> as yet...
>
> Any help and comments appreciated.

Assuming that:

1. what you're really doing is mapping lat, lon to your new
   DisplayRealTypes, with coord sys with reference XAxis, YAxis
2. your data-side coord sys is the inverse of your display-side
   coord sys
3. your maps of x, y to XAxis, YAxis avoid going through the
   coord sys and then its inverse

then this should be faster, but a bit more dangerous. For
example, you may want to make explicit calls to setRange()
for your ScalarMaps so auto-scaling doesn't mess this up.

Makes me wonder whether the IDV or other applications use
a similar trick to avoid coord sys transforms.

Good luck,
Bill


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