[pyngl-talk] contouring with the POP grid
Mary Haley
haley at ucar.edu
Wed Sep 9 09:59:39 MDT 2015
Judy,
I'm so sorry I let this slip.
The error is that you have a min latitude that is greater than the max
latitude:
res.mpMaxLatF = -79.
res.mpMinLatF = -50.
I modified the script to remove some of the code that processes the data
read off the file, because this is an unnecessary step. Also, because the
lat/lon arrays have missing values in them, you need to plot this using the
"triangular mesh" algorithm under the hood.
Please see the modified script and resultant PNG image which I attached.
--Mary
On Tue, Sep 1, 2015 at 10:31 AM, Judy Twedt <judytwedt at gmail.com> wrote:
> Hi Mary,
> Thanks for letting me know. I appreciate any assistance you can
> provide. I'm using PyNgl for all of my map plots now, but have been
> regridding ocean data as a short-term work around.
>
> best,
>
>
> On Tue, Sep 1, 2015 at 9:28 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> Hi Judy,
>>
>> I'm sorry I haven't gotten back to this. I'm just swamped right now. I
>> will try to look later today.
>>
>> --Mary
>>
>>
>> On Thu, Aug 27, 2015 at 12:29 PM, Judy Twedt <judytwedt at gmail.com> wrote:
>>
>>> Hello Mary and other PyNgl users,
>>> My name is Judy Twedt. I've recently started using PyNgl on
>>> yellowstone and have persistent problems plotting scalar fields from the
>>> popgrid using the Ngl.contour_map function. The lat/lon arrays are 2D,
>>> which I have raveled to 1D, but I get the following error message and a
>>> plot with unphysical lines which run off of the projection:
>>>
>>> warning:MapTransInitialize: latitude min exceeds max: exchanging values
>>>
>>> I made a short script to reproduce the problem which can be found and
>>> run at: /glade/p/work/jtwedt/LEdata/simplePOPcontour.py
>>>
>>> This example plots SH ice area -- I also tried it with ocean temperature
>>> (which spans both hemispheres) had have the same error. I'd very much
>>> appreciate your help locating the problem here.
>>>
>>> Thanks in advance for your advice!
>>>
>>> The script reads:
>>>
>>> import numpy as np
>>> from netCDF4 import Dataset
>>> import numpy.ma as ma
>>> import pdb
>>> import Ngl
>>>
>>> #load ice lat,lon arrays
>>> ds =
>>> Dataset('/glade/p/cesmLE/CESM-CAM5-BGC-LE/ice/proc/tseries/monthly/aice/b.e11.B20TRC5CNBDRD.f09_g16.032.
>>> cice.h.aice_sh.192001-200512.nc')
>>> lon1 = ds.variables['TLON'][:,:]
>>> lon = np.ravel(np.ma.filled(lon1, np.nan))
>>> lat1 = ds.variables['TLAT'][:,:]
>>> lat = np.ravel(np.ma.filled(lat1, np.nan))
>>> ice1= ds.variables['aice'][1,:,:]
>>> ice = np.ravel(ma.filled(ice1, np.nan))
>>>
>>> #pdb.set_trace()
>>>
>>> wks = Ngl.open_wks('X11', 'scalarPOP')
>>> res = Ngl.Resources()
>>> res.sfXArray = lon
>>> res.sfYArray = lat
>>> res.cnFillOn = True
>>> res.cnLinesOn = False
>>> res.mpProjection = 'Stereographic'
>>> res.mpLimitMode = 'LatLon'
>>> res.mpCenterLatF = -79.
>>> res.mpMaxLatF = -79.
>>> res.mpMinLatF = -50.
>>> Ngl.contour_map(wks, ice, res)
>>> Ngl.end()
>>>
>>>
>>> --
>>>
>>> Judy Twedt
>>>
>>> *Graduate Student *
>>> *Department of Atmospheric Sciences*
>>> *University of Washington*
>>>
>>
>>
>
>
> --
>
> Judy Twedt
>
> *Graduate Student *
> *Department of Atmospheric Sciences*
> *University of Washington*
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20150909/ffbac205/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scalar_pop.py
Type: text/x-python-script
Size: 2121 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20150909/ffbac205/attachment-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scalarPOP.png
Type: image/png
Size: 759194 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20150909/ffbac205/attachment-0001.png
More information about the pyngl-talk
mailing list