[ncl-talk] scatter plots

Dennis Shea shea at ucar.edu
Fri Sep 12 09:06:39 MDT 2014


[1] The script you sent should *not* work at all. It looks like you caut
and pasted from several different
     example scripts and expected it to work.

[2] If it did work, you would not have "annual means". .... yould would
have "anomalies"
           x_ave = rmMonAnnCycTLL(x)
           would not create an "ave" (average). It creates "anomalies" from
an average

[3] The following would also fail
           data1(1,:) = rc*(x-rc at xave) + rc at yave

You sent
==
x_ave = rmMonAnnCycTLL(x)
y        = rmMonAnnCycTLL(y)

Then you use 'y_ave' which you have not created.

x_ave_new = dim_avg_n(x_ave,(/1,2/))
y_ave_new = dim_avg_n(y_ave,(/1,2/))   ; <== you have not computed y_ave

The script should fail here.
==

Assuming,

    y = rmMonAnnCycTLL(y)

should be

   y_ave = rmMonAnnCycTLL(y)

==
Now you use

x_ave_new = dim_avg_n(x_ave,(/1,2/))   ; ===>    x_ave_new(ntim)
y_ave_new = dim_avg_n(y_ave,(/1,2/))   ; ===>    y_ave_new(ntim)

rc = regline(x_ave_new,y_ave_new)
print(rc)

x = x_ave_new                ; <*******   this should fail here
y = y_ave_new
data1 = new((/2,dimsizes(y)/), typeof(y))

By default, NCL does not allow a one-dimensional array [ x_ave_new,
y_ave_new ]
to overwrite a three-dimensional array [ x(ntim,nlat,mlon),
y(ntim,nlat,mlon) ]
unless special NCL syntax := is used. This syntax is available from 6.1.1
onward.

Please clean up your script and send something that 'kinda' works.


On Fri, Sep 12, 2014 at 6:07 AM, Lena Frey <Frey_L at web.de> wrote:

> Hi all!
>
> I am trying to make as scatter plot. I have monthly data, the dimensions
> of the variables x and y are time,lat,lon.
> I would like to have scatter plots for different regions and to have
> monthly data de-seasonalized.
> The script is working, but it seems like I have annual means.
> Here is my script:
>
>  in_x = addfile("~/DATA/x.nc","r")
> x = in_x->x(:,{-10:-20},{180:190})
> in_y = addfile("~/DATA/y.nc","r")
> y = in_y->y(:,{-10:-20},{180:190})
>
> ;*********************************************************************************
>
> ; remove annual cycle
>
> ;*********************************************************************************
> x_ave = rmMonAnnCycTLL(x)
> y = rmMonAnnCycTLL(y)
>
>
> ;********************************************************************************
> ; calculate average LON LAT
>
> ;********************************************************************************
> x_ave_new = dim_avg_n(x_ave,(/1,2/))
> y_ave_new = dim_avg_n(y_ave,(/1,2/))
>
>
> ;********************************************************************************
> ; regression line
>
> ;********************************************************************************
> rc = regline(x_ave_new,y_ave_new)
> print(rc)
>
>
> ;********************************************************************************
> ; create array
>
> ;********************************************************************************
> x = x_ave_new
> y = y_ave_new
> data1 = new((/2,dimsizes(y)/), typeof(y))
>
> data1(0,:) = y
> data1(1,:) = rc*(x-rc at xave) + rc at yave
>
>
>
>
> ;*********************************************************************************
> ; plotting parameters
>
> ;*********************************************************************************
> wks = gsn_open_wks("pdf","scatter")
> res                 = True
> ;res at gsnMinimize            = True
> ...
>
> plot = gsn_csm_xy (wks,x,data1,res)
>
> end
> ;********************************************************************
>
>
> Thanks.
> Best regards,
> Lena
>
> _______________________________________________
> ncl-talk mailing list
> 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/20140912/c506784e/attachment.html 


More information about the ncl-talk mailing list