Re: Controlling x and y ranges for gsn_contour

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 22 May 2008 09:21:36 -0600

See some of the needed changes below.

Also, pls download/print the pdf at
http://www.ncl.ucar.edu/Document/Manuals/
Ideally, color/duplex but b+w is ok.

Mary has created another vary basic manual that goes over example scripts
line-by-line. Click on

Getting Started Using NCL
<http://www.ncl.ucar.edu/Document/Manuals/Getting_Started/>In
particular, see the Examples

Good Luck
Crowell, Sean M. wrote:
> Here's my ncl code. Can you tell me what I'm doing wrong?
>
> load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl" ;
> ;
> begin
        N = 14
  
> ;
> SDerr = asciiread("SDerr",(/N,3/),"float");
> SDtime = asciiread("SDtime",(/N,4/),"float");
> FDerr = asciiread("FDerr",(/N,3/),"float");
> FDtime = asciiread("FDtime",(/N,4/),"float");
> DGerr = asciiread("DGerr",(/N,3/),"float");
> DGtime = asciiread("DGtime",(/N,4/),"float");
> ;
> ;; N = new((/dimsizes(SDerr(:,0))/),"float"); What r u doing here?
> elem = new(N,"float");
> rawSDerr = new(N,"float");
> rawSDtime = new(N,"float");
> rawFDerr = new(N,"float");
> rawFDtime = new((N,"float");
> rawDGerr = new(N,"float");
> rawDGtime = new((N,"float");
> SDiter = new((N,"float");
> FDiter = new(N,"float");
> DGiter = new(N,"float");
> ;
>

;
> ;?N = FDerr(:,0);
> elem = FDerr(:,1);
> rawSDerr = SDerr(:,2);
> rawSDtime = SDtime(:,2);
> rawFDerr = FDerr(:,2);
> rawFDtime = FDtime(:,2);
> rawDGerr = DGerr(:,2);
> rawDGtime = DGtime(:,2);
> SDiter = SDtime(:,3);
> FDiter = FDtime(:,3);
> DGiter = DGtime(:,3);
> ;
> cmap = (/"(/1.000, 1.000, 1.000/)", \ ;
> "(/0.000, 0.000, 0.000/)", \;
> "(/0.142, 0.000, 0.850/)", \;
> "(/0.097, 0.112, 0.970/)", \;
> "(/0.160, 0.342, 1.000/)", \;
> "(/0.240, 0.531, 1.000/)", \;
> "(/0.340, 0.692, 1.000/)", \;
> "(/0.460, 0.829, 1.000/)", \;
> "(/0.600, 0.920, 1.000/)", \;
> "(/0.740, 0.978, 1.000/)", \ ;
> "(/0.920, 1.000, 1.000/)", \;
> "(/1.000, 1.000, 0.920/)", \;
> "(/1.000, 0.948, 0.740/)", \;
> "(/1.000, 0.840, 0.600/)", \;
> "(/1.000, 0.676, 0.460/)", \;
> "(/1.000, 0.472, 0.340/)", \;
> "(/1.000, 0.240, 0.240/)", \;
> "(/0.970, 0.155, 0.210/)", \;
> "(/0.850, 0.085, 0.187/)", \;
> "(/0.650, 0.000, 0.130/)" /);
> ;
> numxout = dimsizes(N);
> numyout = dimsizes(elem);
> xmin = min(N);
> ymin = min(elem);
> xmax = max(N);
> ymax = max(elem);
> xc = (xmax-xmin)/(numxout-1);
> yc = (ymax-ymin)/(numyout-1);
> x0 = xmin + ispan(0,numxout-1,1)*xc;
> y0 = ymin + ispan(0,numyout-1,1)*xc;
> ;
> z0 = natgrids(N,elem,-rawSDerr,x0,y0);
> wks1 = gsn_open_wks("x11","err_contour");
> wks2 = gsn_open_wks("ps","SDErrorContour");
> gsn_define_colormap(wks1,cmap);
> gsn_define_colormap(wks2,cmap);
> ;
> x0_at_long_name = "Poly Order";
> y0_at_long_name = "Elements";
> z0_at_long_name = "RMS Error";
> ;
> res = True;
> res_at_tiMainFont="Times-Bold";
> res_at_tiMainString = "SD RMS Error vs K and N";
> res_at_tiXAxisString = "Polynomial Order";
> res_at_tiYAxisString = "Elements";
> res_at_sfXArray = x0;
> res_at_sfYArray = y0;
> res_at_cnFillOn = True;
> res_at_lbOrientation = "Vertical";
> res_at_pmLabelBarDisplayMode = "Always";
> res_at_pmLabelBarSide = "Right";
> ;
> z0!0 = "i";
> z0!1 = "j";
> ;
> contour = gsn_contour(wks1,z0(j|:,i|:),res);
> contour2 = gsn_contour(wks2,z0(j|:,i|:),res);
> ;
>
> ________________________________________
> From: Mary Haley [haley_at_ucar.edu]
> Sent: Thursday, May 22, 2008 9:47 AM
> To: Crowell, Sean M.
> Cc: ncl-talk_at_ucar.edu
> Subject: Re: Controlling x and y ranges for gsn_contour
>
> Hi Sean,
>
> If I understand you correctly, I think you need to set:
>
> res_at_sfXArray = x
> res_at_sfYArray = y
>
> This tells NCL what values define your X and Y axes. Otherwise, it
> will just use index values that go from 0 to n-1, where n is the
> number of points in the Z array in the X or Y direction.
>
> Here's a small example using your same X,Y values.
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>
> begin
> wks = gsn_open_wks("x11","test")
>
> x = (/2,4,6,2,4,6/)
> y = (/5,5,5,7,7,7/)
> z = (/1,2,3,2,1,3/)
>
> res = True
> res_at_sfXArray = x
> res_at_sfYArray = y
>
> plot = gsn_contour(wks,z,res)
> end
>
> --Mary
>
> On Thu, 22 May 2008, Crowell, Sean M. wrote:
>
>
>> I'm using gsn_contour to make contour plots, and the file is reading in my x and y arrays properly (checked using print) and interpolating properly using natgrids, but when I make the contour plots, it only plots the x and y values up to the smallest dimension (length of x or y) and leaves out the rest of the array with more distinct values.
>>
>> To clear it up a bit:
>>
>> I've got a data file that looks like
>> 2 5 z
>> 4 5 z
>> 6 5 z
>> 2 7 z
>> 4 7 z
>> 6 7 z
>>
>> And when it does the contour plot, the x's only range up to 4, which I'm assuming is some default option to make the plot square. How do I control this?
>>
>> Sean Crowell
>>
>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 22 2008 - 09:21:36 MDT

This archive was generated by hypermail 2.2.0 : Fri May 23 2008 - 11:28:10 MDT