Re: gsn_csm_contour_map_ce help

From: Erik Noble <enoble_at_nyahnyahspammersnyahnyah>
Date: Tue, 26 May 2009 00:37:48 -0400

Hi Thank you for pointing this example out. This still did not help. I
included the res_at_vpXF & res_at_vpYF; they separated the images but the top
right image is still too large compared to the rest. (It actually as the
exact same dimensions in the x-axis as the 1st image. also, the axes of the
bottom two images are twice the size of the top left image but NCL plots
them exactly the same).
Is there any other way make them all the same size in the figure?
-erik

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
setfileoption("bin","ReadByteOrder","BigEndian")
nlat = 400;default latitudes in file 0.25 by 0.25 degree
nlon = 1440 ;default longitutdes in file 0.25 by 0.25 degree
fils = systemfunc("ls *precipitation.bin")
nfils = dimsizes(fils)
prate = new((/nfils,nlat,nlon/),"float") ; New array for rain rate

p = new((/nfils,nlat,nlon/),"float") ; New array for rain
do gg = 0,dimsizes(fils)-1 ; Do loop to extract variable form
binary files
prate(gg,:,:) = fbindirread(fils(gg),0,(/nlat,nlon/),"float")
p(gg,:,:) = prate(gg,:,:) * 3 ; rain per three hours (mm)
end do

rain = where(p.lt.0.01 , 0.0, p) ; keep precipitation values above
zero
printMinMax(rain, True)

rain!0="Time"

;;;;;;;;;;;;;;;;;;;;Coordinates........What is neccessary to plot a map
plot?????
rain!1="Lat"
Lat = ispan(0,nlat-1,1)*0.25 - 49.875 ; From TRMM README file
Lat_at_units = "degrees_north"
rain_at_Lat =Lat

rain!2="Lon"
Lon = ispan(0,nlon-1,1)*0.25 - 179.875 ; From TRMM README file
Lon_at_units = "degrees_east"
rain_at_Lon =Lon

lat2d = rain(0,:,:)
lon2d = rain(0,:,:)
lat2d_at_units = "degrees_north"
lon2d_at_units = "degrees_east"

printVarSummary(rain)

;;;;For regridding function;;;;
ylat = Lat
xlon = Lon
ylat!0 = "Lat"
xlon!0 = "Lon"
lat2d = new((/400,1440/),float)
lon2d = new((/400,1440/),float)
lat2d!0 = "Lat"
lat2d!1 = "Lon"
lon2d!0 = "Lat"
lon2d!1 = "Lon"
lat2d_at_units = "degrees_north"
lon2d_at_units = "degrees_east"
; Just copy the 2d grid coordinates to match the rain array and keep number
of elements consistent.
do i=0,399
lon2d(i,:) = xlon(:)
 end do
do i=0,1439
lat2d(:,i) = ylat(:)
end do
;;; Now, we want to regrid the TRMM data to a 0.5 by 0.5 grid. This means
that it we have to divide by half.
NLAT = 200
NLAT = 200; 400/2
MLON = 720
MLON = 720; 1440/2
lat = ispan(0,NLAT-1,1)*0.50 - 49.875
lon = ispan(0,MLON-1,1)*0.50 - 179.875
lat!0 = "lat"
lat_at_units = "degrees_north"
lat&lat = lat
lon!0 = "lon"
lon_at_units = "degrees_east"
lon&lon = lon
rNEW = new ((/dimsizes(fils),NLAT,MLON/),typeof(rain),getFillValue(rain))
 ;New rain array
rNEW!0 = "Time"
rNEW&Time = ispan(1,dimsizes(fils),1)
rNEW!1 = "lat"
rNEW&lat = lat
rNEW!2 = "lon"
rNEW&lon = lon
;;;;;;;;;;;;;;TRIPLE2GRID;;;;;;;;;;;;;;;
do ii = 0,dimsizes(fils)-1
rNEW(ii,:,:) = triple2grid(ndtooned(lon2d), ndtooned(lat2d), ndtooned(
rain(ii,:,:)),lon,lat,False)
end do
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rm= systemfunc("rm TRMM_SOP3_0.50x0.50_res.nc") ;remove the file we are
about to create
a = addfile("TRMM_SOP3_0.50x0.50_res.nc","c")
a_at_title = "1 month of daily accumulated precipitation"
filedimdef(a,"time",-1,True) ; make time an UNLIMITED dimension, always
recommended
a->precipitation=rNEW

