[ncl-talk] NCL Plotting
Mary Haley
haley at ucar.edu
Wed Feb 21 09:45:31 MST 2018
Ankita,
You need to be more specific about what you mean by a "bad plot".
My guess is that the data you are trying to plot has been stripped of all
of its metadata, which means there are no lat/lon coordinates being passed
to the plotting function.
When you do a calculation or call a function like uv2fsvpg, NCL will strip
off the metadata. It is the user's responsibility to copy or reconstruct
the metadata before plotting, especially if you need to plot it over a map.
If you look at the one example we have of using uv2sfvpg, sol_2.ncl:
http://www.ncl.ucar.edu/Applications/tropical.shtml#ex2
you will see this code:
psi = u ; Trick to copy metadata from u
to both
chi = u ; psi and chi before doing
calculation
uv2sfvpg(u,v,psi,chi) ; Calculate psi and chi
psi at long_name = "stream function" ; Update long_name attribute
chi at long_name = "velocity potential"
The first two lines copy all of u's metadata to psi and chi, including the
lat/lon coordinate arrays that were attached to u. This enables us to plot
psi and chi over a map.
Note that it's important to update the metadata after the calculation,
because the long_name and/or units may not be appropriate.
--Mary
On Sat, Feb 17, 2018 at 12:14 AM, Ankita Sharma <ankita at iiserb.ac.in> wrote:
> Dear all,
>
> Thank you for your time and reply.
> I have already used almost all the scripts for plotting but still, I am
> getting the bad plot.
> I am using ERA-Interim data for the year 2009 for zonal wind, meridional
> wind, divergence and velocity potential (which I have included by the help
> of function *uv2sfvpg*) but still getting a very bad plot.
> Please suggest me some other option if possible.
>
> Thanking you,
> Ankita Sharma
>
>
> On Wed, Feb 14, 2018 at 8:13 PM, Dennis Shea <shea at ucar.edu> wrote:
>
>> I suggest that you look at the NCL examples page;
>>
>> http://www.ncl.ucar.edu/Applications/
>>
>> Then look under "Vectors"
>>
>> -----------------------------------
>> Two ways to 'thin' vectors:
>>
>> (a) As noted by Barry: use NCL array syntax. This hard-wires a specific
>> subset.
>> plotB = gsn_csm_vector(wks,u_new*(::4,:**:4)*,v_new*(::4,::4)*
>> ,vecres)
>> Generally, this is
>> plotB = gsn_csm_vector(wks,u_new(::ny,
>> ::mx),v_new(::ny,::mx),vecres)
>> Note that 'ny' need not equal 'mx'
>> plotB = gsn_csm_vector(wks,u_new(::4,:
>> :2),v_new(::4,::2),vecres)
>>
>> (b) If you click on "Vectors"
>> http://www.ncl.ucar.edu/Applications/vector.shtml
>>
>> Within the top 'preamble', there is the comment:
>>
>> Important resources for controlling the length, *density,* direction,
>> and style of vectors:
>>
>> *[snip]*
>>
>> *vcMinDistanceF*
>> <http://www.ncl.ucar.edu/Document/Graphics/Resources/vc.shtml#vcMinDistanceF>
>> - *set to small value to thin the vectors*. <%%%%%%%%%%%%%%%%%
>>
>>
>> Then, click on "resources" at the top of the page and search for
>> "vcMinDistanceF". This will show you all the examples that use this
>> resource.
>>
>> This is an 'even better' way to thin vectore.
>>
>> *vcMinDistanceF*
>> <http://www.ncl.ucar.edu/Document/Graphics/Resources/vc.shtml#vcMinDistanceF>
>> WRF_2d_3.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/WRF_2d_3.ncl> (WRF 2D data
>> <http://www.ncl.ucar.edu/Applications/wrf2d.shtml#ex3>)
>> WRF_2d_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/WRF_2d_4.ncl> (WRF 2D data
>> <http://www.ncl.ucar.edu/Applications/wrf2d.shtml#ex4>)
>> WRF_lc_7.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/WRF_lc_7.ncl> (WRF lambert
>> conformal projections
>> <http://www.ncl.ucar.edu/Applications/wrflc.shtml#ex7>)
>> WRF_lc_8.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/WRF_lc_8.ncl> (WRF lambert
>> conformal projections
>> <http://www.ncl.ucar.edu/Applications/wrflc.shtml#ex8>)
>> barb_1.ncl <http://www.ncl.ucar.edu/Applications/Scripts/barb_1.ncl>
>> (wind barbs <http://www.ncl.ucar.edu/Applications/barb.shtml#ex1>)
>> barb_2.ncl <http://www.ncl.ucar.edu/Applications/Scripts/barb_2.ncl>
>> (wind barbs <http://www.ncl.ucar.edu/Applications/barb.shtml#ex2>)
>> barb_3.ncl <http://www.ncl.ucar.edu/Applications/Scripts/barb_3.ncl>
>> (wind barbs <http://www.ncl.ucar.edu/Applications/barb.shtml#ex3>)
>> ce_4.ncl <http://www.ncl.ucar.edu/Applications/Scripts/ce_4.ncl> (cylindrical
>> equidistant projections
>> <http://www.ncl.ucar.edu/Applications/cylineq.shtml#ex4>)
>> coamps_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/coamps_2.ncl> (COAMPS
>> <http://www.ncl.ucar.edu/Applications/coamps.shtml#ex2>)
>> coamps_3.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/coamps_3.ncl> (COAMPS
>> <http://www.ncl.ucar.edu/Applications/coamps.shtml#ex3>)
>> coamps_5.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/coamps_5.ncl> (COAMPS
>> <http://www.ncl.ucar.edu/Applications/coamps.shtml#ex5>)
>> coamps_6.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/coamps_6.ncl> (COAMPS
>> <http://www.ncl.ucar.edu/Applications/coamps.shtml#ex6>)
>> dataonmap_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/dataonmap_2.ncl> (Plotting
>> data on a map
>> <http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml#ex2>)
>> dataonmap_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/dataonmap_4.ncl> (Plotting
>> data on a map
>> <http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml#ex4>)
>> dataonmap_native_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/dataonmap_native_4.ncl> (Plotting
>> data on a map
>> <http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml#ex4>)
>> dataonmap_nonnative_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/dataonmap_nonnative_4.ncl>
>> (Plotting data on a map
>> <http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml#ex4>)
>> epflux_1.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/epflux_1.ncl> (EPflux
>> <http://www.ncl.ucar.edu/Applications/epflux.shtml#ex1>)
>> epflux_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/epflux_2.ncl> (EPflux
>> <http://www.ncl.ucar.edu/Applications/epflux.shtml#ex2>)
>> era40_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/era40_2.ncl> (ERA40 data
>> <http://www.ncl.ucar.edu/Applications/era40.shtml#ex2>)
>> global_nogaps_vec.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/global_nogaps_vec.ncl>
>> global_nogaps_vec_con.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/global_nogaps_vec_con.ncl>
>> global_nogaps_vec_con_panel.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/global_nogaps_vec_con_panel.ncl>
>> global_nogaps_vec_panel.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/global_nogaps_vec_panel.ncl>
>> godas_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/godas_2.ncl> (GODAS
>> <http://www.ncl.ucar.edu/Applications/godas.shtml#ex2>)
>> godas_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/godas_4.ncl> (GODAS
>> <http://www.ncl.ucar.edu/Applications/godas.shtml#ex4>)
>> hycom_con_vec.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/hycom_con_vec.ncl>
>> ice_2.ncl <http://www.ncl.ucar.edu/Applications/Scripts/ice_2.ncl> (CESM
>> ice model <http://www.ncl.ucar.edu/Applications/ice.shtml#ex2>)
>> lat2pop_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/lat2pop_2.ncl> (lat/lon to
>> POP <http://www.ncl.ucar.edu/Applications/lat2pop.shtml#ex2>)
>> lcmask_3.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/lcmask_3.ncl> (masking
>> lambert conformal <http://www.ncl.ucar.edu/Applications/lcmask.shtml#ex3>
>> )
>> lcnative_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/lcnative_4.ncl> (native
>> lambert conformal
>> <http://www.ncl.ucar.edu/Applications/lcnative.shtml#ex4>)
>> lcnative_5.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/lcnative_5.ncl> (native
>> lambert conformal
>> <http://www.ncl.ucar.edu/Applications/lcnative.shtml#ex5>)
>> lcnative_overlay_5.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/lcnative_overlay_5.ncl>
>> mjoclivar_16.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/mjoclivar_16.ncl> (MJO
>> climate variability
>> <http://www.ncl.ucar.edu/Applications/mjoclivar.shtml#ex16>)
>> newcolor_8.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/newcolor_8.ncl> (new
>> 32-bit color capabilities
>> <http://www.ncl.ucar.edu/Applications/rgbacolor.shtml#ex8>)
>> nldas_01.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/nldas_01.ncl> (NLDAS-GLDAS
>> <http://www.ncl.ucar.edu/Applications/nldas_gldas.shtml#ex01>)
>> nlom_1.ncl <http://www.ncl.ucar.edu/Applications/Scripts/nlom_1.ncl>
>> (NLOM <http://www.ncl.ucar.edu/Applications/nlom.shtml#ex1>)
>> nlom_vec_con.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/nlom_vec_con.ncl>
>> polar_7.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/polar_7.ncl> (polar
>> stereographic projection
>> <http://www.ncl.ucar.edu/Applications/polar.shtml#ex7>)
>> polar_8.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/polar_8.ncl> (polar
>> stereographic projection
>> <http://www.ncl.ucar.edu/Applications/polar.shtml#ex8>)
>> pop2lat_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/pop2lat_2.ncl> (POP to
>> lat/lon <http://www.ncl.ucar.edu/Applications/pop2lat.shtml#ex2>)
>> popscal_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/popscal_4.ncl> (POP scalars
>> <http://www.ncl.ucar.edu/Applications/popscal.shtml#ex4>)
>> popvec_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/popvec_2.ncl> (POP vectors
>> <http://www.ncl.ucar.edu/Applications/popvec.shtml#ex2>)
>> popvec_3.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/popvec_3.ncl> (POP vectors
>> <http://www.ncl.ucar.edu/Applications/popvec.shtml#ex3>)
>> popvec_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/popvec_4.ncl> (POP vectors
>> <http://www.ncl.ucar.edu/Applications/popvec.shtml#ex4>)
>> roms_5.ncl <http://www.ncl.ucar.edu/Applications/Scripts/roms_5.ncl>
>> (ROMS <http://www.ncl.ucar.edu/Applications/roms.shtml#ex5>)
>> veceff_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/veceff_4.ncl> (vector
>> effects <http://www.ncl.ucar.edu/Applications/veceff.shtml#ex4>)
>> vector_3.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/vector_3.ncl> (vector plots
>> <http://www.ncl.ucar.edu/Applications/vector.shtml#ex3>)
>> vector_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/vector_4.ncl> (vector plots
>> <http://www.ncl.ucar.edu/Applications/vector.shtml#ex4>)
>> vector_5.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/vector_5.ncl> (vector plots
>> <http://www.ncl.ucar.edu/Applications/vector.shtml#ex5>)
>> wind_1.ncl <http://www.ncl.ucar.edu/Applications/Scripts/wind_1.ncl>
>> (divergent and rotational wind components
>> <http://www.ncl.ucar.edu/Applications/wind.shtml#ex1>)
>> wind_2.ncl <http://www.ncl.ucar.edu/Applications/Scripts/wind_2.ncl>
>> (divergent and rotational wind components
>> <http://www.ncl.ucar.edu/Applications/wind.shtml#ex2>)
>> wind_3.ncl <http://www.ncl.ucar.edu/Applications/Scripts/wind_3.ncl>
>> (divergent and rotational wind components
>> <http://www.ncl.ucar.edu/Applications/wind.shtml#ex3>)
>> wind_4.ncl <http://www.ncl.ucar.edu/Applications/Scripts/wind_4.ncl>
>> (divergent and rotational wind components
>> <http://www.ncl.ucar.edu/Applications/wind.shtml#ex4>)
>>
>> *vcMinFracLengthF*
>> <http://www.ncl.ucar.edu/Document/Graphics/Resources/vc.shtml#vcMinFracLengthF>
>> newcolor_7.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/newcolor_7.ncl> (new
>> 32-bit color capabilities
>> <http://www.ncl.ucar.edu/Applications/rgbacolor.shtml#ex7>)
>> newcolor_8.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/newcolor_8.ncl> (new
>> 32-bit color capabilities
>> <http://www.ncl.ucar.edu/Applications/rgbacolor.shtml#ex8>)
>> overlay_6.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/overlay_6.ncl> (Overlays
>> <http://www.ncl.ucar.edu/Applications/overlay.shtml#ex6>)
>> unique_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/unique_2.ncl> (unique plots
>> <http://www.ncl.ucar.edu/Applications/unique.shtml#ex2>)
>> unique_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/unique_4.ncl> (unique plots
>> <http://www.ncl.ucar.edu/Applications/unique.shtml#ex4>)
>> veceff_1.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/veceff_1.ncl> (vector
>> effects <http://www.ncl.ucar.edu/Applications/veceff.shtml#ex1>)
>> veceff_2.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/veceff_2.ncl> (vector
>> effects <http://www.ncl.ucar.edu/Applications/veceff.shtml#ex2>)
>> veceff_3.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/veceff_3.ncl> (vector
>> effects <http://www.ncl.ucar.edu/Applications/veceff.shtml#ex3>)
>> veceff_4.ncl
>> <http://www.ncl.ucar.edu/Applications/Scripts/veceff_4.ncl> (vector
>> effects <http://www.ncl.ucar.edu/Applications/veceff.shtml#ex4>)
>>
>>
>>
>>
>> On Wed, Feb 14, 2018 at 12:24 AM, Barry Lynn <barry.h.lynn at gmail.com>
>> wrote:
>>
>>> Here is how you do it.
>>>
>>> vecres = True ; vector only resources
>>>
>>> vecres at gsnDraw = False ; don't draw
>>>
>>> vecres at gsnFrame = False ; don't advance frame
>>>
>>> vecres at vcGlyphStyle = "CurlyVector" ; curly vectors
>>>
>>> vecres at vcRefMagnitudeF = 20 ; define vector ref mag
>>>
>>> vecres at vcRefLengthF = 0.045 ; define length of vec ref
>>>
>>> vecres at gsnRightString = " " ; turn off right string
>>>
>>> vecres at gsnLeftString = " " ; turn off left string
>>>
>>> vecres at tiXAxisString = " " ; turn off axis label
>>>
>>> vecres at vcRefAnnoOrthogonalPosF = -0.17 ; move ref vector into plot
>>>
>>>
>>> vecres at gsnAddCyclic = False ; we will manually zoom
>>> in.
>>>
>>> plotB = gsn_csm_vector(wks,u_new(::4,::4),v_new(::4,::4),vecres)
>>>
>>> Then, you can overlay it onto another plot like temperature.
>>>
>>> panres = True
>>>
>>> panres at gsnMaximize = True
>>>
>>> panres at gsnPanelRight = 0.98
>>>
>>> panres at gsnPanelLeft = 0.02
>>>
>>> panres at gsnPaperOrientation="Portrait"
>>>
>>> overlay(plot,plotB)
>>>
>>> gsn_panel(wks,plot,(/1,1/),panres)
>>>
>>>
>>> On Wed, Feb 14, 2018 at 6:53 AM, Ankita Sharma <ankita at iiserb.ac.in>
>>> wrote:
>>>
>>>> How to use "skip 4" in NCL? or How to skip vectors into grids?
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>>>
>>> --
>>> Barry H. Lynn, Ph.D
>>> Senior Lecturer,
>>> The Institute of the Earth Science,
>>> The Hebrew University of Jerusalem,
>>> Givat Ram, Jerusalem 91904, Israel
>>> Tel: 972 547 231 170
>>> Fax: (972)-25662581
>>>
>>> C.E.O, Weather It Is, LTD
>>> Weather and Climate Focus
>>> http://weather-it-is.com
>>> Jerusalem, Israel
>>> Local: 02 930 9525
>>> Cell: 054 7 231 170
>>> Int-IS: x972 2 930 9525
>>> US 914 432 3108 <(914)%20432-3108>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
> _______________________________________________
> 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/20180221/ff9d60fd/attachment.html>
More information about the ncl-talk
mailing list