Re: resample with RealTupleType.SpatialEarth2DTuple

Hi Garrett-

"Campbell, Garrett" wrote:
> 
> I am attempting to read a Mcidas area (via adde) and then resample it to
> a
> grid with longitude increase to the right and lat increase up.
> 
> The RealTupleType.SpatialEarth2DTuple seems to be the correct type to
> represent that
> grid.  But the resampling produces all missing data.
> 
> I began this code using RealTupleType.LatitudeLongitudeTuple which seems
> to work fine
> except the image is rotated with respect to the normal view point.
> 
> is there something precular about Earth2DTuple??

In a McIDAS image read in through AreaAdapter, the domain is
(ImageElement, ImageLine) with a coordinate system that
transforms to (Latitude, Longitude).  SpatialEarth2DTuple is
(Longitude, Latitude), and LatitudeLongitudeTuple is
(Latitude, Longitude).  So, given your data structure, you should
use LLT.  The image data object is not rotated from it's 
original structure using LLT, but if you display the data
using graph.image, it assumes the first component of the domain
should map to  X and the second to Y, you end up with scalarmaps of
Latitude -> X, Longitude -> Y, which is a rotated image.  The
Display doesn't know that Latitude is supposed to be mapped
to Y, but only goes on what you've told it to do.  The data
are in (Latitude, Longitude) coordinates and are correct.
It's your display that is backwards.  For a test of this,
change:

  dom_1 = RealType.getRealType(domainType(data,0) )
  dom_2 = RealType.getRealType(domainType(data,1))

to:

  dom_2 = RealType.getRealType(domainType(data,0) )
  dom_1 = RealType.getRealType(domainType(data,1))

in the image section of graph.py, use LLT to resample and 
you'll see that your data are displayed correctly.

I suspect that you are getting missing data back using
SpatialEarth2DTuple because the resampling is assuming 
that your Longitudes are Latitudes (sampling on the first 
in the Tuple) and vice-versa which would put the sampling 
domain outside the domain of the image. Thus, you'd get 
missing values back.  I'm surprised that the order isn't 
checked, maybe this is a bug.  However, using LLT for your
sampling should give you the correct data - you just can't
use graph.image to display it if you want lon->X and lat->Y.

> Here is may test jython script. part of which works and part of which
> does not.
> 
> from java.awt import *
> from javax.swing import JFrame, JPanel
> from java.awt.event import *
> from visad.python.JPythonMethods import *
> from visad import *
> from visad import Real, Unit, RealType
> from visad.data.mcidas import AreaAdapter
> import graph
> latc = 40.
> lonc = -106
> #aeast
> AreaAdapter("adde://adde.ucar.edu/imagedata?group=rtimages&descr=ge-ir&l
> atlon=40 -105&size=100 100")
> #goese = aeast.getData()
> #etime1 = aeast.getNominalTime()
> #print etime1
> goese
> load("adde://adde.ucar.edu/imagedata?group=rtimages&descr=ge-ir&latlon=4
> 0 -105&size=100 100")
> ##   load and getData produce the same result
> graph.image(goese,colortable=None,title="goese raw")
> ##  display is ok but lat/lon do not seem to have been loaded
> 
> sampleLat = makeDomain(RealTupleType.LatitudeLongitudeTuple, 39, 41, 61,
> -106, -104, 61)
> d = goese.resample(sampleLat, Data.NEAREST_NEIGHBOR, Data.NO_ERRORS)
> graph.image(d,title="east Lat")  #  ok , but lat increasing to right,
> lon increasing up

Data is okay, graph is backwards.
 
> sampleDomain = makeDomain(RealTupleType.SpatialEarth2DTuple , -106.,
> -104., 61, 39., 41., 61)
> x = sampleDomain.getX()
> print "xlocs "
> print x.getFirst()
> print x.getLast()
> y = sampleDomain.getY()
> print "ylocs "
> print y.getFirst()
> print y.getLast()
> d2 = goese.resample(sampleDomain, Data.NEAREST_NEIGHBOR, Data.NO_ERRORS)
> graph.image(d2,title="east Lon")  # all seem to be missing
> # this image display seems to have the correct lat/lon reference when
> doing right/left mouse down and moveing around
> # just all the data is missing.  Must be the resample function did not
> interpret SpatialEarth2DTuple correctly.

I think the last statement is correct.
 
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
*************************************************************


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