[ncl-talk] didn't show all markers

Mary Haley haley at ucar.edu
Fri Nov 10 10:33:22 MST 2017


Zhen,

Which markers in particular are not showing up? It's too hard for us to
look at your output and try to figure out which dots are on the plot and
which are not.

Also, it's very unlikely that NCL would just drop some of those dots.
There has to be something else going on, like the dots are out-of-range of
the limits of your X and/or Y axes.

[1] Clean coding tip: you do not need to loop across each index of the
array to add each dot, if you are drawing them all with the same color and
size. Instead of this code:

dot=new((/dimsizes(forc),dimsizes(lat)*dimsizes(plev)/),graphic)
do iex=0,dimsizes(forc)-1
 . . .
  do ip=0,npts-1
    dot(iex,ip) =
gsn_add_polymarker(wks,plot(iex),lat(indices(ip,1)),plev(indices(ip,0)),resmarker)
  end do

you can have this code:

dot=new((/dimsizes(forc),dimsizes(lat)/),graphic)
do iex=0,dimsizes(forc)-1
 . . .
  dot(iex) =
gsn_add_polymarker(wks,plot(iex),lat(indices(:,1)),plev(indices(:,0)),resmarker)

This will run faster, because each call to gsn_add_polymarker causes the
creation of an internal object, and if you do this for each single dot, you
are going to end up using more memory and taking more time.

[2] Clean coding tip: if you find yourself calling "dimsizes" on the same
variable multiple times, I suggest saving it to a variable so it can save
you some typing:

For example:

var_run = new((/dimsizes(forc),dimsizes(ens),dimsizes(year),23,90/),"float")
var_djf_clim =  new((/dimsizes(forc),dimsizes(ens),23,90/),"float") ; 10
years
rc_m = new((/dimsizes(forc),23,90/),"float")
do iv=0,dimsizes(vars)-1

could be changed to:

nforc = dimsizes(forc)
nens  = dimsizes(ens)
nyear = dimsizes(year)
nvars = dimsizes(vars)

var_run = new((/nforc,nens,nyear),23,90/),"float")
var_djf_clim =  new((/nforc,nens),23,90/),"float") ; 10 years

rc_m = new((/nforc,23,90/),"float")
do iv=0,nvars-1

I don't know what "23" and "90" are supposed to represent, but it would be
good to also assign these to variables as well, so if you need to change
the 23 or 90 values later, you can just do it in one place.

[3] Clean coding tip: you don't need to use "new" to preallocate an array
that is getting calculated by a function.  You have this code:

rc_m = new((/dimsizes(forc),23,90/),"float")
rc_m = regCoef_n(year,var_ens,0,1)

Remove the "new" line as it is not needed.  The regCoef_n function will
allocate the memory for you, as does every single NCL function.

If you continue to have problems with the dots, please be more specific
about which dots are not showing up.

--Mary






On Thu, Nov 9, 2017 at 2:56 PM, 刘振 <286909655 at qq.com> wrote:

> Dear all,
>
>   I am using ncl 6.4 to plot and want to print dot when value pass student
> t test using function gsn_add_polymaker (script and figure attached, i.e.
> 850hPa). But the dots are only printed at some levels (not all levels) in
> vertical direction. Actually, I got 23 pressure levels for my data and
> indeed some dot are not printed on the plot when I print the indices
> passing significance level (see log files attached). Could you please help
> me to solve this problem. Thanks.
>
> zhen
>
> ------------------
> 刘振
> 中山大学
> 环境科学与工程学院
> 大气科学系
> Phone: +86-15013246049 <+86%20150%201324%206049>
> Liu  Zhen
> Department of Atmospheric Science
> School of Environmental Science and Engineering
> Sun Yat-sen University
> Email address: liuzhen9 at mail2.sysu.edu.cn
>
>
> _______________________________________________
> 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/20171110/511d6aa2/attachment-0001.html>


More information about the ncl-talk mailing list