Re: overlaying gridded data

From: Kara Yedinak <kyedinak_at_nyahnyahspammersnyahnyah>
Date: Thu May 24 2012 - 18:30:34 MDT

Hi Dave,

  I have attached a pdf of a single plot as an example of what is going
wrong.

Thanks,
Kara

On Thu, May 24, 2012 at 5:10 PM, David Brown <dbrown@ucar.edu> wrote:

> Hi Kara,
> It would really help to see the plot, so we could see how the 2nd variable
> fails to align with the 1st. Actually if each of the graphics in the panel
> have the same misalignment, then it would be more useful to send the first
> plot drawn to fill the whole frame. Thanks.
> -dave
>
> On May 24, 2012, at 5:13 PM, Kara Yedinak wrote:
>
> Hello NCL users,
>
> I am working on building an overlay plot of two gridded variables (no
> lat and lon coordinates). The first variable (u-component wind) is on a
> grid that is 200(j) x 320(i) cells. My second variable is on a grid that
> is 2000(j) x 3200(i) cells. Both variables represent the output for a
> model domain that is 5km x 8km in size. Because the i and j indices for
> these two variables don't match, I am not getting an accurate overlay of
> variable 2 onto variable 1. I think I may need to use the Transform
> resources to force one of these variables to be the same size as the other,
> but I am not completely sure of this and could use both some advice, and
> possibly an example to look at. Here is my NCL code so far (there is
> currently no transformation present):
>
> ;================================================;
> 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/wrf/WRFUserARW.ncl"
> ;================================================;
>
> begin
>
> ;=================================================;
> ; open file and read in data
> ;=================================================;
>
> K = 1
> Plot = "x11"
> T1 = 15
> T2 = 18
> T3 = 25
> T4 = 35
> Title = "Fire Area"
> File = "base_unstable_60A"
> FileT= "Fire_Area_"+File
>
> f =
> addfile("/mnt/pvfs2/karay/Rath_SA/StabilitySound_xy4/"+File+"/wrfout_d01_2006-02-23_12:00:
> 00.nc","r")
>
> Fa1 = f->FIRE_AREA(T1,:,:) ; fraction of cell area on fire
> Fa2 = f->FIRE_AREA(T2,:,:)
> Fa3 = f->FIRE_AREA(T3,:,:)
> Fa4 = f->FIRE_AREA(T4,:,:)
>
> ua = wrf_user_getvar(f,"ua",-1) ; umet and vmet averaged to mass
> points
> U1 = ua(T1,K,:,:)
> U2 = ua(T2,K,:,:)
> U3 = ua(T3,K,:,:)
> U4 = ua(T4,K,:,:)
>
> ;=================================================;
> ;plotting resources set
> ;=================================================;
>
> wks = gsn_open_wks(Plot,FileT)
> plot_u = new(4,graphic)
> plot_o = new(4,graphic)
> plot = new(4,graphic)
>
> gsn_define_colormap(wks,"hotres") ; choose a colormap used hotres
> before
> res = True ; plot mods desired
> res@lbLabelBarOn = False ; turn off individual label bars
> res@cnLineLabelsOn = False
> res@cnInfoLabelOn = False
> res@gsnDraw = False ; don't draw
> res@gsnFrame = False ; don't adnvance frame
> res@cnFillOn = True ; turn on color
> res@gsnSpreadColors = True ; use full range of colormap
> res@cnLinesOn = False ; turn off contour lines
> res@lbLabelAutoStride = True ;
> res@vpWidthF = 0.8 ; change aspect ratio of plot
> res@vpHeightF = 0.4
> res@lbLabelAngleF = 45 ; angle labels
> res@lbLabelFontHeightF =.022 ; make labels larger
> res@lbTitleOn = True ; turn on title
> res@lbTitleFontHeightF = .015 ; make title smaller
> res@pmLabelBarOrthogonalPosF = .10 ; move whole thing down
>
> sres = True
> sres@gsnDraw = False
> sres@gsnFrame = False
> sres@cnLineThicknessF = 2.
> sres@tfDoNDCOverlay = True
>
> ;===============================================================================
> ; Make plots
>
> ;===============================================================================
>
> plot_o(0) = gsn_csm_contour(wks,Fa1,sres)
> plot_u(0) = gsn_csm_contour(wks,U1,res)
> overlay(plot_o(0),plot_u(0))
> plot(0) = plot_o(0)
>
> plot_o(1) = gsn_csm_contour(wks,Fa2,sres)
> plot_u(1) = gsn_csm_contour(wks,U2,res)
> overlay(plot_o(1),plot_u(1))
> plot(1) = plot_o(1)
>
> plot_o(2) = gsn_csm_contour(wks,Fa3,sres)
> plot_u(2) = gsn_csm_contour(wks,U3,res)
> overlay(plot_o(2),plot_u(2))
> plot(2) = plot_o(2)
>
>
> plot_u(3) = gsn_csm_contour(wks,U4,res)
> plot_o(3) = gsn_csm_contour(wks,Fa4,sres)
> overlay(plot_o(3),plot_u(3))
> plot(3) = plot_o(3)
>
>
> ;===============================================================================
> ; Creat Panel
>
> ;===============================================================================
>
> resP = True
> resP@txFontHeightF = 0.03
> resP@gsnFrame = False ; don't
> advance panel plot
> resP@txString = "Surface Winds "+File ;
> add common title
> resP@gsnPanelBottom = 0.01 ; add
> space at bottom
> resP@gsnPanelFigureStrings = (/"t = "+T1,"t = "+T2,"t =
> "+T3,"t = "+T4/) ; add strings to panel
> resP@amJust = "BottomRight"
> resP@gsnPanelFigureStringsFontHeightF = 0.015 ; set string font
> size
> resP@gsnPanelLabelBar = True ; set common
> label bar
> resP@gsnPanelFigureStringsPerimOn = True ; turn off box
> around annotation
> resP@gsnPanelXWhiteSpacePercent = 5 ; set a bit of
> extra white space between panels in the x and y directions
> resP@gsnPanelYWhiteSpacePercent = 5
> resP@gsnPaperOrientation = "landscape"
>
> gsn_panel(wks,plot,(/2,2/),resP)
>
>
> txres = True
> txres@txFontHeightF = 0.015
> gsn_text_ndc(wks,Title,0.5,0.02,txres)
>
> frame(wks)
>
>
> end
>
>
>
> Thank you for your help,
> Kara
>
>
> --
> "Don't knock the weather; nine-tenths of the people couldn't start a
> conversation if it didn't change once in a while." ~Kin Hubbard
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>

-- 
"Don't knock the weather; nine-tenths of the people couldn't start a
conversation if it didn't change once in a while."  ~Kin Hubbard


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

Received on Thu May 24 18:57:02 2012

This archive was generated by hypermail 2.1.8 : Fri May 25 2012 - 08:35:50 MDT