printVarSummary(rNEW)
printMinMax(rNEW,True)
total_rain = dim_sum_Wrap(rNEW(lat|:, lon|:, Time|:) )
printMinMax(total_rain,True)

; The next set of commands set up plot properties
wks = gsn_open_wks("ps","Test_TRMM")
colors = (/"white","black" \ ; {for/back}ground
            ,"white","azure" \
             ,"green","palegreen","yellowgreen", "greenyellow" \
             ,"yellow","goldenrod","orange","orangered" \
              ,"red","deeppinK","violet","darkviolet","blueviolet","blue"/)

gsn_define_colormap(wks, colors)
res = True ; plot mods desired
;res_at_gsnDebugWriteFileName = True
;res_at_gsnMaximize = True ; uncomment to maximize size
res_at_gsnSpreadColors = True ; use full range of colormap
res_at_cnFillOn = True ;False ; color plot desired
res_at_cnLinesOn = False ; turn off contour lines
res_at_cnLineLabelsOn = False ; turn off contour labels

res_at_cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal] cn levels
res_at_cnLevels =
(/0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800/)
res_at_cnFillMode = "AreaFill" ;"RasterFill"
res_at_lbOrientation = "Vertical" ; default is horizontal
;res_at_gsnZonalMean = True
; Plot the plots
;x = gsn_csm_contour_map_ce(wks,total_rain,res)
;total_TRMM_R1=total_rain({5.0:11.5},{-30.875:-20.875})
total_TRMM=total_rain({-20:25},{-35:35})
total_TRMM_R1=total_rain({5:11},{-30:-20})
total_TRMM_R2=total_rain({7:18},{-20:-10})
total_TRMM_R3=total_rain({7:18},{-10:10})
total_TRMM_R4=total_rain({7:18},{10:30})
printVarSummary(total_TRMM_R1)
printVarSummary(total_TRMM_R2)
printVarSummary(total_TRMM_R3)
printVarSummary(total_TRMM_R4)
res_at_gsnAddCyclic = False
res_at_gsnFrame = False ; don't advance frame
res_at_gsnDraw = False ; don't draw plots
; res_at_lbLabelBarOn = False
;Plot Region 1, from rn_R1(it,:,:)=rainw(8,55:67,10:30)-rainw(0,55:67,10:30)
res_at_mpMinLatF = -20. ; range to zoom in on
res_at_mpMaxLatF = 25.
res_at_mpMinLonF = -35.
res_at_mpMaxLonF = 35.
res_at_gsnLeftString = "West African Region"
;x1a = gsn_csm_contour_map_ce(wks,total_TRMM,res)
;;;;;;;;;;May 20, 2009, Aftr hint form Dr. Shea and NCL-talk, Hopefuly it
works!;;;;;
res_at_mpMinLatF = 5. ; range to zoom in on
res_at_mpMaxLatF = 11.
res_at_mpMinLonF = -30.
res_at_mpMaxLonF = -20.
res_at_gsnLeftString = "Region 1: Atlantic ITCZ"
res_at_gsnRightString = "mm"
res_at_vpXF = 0.05 ; position and sizes
res_at_vpYF = 0.94 ; for XY plot
res_at_vpWidthF = 0.40
res_at_vpHeightF = 0.40
x1 = gsn_csm_contour_map_ce(wks,total_TRMM_R1,res)
res_at_mpMinLatF = 7. ; range to zoom in on
res_at_mpMaxLatF = 18.
res_at_mpMinLonF = -20.
res_at_mpMaxLonF = -10.
res_at_gsnLeftString = "Region 2: Western Sahel"
res_at_vpXF = 0.53
x2 = gsn_csm_contour_map_ce(wks,total_TRMM_R2,res)
res_at_mpMinLatF = 7. ; range to zoom in on
res_at_mpMaxLatF = 18.
res_at_mpMinLonF = -10.
res_at_mpMaxLonF = 10.
res_at_gsnLeftString = "Region 3: Central Sahel"
res_at_vpXF = 0.05 ; position and sizes
res_at_vpYF = 0.54 ; for XY plot
res_at_vpWidthF = 0.40
res_at_vpHeightF = 0.40

x3 = gsn_csm_contour_map_ce(wks,total_TRMM_R3,res)
res_at_mpMinLatF = 7. ; range to zoom in on
res_at_mpMaxLatF = 18.
res_at_mpMinLonF = 10.
res_at_mpMaxLonF = 30.
res_at_gsnLeftString = "Region 4: Eastern Sahel"
res_at_vpXF = 0.53 ; position and sizes
x4 = gsn_csm_contour_map_ce(wks,total_TRMM_R4,res)
;
; Maximize plots in frame.
;
 psres = True
 maximize_output(wks,psres) ; calls draw and frame for you

