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 ;
SDerr = asciiread("SDerr",(/14,3/),"float");
SDtime = asciiread("SDtime",(/dimsizes(SDerr(:,0)),4/),"float");
FDerr = asciiread("FDerr",(/dimsizes(SDerr(:,0)),3/),"float");
FDtime = asciiread("FDtime",(/dimsizes(SDerr(:,0)),4/),"float");
DGerr = asciiread("DGerr",(/dimsizes(SDerr(:,0)),3/),"float");
DGtime = asciiread("DGtime",(/dimsizes(SDerr(:,0)),4/),"float");
;
N = new((/dimsizes(SDerr(:,0))/),"float");
elem = new((/dimsizes(N)/),"float");
rawSDerr = new((/dimsizes(N)/),"float");
rawSDtime = new((/dimsizes(N)/),"float");
rawFDerr = new((/dimsizes(N)/),"float");
rawFDtime = new((/dimsizes(N)/),"float");
rawDGerr = new((/dimsizes(N)/),"float");
rawDGtime = new((/dimsizes(N)/),"float");
SDiter = new((/dimsizes(N)/),"float");
FDiter = new((/dimsizes(N)/),"float");
DGiter = new((/dimsizes(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
>
Received on Thu May 22 2008 - 09:02:18 MDT
This archive was generated by hypermail 2.2.0 : Fri May 23 2008 - 11:28:10 MDT