[ncl-talk] Sub: Plot is empty..
Karin Meier-Fleischer
meier-fleischer at dkrz.de
Tue Jul 14 05:33:31 MDT 2015
Hi Adv,
I'd run the script below with another CMIP5 tas_Amon file I had and I got a
plot with data values (colors). The plot is attached.
It is your script but I cleaned it and made some indents which makes it
more readable.
Try to run it with your data.
;---------------------------------------------------------
begin
f1 =
addfile("$HOME/data/CMIP5/atmos/tas_Amon_MPI-ESM-LR_historical_r3i1p1_185001-200512.nc",
"r") ; note the "s" of addfile
u1 = f1->tas
printVarSummary(u1) ; [time| 720]x[lat|
91]x[lon| 180]
ua1=u1(lat|:,lon|:,time|1332:)
ua11=u1(time|1332:,lat|:,lon|:)
printVarSummary(ua1) ; [time| 720]x[lat|
91]x[lon| 180]
ua11 = ua11-273.15
ua11 at units = "degC"
yyyymm = cd_calendar(ua11&time, -1)
yyyy = yyyymm/100
dimx = dimsizes(ua11)
ntim = dimx(0) ; all years and months
year = ispan(yyyy(0), yyyy(ntim-2), 1)
print(year)
nyrs = dimsizes(year)
print(nyrs)
xann1 = month_to_annual(ua11 , 1) ; [year| 60]x[lat| 91]x[lon| 180]
printVarSummary(xann1)
xann1&year = year
rc1 = regCoef(year,xann1(lat|:,lon|:,year|:))
copy_VarCoords(ua11(0,:,:), rc1)
rc1 = rc1*45
tval1 = onedtond(rc1 at tval , dimsizes(rc1))
printVarSummary(tval1)
df1 = onedtond(rc1 at nptxy, dimsizes(rc1)) - 2
printVarSummary(df1)
b = 0.5
t4 = onedtond(0.5,dimsizes(rc1))
prob1 = (1-betainc(df1/(df1+tval1^2),df1/2.0,t4))
print(prob1)
printVarSummary(prob1)
copy_VarCoords(rc1,prob1)
printVarSummary(prob1)
print(prob1)
print(min(prob1))
print(max(prob1))
printVarSummary(prob1)
;**************************************************
; plot parameters
;**************************************************
wks =
gsn_open_wks("png","NorthernPlains_Significant_AirTemp_1961-2005") ;
Open ps file
gsn_define_colormap(wks,"gui_default") ; assign colormap
plot = new(1,graphic) ; create a plot array
res = True
res at gsnDraw = False ; don't draw
res at gsnFrame = False ; don't advance frame
res at gsnAddCyclic = False
res at gsnTickMarksOn = False
res at lbLabelBarOn = False ; turn off individual cb's
res at txFontHeightF = 0.030 ; adjust font height of
gsnLeftString/gsnRightString titles
res at cnInfoLabelOn = False ; turn off cn info label
res at cnLinesOn = False ; turn off contour lines
res at cnFillOn = True ; color plot desired
res at cnLineLabelsOn = False
res at cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour
levels
; res at cnLevels = (/ 10,20,30,40,50,60,70,80,90,100/)
res at cnLevels = (/
0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1/)
res at vpWidthF = 0.90 ; change aspect ratio of plot
res at vpHeightF = 0.90
res at vpXF = 0.05
res at vpYF = 0.95
res at mpGridAndLimbOn = False
res at mpLimitMode = "LatLon"
res at mpMinLatF = 40.
res at mpMaxLatF = 49.
res at mpMinLonF = 242.
res at mpMaxLonF = 264.
res at mpCenterLonF = 252
res at mpPerimOn = True ; draw box around map
res at mpGeophysicalLineThicknessF = 3.0
res at mpGeophysicalLineColor = "Black"; (/22/)
; res at mpNationalLineThicknessF = 3.0
res at mpOutlineBoundarySets = "GeophysicalAndUSStates" ; add
state boundaries
res at mpNationalLineColor = res at mpGeophysicalLineColor
res at mpUSStateLineThicknessF = 3.0
res at mpUSStateLineColor = res at mpGeophysicalLineColor
plot(0) = gsn_csm_contour_map_ce(wks,prob1,res)
;************************************************
; create panel
;************************************************
resP = True ; modify the panel plot
; resP at gsnFrame = False ; don't advance the
frame, so we can use gsn_text_ndc
resP at gsnPanelLabelBar = True ; add common colorbar
resP at lbLabelFontHeightF = 0.015 ; set font height of
Label Bar labels
resP at gsnPanelBottom = 0.2 ; shrink panel plot
by setting bottom edge of plot
resP at gsnPanelTop = 0.9 ; shrink panel plot
by setting top edge of plot
resP at pmLabelBarWidthF = 0.7 ; make thinner
resP at pmLabelBarHeightF = 0.09
resP at gsnPanelYWhiteSpacePercent = 5. ; increase spacing
along Y-axis between panel plots
resP at txString =
"NorthernPlains_AirTemperature_Significant_1961-2005"
gsn_panel(wks,plot,(/1,1/),resP) ; now draw as one plot
end
;---------------------------------------------------------
Bye, Karin
Am 13.07.15 um 21:33 schrieb Adv:
> Hi,
> Sorry about it. Here is the printVarSummary out.
> Variable: prob1
> Type: float
> Total Size: 221184 bytes
> 55296 values
> Number of Dimensions: 2
> Dimensions and sizes: [lat | 192] x [lon | 288]
> Coordinates:
> lat: [ -90.. 90]
> lon: [ 0..358.75]
> Thanks
> Adv
>
>
>
> On Mon, Jul 13, 2015 at 1:44 PM, Karin Meier-Fleischer
> <meier-fleischer at dkrz.de <mailto:meier-fleischer at dkrz.de>> wrote:
>
> Hi Adv,
>
> please always reply to ncl-talk!
>
> Without any information about your data it is not possible to help.
> Please send the output of the printVarSummary(prob1).
>
> Does your data include the selected region of the map?
>
> Bye,
> Karin
>
> Am 13.07.15 um 17:30 schrieb Adv:
>> Hi,
>> I get a plot not the values. I have attached here the output of
>> this script.
>> I don't understand.
>>
>> Thanks,
>> Adv
>>
>>
>> On Mon, Jul 13, 2015 at 1:53 AM, Karin Meier-Fleischer
>> <meier-fleischer at dkrz.de <mailto:meier-fleischer at dkrz.de>> wrote:
>>
>> Hi Adv,
>>
>> first you have set
>>
>> resP at gsnFrame = False
>>
>> which will let NCL end without drawing a frame! Delete the
>> line and you
>> will get your plot.
>>
>> Bye,
>> Karin
>>
>> Am 13.07.15 um 04:54 schrieb Adv:
>> > Hi ,
>> > Could someone point out the error in this script? It plots
>> no values.
>> > Many times i checked, the values are proper. I think
>> graphical part
>> > has issues.
>> >
>> > ;****************************************************
>> > ;****************************************************
>> > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> > ;***************************************************
>> >
>> > ;***************************************************
>> > begin
>> > ;***************************************************
>> > ;prec*.25x.25cpc1948-present-usa grid
>> > ;others*2.25x2.25cpc1948-present-globalgrid
>> > f1 =
>> addfile("tas_Amon_CCSM4_historical_r3i1p1_185001-200512.nc",
>> > "r") ; note the "s" of addfile
>> > u1 = f1->tas
>> > printVarSummary(u1) ; [time| 720]x[lat|
>> > 91]x[lon| 180]
>> > ;;;;;;1961-2005;;;;;;;;;;;;;;;;;
>> > ua1=u1(lat|:,lon|:,time|1332:)
>> > ua11=u1(time|1332:,lat|:,lon|:)
>> > printVarSummary(ua1) ; [time| 720]x[lat|
>> > 91]x[lon| 180]
>> > ua11 = ua11-273.15
>> > ua11 at units= "degC"
>> > ;return
>> > yyyymm = cd_calendar(ua11&time, -1)
>> > yyyy = yyyymm/100
>> > dimx = dimsizes(ua11)
>> > ntim = dimx(0) ; all years and months
>> >
>> > year = ispan(yyyy(0), yyyy(ntim-2), 1)
>> > print(year)
>> > nyrs = dimsizes(year)
>> > print(nyrs)
>> > ;return
>> > ;delete(u)
>> > xann1 = month_to_annual(ua11 , 1) ; [year|
>> 60]x[lat|
>> > 91]x[lon| 180]
>> > printVarSummary(xann1)
>> > xann1&year = year
>> > rc1 = regCoef(year,xann1(lat|:,lon|:,year|:))
>> > copy_VarCoords(ua11(0,:,:), rc1)
>> > rc1=rc1*45
>> > tval1 = onedtond(rc1 at tval , dimsizes(rc1))
>> > printVarSummary(tval1)
>> > df1 = onedtond(rc1 at nptxy, dimsizes(rc1)) - 2
>> > printVarSummary(df1)
>> > b = 0.5
>> > t4=onedtond(0.5,dimsizes(rc1))
>> > prob1 = (1-betainc(df1/(df1+tval1^2),df1/2.0,t4))
>> > print(prob1)
>> > printVarSummary(prob1)
>> > copy_VarCoords(rc1,prob1)
>> > printVarSummary(prob1)
>> > ;return
>> > print(prob1)
>> > print(min(prob1))
>> > print(max(prob1))
>> > printVarSummary(prob1)
>> > ;**************************************************
>> > ; plot parameters
>> > ;**************************************************
>> >
>> > wks =
>> >
>> gsn_open_wks("x11","NorthernPlains_Significant_AirTemp_1961-2005")
>> ;
>> > Open ps file
>> > gsn_define_colormap(wks,"gui_default") ; assign
>> colormap
>> > plot = new(1,graphic) ; create a plot array
>> >
>> > res = True
>> > res at gsnDraw = False ; don't draw
>> > res at gsnFrame = False ; don't advance frame
>> > res at cnInfoLabelOn = False ; turn off cn info label
>> > res at cnLinesOn = False ; turn off contour
>> lines
>> > res at cnFillOn = True ; color plot desired
>> > res at cnLineLabelsOn = False
>> > res at lbLabelBarOn = False ; turn off
>> individual cb's
>> > res at txFontHeightF = 0.030 ; adjust font height of
>> > gsnLeftString/gsnRightString titles
>> > res at cnLevelSelectionMode = "ExplicitLevels"
>> ; set
>> > explicit contour levels
>> > ; res at cnLevels = (/ 10,20,30,40,50,60,70,80,90,100/)
>> > res at cnLevels = (/
>> 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1/)
>> > res at vpWidthF = 0.90 ; change
>> aspect ratio
>> > of plot
>> > res at vpHeightF = 0.90
>> > res at vpXF = 0.05
>> > res at vpYF = 0.95
>> >
>> > ; map resources for projection
>> > res at mpGridAndLimbOn = False
>> > res at gsnTickMarksOn = False
>> > ;***************************************************
>> > res at mpLimitMode = "LatLon"
>> > res at mpMinLatF = 40.
>> > res at mpMaxLatF = 49.
>> > res at mpMinLonF = 242.
>> > res at mpMaxLonF = 264.
>> > res at mpCenterLonF = 252
>> >
>> > res at mpPerimOn = True ;
>> draw box
>> > around map
>> >
>> > res at mpGeophysicalLineThicknessF = 3.0
>> > res at mpGeophysicalLineColor = "Black"; (/22/)
>> > ;res at mpNationalLineThicknessF = 3.0
>> > res at mpOutlineBoundarySets = "GeophysicalAndUSStates" ; add
>> state
>> > boundaries
>> > res at mpNationalLineColor = res at mpGeophysicalLineColor
>> > res at mpUSStateLineThicknessF = 3.0
>> > res at mpUSStateLineColor = res at mpGeophysicalLineColor
>> >
>> > res at gsnAddCyclic = False
>> > ; to take advantage of NCL's automatic labeling, we need to
>> assign som
>> > attributes:
>> >
>> >
>> > plot(0) = gsn_csm_contour_map_ce(wks,prob1,res)
>> > ;return
>> > ;************************************************
>> > ; create panel
>> > ;************************************************
>> > resP = True ; modify the
>> panel plot
>> > resP at gsnFrame = False ; don't
>> advance the
>> > frame, so we can use gsn_text_ndc
>> > resP at gsnPanelLabelBar = True ; add common
>> colorbar
>> > resP at lbLabelFontHeightF = 0.015 ; set font
>> height of
>> > Label Bar labels
>> > resP at gsnPanelBottom = 0.2 ; shrink panel plot
>> > by setting bottom edge of plot
>> > resP at gsnPanelTop = 0.9 ; shrink panel plot by
>> > setting top edge of plot
>> > resP at pmLabelBarWidthF = 0.7 ; make thinner
>> > resP at pmLabelBarHeightF = 0.09
>> > resP at gsnPanelYWhiteSpacePercent = 5. ; increase
>> spacing
>> > along Y-axis between panel plots
>> > resP at txString =
>> "NorthernPlains_AirTemperature_Significant_1961-2005"
>> > gsn_panel(wks,plot,(/1,1/),resP) ; now draw
>> as one plot
>> >
>> >
>> >
>> > end
>> >
>> > Thank you,
>> > Adv
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>> 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/20150714/53dae07d/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NorthernPlains_Significant_AirTemp_1961-2005.png
Type: image/png
Size: 22214 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150714/53dae07d/attachment.png
More information about the ncl-talk
mailing list