;****************************************************************************
; create panel of different components
;****************************************************************************
  plts = new (4 , "graphic") ; 1d array to hold plots

  res_at_gsnDraw = False ; (a) do not draw
  res_at_gsnFrame = False ; (b) do not advance 'frame'
  res_at_lbLabelBarOn = False ; (c) turn off individual
lb's

;************************************************
; create panel: panel plots have their own set of resources
;************************************************
  resP = True ; modify the panel plot
; resP_at_gsnDebugWriteFileName = True
; resP_at_gsnMaximize = True ; maximize panel area
  resP_at_gsnPanelRowSpec = True ; specify 1 top, 2 lower
level
  resP_at_gsnPanelLabelBar = True ; add common colorbar
  resP_at_pmLabelBarWidthF = 0.85 ; make label wider
  resP_at_lbLabelFontHeightF = 0.015 ; default 0.02 [demo make
smaller]

res_at_mpMinLatF = 5. ; range to zoom in on
res_at_mpMaxLatF = 11.
res_at_mpMinLonF = -30.
res_at_mpMaxLonF = -20.
res_at_gsnLeftString = "Region 1: Atlantic ITCZ"
plts(0) = gsn_csm_contour_map_ce(wks,total_TRMM_R1,res)
res_at_mpMinLatF = 7. ; range to zoom in on
res_at_mpMaxLatF = 18.
res_at_mpMinLonF = -20.
res_at_mpMaxLonF = -10.
res_at_gsnLeftString = "Region 2: Western Sahel"
plts(1) = gsn_csm_contour_map_ce(wks,total_TRMM_R2,res)
res_at_mpMinLatF = 7. ; range to zoom in on
res_at_mpMaxLatF = 18.
res_at_mpMinLonF = -10.
res_at_mpMaxLonF = 10.
res_at_gsnLeftString = "Region 3: Central Sahel"
plts(2) = gsn_csm_contour_map_ce(wks,total_TRMM_R3,res)
res_at_mpMinLatF = 7. ; range to zoom in on
res_at_mpMaxLatF = 18.
res_at_mpMinLonF = 10.
res_at_mpMaxLonF = 30.
res_at_gsnLeftString = "Region 4: Eastern Sahel"
plts(3) = gsn_csm_contour_map_ce(wks,total_TRMM_R4,res)
resP_at_txString = "Total Precipitation, TRMM (September 2006)"
gsn_panel(wks,plts,(/2,2/),resP) ; now draw as one plot

On Fri, May 22, 2009 at 11:10 AM, Dennis Shea <shea_at_ucar.edu> wrote:

