Re: Problems with plotting data on maps

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu, 23 Jun 2005 09:26:51 -0600 (MDT)

   Note: I'm posting this to both the pyngl-talk and ncl-talk email
   groups. It only affects PyNGL users, but this question originally
   came into ncl-talk, so I'm posting it here too.

On Tue, 21 Jun 2005, Kemp, Eric M. wrote:

> Dear ncl-talk:
> I am having some serious problems plotting gridded data on a map with
> PyNGL. It appears that the module assumes that gridded data is
> projected around the prime meridian, and does not allow changes to this
> projection even if the user changes the settings for the map. I am
> seeing this problem both with my own applications and with the example
> scripts that come with PyNGL. I have attached a sample postscript file
> showing the third plot from the fifth "Getting started with PyNGL"
> script. This is run on a Xeon Pentium maching running RedHat Linux.
> Any ideas?
> Eric Kemp
> Northrop Grumman IT TASC
> <<>>

After looking into this some more, Fred Clare and I found the source
of the problem. It has to do with using Numeric version 24.0b2 in
conjunction with the NetCDF module from ScientificPython (version
2.4.9). This problem does not occur with Numeric version 23.8. As
Fred reported to the Numeric email group:

     The problem arises in using the "min" function on a NetCDF
     floating array. In 23.8, the "min" function returns a floating
     scalar, while in 24.0b2 it returns an *array* of length "1". Below I
     list a simple NetCDF file and a Python script that illustrate the
     problem. When I run the script using 23.8, I get the result:

          1.0 <type 'float'>

     whereas using 24.0b2 I get:

          1.0 <type 'array'>

    NetCDF file simple.cdl (used to create with "ncgen")

    netcdf simple {
            num = 3 ;
            float temp(num) ;

     temp = 1, 2, 3 ;

    Python script

    import Numeric
    from Scientific.IO.NetCDF import NetCDFFile

    cdf_file1 = NetCDFFile("","r")
    temp = cdf_file1.variables["temp"][:]

    print min(temp), type(min(temp))

Obviously, this creates backward incompatibilities that breaks several
of our pyngl examples.

We are waiting to hear back from the Numeric folks about this issue,
but meanwhile, if you are running Numeric 24.0b2 in conjunction
with the netCDF module from ScientificPython, then be aware
that when you use min/max you will be getting an array value, and
not a scalar value.

This means that for PyNGL codes that expects a scalar value, like
in the pynglex example "ngl05p":

    resources.sfXCStartV = min(psl_lon)
    resources.sfYCStartV = min(psl_lat)
    resources.sfXCEndV = max(psl_lon)
    resources.sfYCEndV = max(psl_lat)

You will need to index the min/max functions:

    resources.sfXCStartV = min(psl_lon)[0]
    resources.sfYCStartV = min(psl_lat)[0]
    resources.sfXCEndV = max(psl_lon)[0]
    resources.sfYCEndV = max(psl_lat)[0]


pyngl-talk mailing list
Received on Thu Jun 23 2005 - 09:26:51 MDT

This archive was generated by hypermail 2.2.0 : Thu Jan 19 2006 - 21:31:53 MST