[ncl-talk] Problems with gsn_csm_xy
Lara Gunn
lara.n.gunn at gmail.com
Thu Aug 27 08:13:57 MDT 2015
Hi
I am running ncl 6.2.1 in cygwin
I am running a plot script which seems to be working but I get this error.
(0) gsn_csm_xy: Fatal: X and Y must have the same dimensions sizes,
or one must be one-dimensional and both have the same rightmost dimension.
However when I print out the two variables I am plotting I get this
Variable: dt
Type: float
Total Size: 12 bytes
3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
Number Of Attributes: 1
_FillValue : 9.96921e+36
(0) 0
(1) 3
(2) 6
Variable: T_dif
Type: float
Total Size: 12 bytes
3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
Number Of Attributes: 1
_FillValue : 9.96921e+36
(0) 0.1149902
(1) -0.3859797
(2) -0.0739994
The line of code is as follows
res3 = res
res3 at tiMainString = ""
res3 at tiXAxisString = "Time Step"
res3 at tiYAxisString = "Temperature Difference
(C)"
res3 at trYMinF = -3
res3 at trYMaxF = 3
res3 at trXMinF = 0
res3 at trXMaxF = 240
res3 at vpXF = 0.1
res3 at gsnYRefLine = 0.0
res3 at gsnAboveYRefLineColor = "red"
res3 at gsnBelowYRefLineColor = "blue"
polyres = True
polyres at gsLineThicknessF = 3.0
if (dimsizes(T).gt.1).and.(dimsizes(T).lt.240) then
plot2 = gsn_csm_xy(wks,dt,T_dif,res3)
gsn_polyline(wks,plot,dt,T_dif,polyres)
psres = True
gsn_panel(wks,(/plot,plot2/),(/1,2/),psres)
end if
Obviously this isn’t the whole piece of code but the other graph in the
image using gsn_csm_x2y2 so that can’t be the cause of the error. There do
seem to be some errors in this because the gsn_polyline is on plot2 not
plot one on the image it creates, but if I put plot there instead it draws
a mysterious line of the first plot. All in all I am quite confused what I
have done.
I have attached the full script just incase that help shed light on my
coding.
Thanks in advance
Lara
load
"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load
"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
grib_in = addfile("$file1","r")
names = getfilevarnames(grib_in)
ncdf_out = addfile("$file2","c")
do i=0,dimsizes(names)-1
ncdf_out->$extra(i)$ = grib_in->$extra(i) $
end do
setfileoption("nc","FileStructure","Advanced")
fn = "$file2"
fi = addfile(fn,"r")
t2m = fi->TMP_P0_L103_GLL0
lat = fi->lat_0
lon = fi->lon_0
T_london=t2m(154,0)
T_birmingham=t2m(150,1432)
T_manchester=t2m(146,1431)
T_glasgow=t2m(137,1421)
T_UK =
(0.44*(T_london)+0.18*T_birmingham+0.27*(T_manchester)+0.11*(T_glasgow))-272.15
asciiwrite ("T_UK_$i",T_UK)
asciiwrite ("dt_$i",$i)
system("cat T_UK_* > T_UK")
system("cat dt_* > datefile")
T_old=asciiread("T_00z",-1,"float")
dt_old=asciiread("DATEFILE_00z",-1,"float")
T=asciiread("T_UK",-1,"float")
dt=asciiread("datefile",-1,"float")
dt2=dt+6
if (dimsizes(T).lt.240) then
T_dif =
T(0:dimsizes(T)-1)-T_old(2:(2+dimsizes(T))-1)
end if
filename="$a"
wks = gsn_open_wks("png",filename)
res = True
res at gsnFrame = False
res at gsnDraw = False
res at tiMainString = "GFS 06z op UK
Temperatures"
res at tiXAxisString = "Time Step"
res at tiYAxisString = "Temperature (C)"
res at trYMinF = min(T_old)-2
res at trYMaxF = max(T_old)+2
res at trXMinF = 0
res at trXMaxF = 390
res at xyLineColor = "black"
res at xyLineThicknessF = 4
res at xyDashPattern = 4
res2 = True
res2 at gsnFrame = False
res2 at gsnDraw = False
res2 at trYMinF = min(T_old)-2
res2 at trYMaxF = max(T_old)+2
res2 at trXMinF = 0
res2 at trXMaxF = 390
res2 at xyLineColor = "red"
res2 at xyLineThicknessF = 4
res2 at xyDashPattern = 0
if (dimsizes(T).gt.1) then
plot =
gsn_csm_x2y2(wks,dt_old,dt2,T_old,T,res,res2)
end if
res3 = res
res3 at tiMainString = ""
res3 at tiXAxisString = "Time Step"
res3 at tiYAxisString = "Temperature Difference
(C)"
res3 at trYMinF = -3
res3 at trYMaxF = 3
res3 at trXMinF = 0
res3 at trXMaxF = 240
res3 at vpXF = 0.1
res3 at gsnYRefLine = 0.0
res3 at gsnAboveYRefLineColor = "red"
res3 at gsnBelowYRefLineColor = "blue"
polyres = True
polyres at gsLineThicknessF = 3.0
if (dimsizes(T).gt.1).and.(dimsizes(T).lt.240) then
plot2 = gsn_csm_xy(wks,dt,T_dif,res3)
gsn_polyline(wks,plot,dt,T_dif,polyres)
psres = True
gsn_panel(wks,(/plot,plot2/),(/1,2/),psres)
end if
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150827/922c6c8b/attachment.html
More information about the ncl-talk
mailing list