<div dir="ltr">Hi Bedassa,<div><br></div><div>You can't plot something with a 2D coordinate against a 1D coordinate in a 2D plot. The lon2d gives the longitude values for a horizontal 2D field. You have to make some choices to get a vertical plot -- you need to reduce the latitude dimension to a single element somehow. The simplest thing to do would be to just pick one index along the y axis of the lon coordinate -- e.g. lon2d(100,:). However, because the coordinates are 2d, the chances are that this would not be a constant latitude, so you could not say for instance that your plot represents height vs longitude at 10 degrees North latitude.</div><div><br></div><div>But with proper labeling you could describe what this plot does represent. I suggest you look at the NCL Examples page for Pressure/Height vs Longitude plots and specifically at the last example on the page called narr_6.ncl. It shows height plots for data where the coordinates are 2D (aka "curvilinear" coordinates). Notice that the X axis for these plots has both lat/lon values for the tickmark labels.This should give you some ideas of what the issues are and how to solve them. </div><div><br></div><div>Creating a plot where the latitude is constant would require a bit more work. But if you wanted to try you would probably want to use the function</div><div>getind_latlon2d. This might actually be a good topic for a future example.</div><div> -dave</div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 1, 2014 at 4:24 PM, Bedassa Regassa <span dir="ltr"><<a href="mailto:beregassa@gmail.com" target="_blank">beregassa@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">I am new to ncl. I am to plot the vertical Height vs longitude but I got warning and I tried to a lot to find my error.</p>
<p dir="ltr">here is the wraning<br>
<br>
warning:ScalarFieldSetValues: 2d coordinate array sfXArray has an incorrect dimension size: defaulting sfXArray</p>
<p dir="ltr">here is my data information ncl_filedump and below alos my scrip<br></p>
<p dir="ltr">dimensions:<br>
x = 186<br>
y = 166<br>
pressure = 9<br>
time = 1 // unlimited<br>
nb2 = 2<br>
variables:<br>
float lon ( y, x )<br>
standard_name : longitude<br>
long_name : longitude<br>
units : degrees_east<br>
_CoordinateAxisType : Lon</p>
<p dir="ltr"> float lat ( y, x )<br>
standard_name : latitude<br>
long_name : latitude<br>
units : degrees_north<br>
_CoordinateAxisType : Lat</p>
<p dir="ltr"> float pressure ( pressure )<br>
standard_name : air_pressure<br>
long_name : pressure<br>
units : Pa<br>
positive : down<br>
axis : Z</p>
<p dir="ltr"> double time ( time )<br>
standard_name : time<br>
long_name : time<br>
bounds : time_bnds<br>
units : seconds since 2009-05-01 00:00:00<br>
calendar : proleptic_gregorian</p>
<p dir="ltr"> double time_bnds ( time, nb2 )<br>
units : seconds since 2009-05-01 00:00:00<br>
calendar : proleptic_gregorian</p>
<p dir="ltr"> float U ( time, pressure, y, x )<br>
standard_name : grid_eastward_wind<br>
long_name : U-component of wind<br>
units : m s-1<br>
coordinates : lon lat</p>
<p dir="ltr">;************************************************<br>
;load the graphic libraries <br>
;************************************************<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" <br>
;************************************************<br>
begin<br>
;************************************************<br>
;open file and read in data<br>
;************************************************<br>
f=addfile("u_2009_JJAS_mean.nc","r")<br>
;************************************************<br>
; get variables infromation and print them cclm <br>
;************************************************<br>
vars = getfilevarnames(f)<br>
print(vars)<br>
;************************************************<br>
var=f->U(0,:,15,:)        <br>
lon2d=f->lon<br>
lev=f->pressure</p>
<p dir="ltr">var@lon2d=lon2d<br>
var@lev=lev<br>
;*******************************<br>
;create plot<br>
;************************************************</p>
<p dir="ltr">;-- define workstation<br>
wks = gsn_open_wks("png","plot_slices")<br>
gsn_define_colormap(wks,"ncl_default") ;-- set the colormap to be used<br>
;-- set resources<br>
res = True<br>
res@tiMainString = "DKRZ NCL Tutorial Example: Slice plot at 40N"<br>
res@cnFillOn = True ;-- turn on color fill<br>
res@cnLineLabelsOn = False ;-- turns off contour line labels<br>
res@cnInfoLabelOn = False ;-- turns off contour info label<br>
res@lbOrientation = "vertical" ;-- vertical label bar<br>
res@tiYAxisString = var@long_name+" [hPa]"<br>
;-- append units to y-axis label<br>
;res@tfDoNDCOverlay = True<br>
res@sfXArray = lon2d ;-- uses lon_t as plot x-axis<br>
res@sfYArray = lev/100 ;-- uses lev_t in hPa as plot y-axis<br>
res@gsnYAxisIrregular2Linear = True ;-- converts irreg depth to linear<br>
res@trYReverse = True ;-- reverses y-axis</p>
<p dir="ltr">;-- generate the plot<br>
plot = gsn_csm_contour(wks,var,res)<br>
end</p>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>