> As noted in the documentation
>
> gsn_panel: "Draws multiple plots of identical size on a single frame."
> http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_panel.shtml
>
> Your 4 plots are not "identical size".
>
> The panel Application page
> http://www.ncl.ucar.edu/Applications/panel.shtml
>
> has two examples (9 and 20) for drawing 'panels' of different sizes.
>
>
>
>
> Erik Noble wrote:
> > Thank you. That tip worked with zooming/plotting subregions.
> >
> > I'm getting strange plot I panel-plot the subregions with
> > gsn_csm_contour_map_ce command. Specifically the second image overruns
> > the 4th image (please see attached). The commands for plotting each
> > image in the panel plot are treated the same at the end of the script.
> > Is this because I am using gsn_csm_contour_map_ce?
> > Should I use a different command?
> >
> > I tried using the *gsnDebugWriteFileName command***, as NCL web site
> > requests,*** to find the bug while this 2nd image on the panel plot. The
> > files named "True" were created. I don't see it.** any
> > suggestions*.**********
> >
> > Sincerely,
> > -Erik
> >
> > Script (a little long....but panel commands are at end)
> >
> >
> >
> >
> >
> > On Wed, May 20, 2009 at 3:26 AM, Dennis Shea <shea_at_ucar.edu
> > <mailto:shea_at_ucar.edu>> wrote:
> >
> > See Example 3 at
> > http://www.ncl.ucar.edu/Applications/cylineq.shtml
> >
> > Erik Noble wrote:
> > > Dear NCL,
> > > Could I have some help with using the gsn_csm_contour_map_ce
> > command? I
> > > plotted precipitation data from TRMM using the
> > gsn_csm_contour_map_ce.
> > > It worked for plotting a global plot.(1st image). I tried to plot
> a
> > > sub-region of the data using the gsnAddCyclic = False
> > > AND
> > > mpCorner commands. A plot was plottted but the image is so small
> > > compared to the rest of the map. (2nd image). How can I just plot
> the
> > > subregion by itself?
> > > Thank you.
> > > Sincerely,
> > > erik
> > >
> > > Terminal history:
> > >
> > > noble:TRMM3B42 enoble$ ncl extract_TRMM_regrid_plot-SOP3.ncl
> > > Copyright (C) 1995-2009 - All Rights Reserved
> > > University Corporation for Atmospheric Research
> > > NCAR Command Language Version 5.1.0
> > > The use of this software is governed by a License Agreement.
> > > See http://www.ncl.ucar.edu/ for more details.
> > > (0)
> > > (0) min=0 max=245.562
> > >
> > >
> > > Variable: rain
> > > Type: float
> > > Total Size: 552960000 bytes
> > > 138240000 values
> > > Number of Dimensions: 3
> > > Dimensions and sizes: [Time | 240] x [Lat | 400] x [Lon | 1440]
> > > Coordinates:
> > > Number Of Attributes: 3
> > > Lon : <ARRAY of 1440 elements>
> > > Lat : <ARRAY of 400 elements>
> > > _FillValue : -999
> > >
> > >
> > > Variable: rNEW
> > > Type: float
> > > Total Size: 138240000 bytes
> > > 34560000 values
> > > Number of Dimensions: 3
> > > Dimensions and sizes: [Time | 240] x [lat | 200] x [lon | 720]
> > > Coordinates:
> > > Time: [1..240]
> > > lat: [-49.875..49.625]
> > > lon: [-179.875..179.625]
> > > Number Of Attributes: 1
> > > _FillValue : -999
> > > (0)
> > > (0) min=0 max=224.236
> > > (0)
> > > (0) min=0 max=1090.89
> > > noble:TRMM3B42 enoble$
> > >
> > >
> > >
> > > SCRIPT: Plotting parts are near the end....
> > >
> > > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> > > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> > > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> > > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> > > load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> > > setfileoption("bin","ReadByteOrder","BigEndian")
> > > nlat = 400;default latitudes in file 0.25 by 0.25 degree
> > > nlon = 1440 ;default longitutdes in file 0.25 by 0.25 degree
> > > fils = systemfunc("ls *precipitation.bin")
> > > nfils = dimsizes(fils)
> > > prate = new((/nfils,nlat,nlon/),"float") ; New array for
> > rain rate
> > >
> > > p = new((/nfils,nlat,nlon/),"float") ; New array for
> rain
> > > do gg = 0,dimsizes(fils)-1 ; Do loop to extract
> > variable form
> > > binary files
> > > prate(gg,:,:) = fbindirread(fils(gg),0,(/nlat,nlon/),"float")
> > > p(gg,:,:) = prate(gg,:,:) * 3 ; rain per three hours (mm)
> > > end do
> > >
> > > rain = where(p.lt.0.01 , 0.0, p) ; keep precipitation
> > values above
> > > zero
> > > printMinMax(rain, True)
> > >
> > > rain!0="Time"
> > >
> > > ;;;;;;;;;;;;;;;;;;;;Coordinates........What is neccessary to plot
> > a map
> > > plot?????
> > > rain!1="Lat"
> > > Lat = ispan(0,nlat-1,1)*0.25 - 49.875 ; From TRMM
> > README file
> > > Lat_at_units = "degrees_north"
> > > rain_at_Lat =Lat
> > >
> > > rain!2="Lon"
> > > Lon = ispan(0,nlon-1,1)*0.25 - 179.875 ; >From TRMM README
> > file
> > > Lon_at_units = "degrees_east"
> > > rain_at_Lon =Lon
> > >
> > > lat2d = rain(0,:,:)
> > > lon2d = rain(0,:,:)
> > > lat2d_at_units = "degrees_north"
> > > lon2d_at_units = "degrees_east"
> > >
> > > printVarSummary(rain)
> > >
> > > ;;;;For regridding function;;;;
> > > ylat = Lat
> > > xlon = Lon
> > > ylat!0 = "Lat"
> > > xlon!0 = "Lon"
> > > lat2d = new((/400,1440/),float)
> > > lon2d = new((/400,1440/),float)
> > > lat2d!0 = "Lat"
> > > lat2d!1 = "Lon"
> > > lon2d!0 = "Lat"
> > > lon2d!1 = "Lon"
> > > lat2d_at_units = "degrees_north"
> > > lon2d_at_units = "degrees_east"
> > > ; Just copy the 2d grid coordinates to match the rain array and
> keep
> > > number of elements consistent.
> > > do i=0,399
> > > lon2d(i,:) = xlon(:)
> > > end do
> > > do i=0,1439
> > > lat2d(:,i) = ylat(:)
> > > end do
> > > ;;; Now, we want to regrid the TRMM data to a 0.5 by 0.5 grid.
> This
> > > means that it we have to divide by half.
> > > NLAT = 200
> > > NLAT = 200; 400/2
> > > MLON = 720
> > > MLON = 720; 1440/2
> > > lat = ispan(0,NLAT-1,1)*0.50 - 49.875
> > > lon = ispan(0,MLON-1,1)*0.50 - 179.875
> > > lat!0 = "lat"
> > > lat_at_units = "degrees_north"
> > > lat&lat = lat
> > > lon!0 = "lon"
> > > lon_at_units = "degrees_east"
> > > lon&lon = lon
> > > rNEW = new
> > > ((/dimsizes(fils),NLAT,MLON/),typeof(rain),getFillValue(rain))
> ;New
> > > rain array
> > > rNEW!0 = "Time"
> > > rNEW&Time = ispan(1,dimsizes(fils),1)
> > > rNEW!1 = "lat"
> > > rNEW&lat = lat
> > > rNEW!2 = "lon"
> > > rNEW&lon = lon
> > > ;;;;;;;;;;;;;;TRIPLE2GRID;;;;;;;;;;;;;;;
> > > do ii = 0,dimsizes(fils)-1
> > > rNEW(ii,:,:) = triple2grid(ndtooned(lon2d), ndtooned(lat2d),
> > > ndtooned( rain(ii,:,:)),lon,lat,False)
> > > end do
> > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > printVarSummary(rNEW)
> > > printMinMax(rNEW,True)
> > > total_rain = dim_sum_Wrap(rNEW(lat|:, lon|:, Time|:) )
> > > printMinMax(total_rain,True)
> > >
> > > ; The next set of commands set up plot properties
> > > wks = gsn_open_wks("ps","Test_TRMM")
> > > colors = (/"white","black" \ ; {for/back}ground
> > > ,"white","azure" \
> > > ,"green","palegreen","yellowgreen", "greenyellow" \
> > > ,"yellow","goldenrod","orange","orangered" \
> > >
> > > ,"red","deeppinK","violet","darkviolet","blueviolet","blue"/)
> > >
> > > gsn_define_colormap(wks, colors)
> > > res = True ; plot mods desired
> > > ; res_at_gsnMaximize = True ; uncomment to
> > maximize size
> > > res_at_gsnSpreadColors = True ; use full range of
> > colormap
> > > res_at_cnFillOn = True ;False ; color plot
> > desired
> > > res_at_cnLinesOn = False ; turn off contour
> lines
> > > res_at_cnLineLabelsOn = False ; turn off contour
> > labels
> > >
> > > res_at_cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal]
> > cn levels
> > > res_at_cnLevels =
> > >
> (/0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800/)
> > > res_at_cnFillMode = "AreaFill" ;"RasterFill"
> > > res_at_lbOrientation = "Vertical" ; default is
> horizontal
> > >
> > > ; Plot the plots
> > > x = gsn_csm_contour_map_ce(wks,total_rain,res)
> > > total_TRMM_R1=total_rain({5.0:11.5},{-30.875:-20.875})
> > >
> > > res_at_gsnAddCyclic = False
> > > ;Plot Region 1, from
> > rn_R1(it,:,:)=rainw(8,55:67,10:30)-rainw(0,55:67,10:30)
> > > res_at_mpLeftCornerLatF = lat2d(55,10)
> > > res_at_mpLeftCornerLonF = lon2d(55,10)
> > > res_at_mpRightCornerLatF = lat2d(67,30)
> > > res_at_mpRightCornerLonF = lon2d(67,30)
> > > res_at_gsnLeftString = "Region 1: Atlantic ITCZ"
> > > x2 = gsn_csm_contour_map_ce(wks,total_TRMM_R1,res)
> > >
> > >
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > ncl-talk mailing list
> > > List instructions, subscriber options, unsubscribe:
> > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Test_TRMM.jpg
Received on Mon May 25 2009 - 22:37:48 MDT

This archive was generated by hypermail 2.2.0 : Tue May 26 2009 - 10:17:16 MDT