[ncl-talk] gsn_contour_map, zoom in plot problem

Mary Haley haley at ucar.edu
Tue Oct 17 10:02:16 MDT 2017


Hi Ying,

Thanks for the data and script.

The gsn_contour_map function is a generic plotting function that doesn't
look for metadata.

You should use gsn_csm_contour_map, which will examine your data variable
for lat/lon coordinate arrays, which is helpful for plotting over a map.

Please see the attached script, which is a modified version of your script.
You shouldn't need to use "trGridType" because your data is rectilinear,
which is fairly straightforward to plot.

If you are new to NCL plotting, you may want to look over the NCL User
Guide:

http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/

You may also want to visit our "Plotting data on a map" examples page:

http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml
http://www.ncl.ucar.edu/Applications/

--Mary


On Mon, Oct 16, 2017 at 5:04 PM, Ying Song <ying.song at sjsu.edu> wrote:

>>  MERRA2_400.inst3_3d_asm_Np.20160601.nc
> <https://drive.google.com/a/sjsu.edu/file/d/0B67osBUwSAudOC15MWZsRzAwZWc/view?usp=drive_web>
> ​Hello, Mary,
>
> I tried to the "trGridType" setting and got this error:
> fatal:ContourPlotDraw: Workspace reallocation would exceed maximum size
> 100000000
> fatal:ContourPlotDraw: draw error
> fatal:ContourPlotDraw: draw error
> fatal:PlotManagerDraw: error in plot draw
> fatal:_NhlPlotManagerDraw: Draw error
> -----------------
>
> the script is attached. The MERRA-2 file I used is quite large (2.9G). I
> tried to upload it to ftp following the link you sent. Got some error msg
> below. So I attached it using google drive. Hope you are able to download
> it.
>
> 200 PORT command sucessful. Consider using PASV
> 553 Could not create file.
> ---------------------
>
> Thanks!
>
> Ying
>
>
> On Thu, Sep 21, 2017 at 10:12 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> Ying,
>>
>> Sorry about the delay, I've been out-of-town.
>>
>> Were you able to figure out the problem? Did you try the "trGridType"
>> setting that the message recommended? This is needed if your lat/lon
>> coordinates contain missing values.
>>
>>  If you are still having a problem, it would help if I could have access
>> to your data file and the latest version of your script.
>>
>> You can upload these to our ftp site:
>>
>> http://www.ncl.ucar.edu/ftp_files.shtml
>>
>> --Mary
>>
>>
>>
>> On Fri, Sep 8, 2017 at 2:58 AM, Ying Song <ying.song at sjsu.edu> wrote:
>>
>>> Hello, Mary,
>>>
>>> I modified my script following your first suggestion. The problem is
>>> still there. The warning msg shows:
>>> -------------------------------------------------
>>> Variable: o3_p
>>> Type: float
>>> Total Size: 831744 bytes
>>>             207936 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes:   [lat | 361] x [lon | 576]
>>> Coordinates:
>>>             lat: [ -90..  90]
>>>             lon: [-180..179.375]
>>> Number Of Attributes: 13
>>>   lev :  900
>>>   time :        540
>>>   long_name :   ozone mixing ratio
>>>   units :       ppbv
>>>   _FillValue :  1e+15
>>>   missing_value :       1e+15
>>>   fmissing_value :      1e+15
>>>   scale_factor :         1
>>>   add_offset :   0
>>>   standard_name :       ozone_mass_mixing_ratio
>>>   vmax :        1e+15
>>>   vmin :        -1e+15
>>>   valid_range : ( -1e+15, 1e+15 )
>>> warning:ContourPlotDraw: out of range coordinates encountered; standard
>>> AreaFill rendering method may be unreliable;
>>>  consider setting the resource trGridType to "TriangularMesh" if
>>> coordinates contain missing values
>>> -------------------------------------
>>> And I attached the updated script. I wounder if I need to add triangular
>>> meshes resource in my script?
>>>
>>> Thanks!
>>>
>>> On Thu, Sep 7, 2017 at 8:46 AM, Mary Haley <haley at ucar.edu> wrote:
>>>
>>>> I think the issue is that "o3_p", which is the variable you are trying
>>>> to plot, doesn't have any metadata attached to it.
>>>>
>>>> When you do calculations like this in NCL:
>>>>
>>>>    o3= a->O3(3,4,:,:) ; 18GTM = 11AM PST
>>>>
>>>>   printVarSummary(o3)
>>>>    o3_p =(o3*1e9)*(28.97/48)
>>>>
>>>> The "o3" will have metadata because no computations were done when you
>>>> read the variable off the file.
>>>>
>>>> However, since o3_p involves calculations, NCL will strip all the
>>>> metadata and the only thing that o3_p will retain from o3 is the _FillValue
>>>> attribute, if any.
>>>>
>>>> As a "trick", you can force o3_p to have the same metadata by doing the
>>>> following:
>>>>
>>>>    o3_p = a->O3(3,4,:,:) ; 18GTM = 11AM PST
>>>>
>>>>    o3_p =(o3_p*1e9)*(28.97/48)
>>>>
>>>> The first line will read the data into o3_p, and the metadata will all
>>>> be there. Then, when you do the calculation, since o3_p already exists, no
>>>> metadata will be removed.
>>>>
>>>> Note that I removed the use of o3, just to save memory. If you need to
>>>> keep o3 and o3_p around, then you can do:
>>>>
>>>>    o3 = a->O3(3,4,:,:) ; 18GTM = 11AM PST
>>>>    o3_p = o3           ; trick to copy metadata
>>>>    o3_p =(o3*1e9)*(28.97/48)
>>>>
>>>> You should however, update the long_name and units attributes of o3_p,
>>>> to reflect what the new values represent.
>>>>
>>>> --Mary
>>>>
>>>>
>>>> On Wed, Sep 6, 2017 at 5:05 PM, Ying Song <ying.song at sjsu.edu> wrote:
>>>>
>>>>> Hello, ncl helper,
>>>>>
>>>>> I trying to plot MERRA-2 reanalysis data in NCL using gsn_contour_map.
>>>>> I am only interested in west coast of US.  But I can not get the zoom in
>>>>> plot correctly by using resources:
>>>>>
>>>>>   res at mpMinLatF               = 30
>>>>>   res at mpMaxLatF               = 45
>>>>>   res at mpMinLonF               = -130
>>>>>   res at mpMaxLonF               = -110
>>>>>
>>>>> The warning shows:
>>>>> warning:ContourPlotDraw: out of range coordinates encountered;
>>>>> standard AreaFill rendering method may be unreliable;
>>>>>  consider setting the resource trGridType to "TriangularMesh" if
>>>>> coordinates contain missing values
>>>>>
>>>>> Attachment is my script. The info of MERRA-2 O3 data from
>>>>> printVarSummary is:
>>>>>  ------------------------------
>>>>> Variable: o3
>>>>> Type: float
>>>>> Total Size: 279465984 bytes
>>>>>             69866496 values
>>>>> Number of Dimensions: 4
>>>>> Dimensions and sizes:   [time | 8] x [lev | 42] x [lat | 361] x [lon |
>>>>> 576]
>>>>> Coordinates:
>>>>>             time: [0..1260]
>>>>>             lev: [1000..0.1000000014901161]
>>>>>             lat: [ -90..  90]
>>>>>             lon: [-180..179.375]
>>>>> Number Of Attributes: 11
>>>>>   long_name :   ozone_mass_mixing_ratio
>>>>>   units :       kg kg-1
>>>>>   _FillValue :  1e+15
>>>>>   missing_value :       1e+15
>>>>>   fmissing_value :      1e+15
>>>>>   scale_factor :         1
>>>>>   add_offset :   0
>>>>>   standard_name :       ozone_mass_mixing_ratio
>>>>>   vmax :        1e+15
>>>>>   vmin :        -1e+15
>>>>>   valid_range : ( -1e+15, 1e+15 )
>>>>> ---------------------------------------------------------
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> ncl-talk at ucar.edu
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171017/396f0073/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: o3_xy_plt_zoom_mod.ncl
Type: application/octet-stream
Size: 1342 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171017/396f0073/attachment.obj>


More information about the ncl-talk mailing list