Re: contouring station data

From: James Correia <jimmyc42_at_nyahnyahspammersnyahnyah>
Date: Wed, 22 Oct 2008 13:21:44 -0700

Mary-
Thanks. I set res_at_tfDoNDCOverlay = False
and it worked perfectly. The other issues you mentioned were needed since
the station (point) data are 1d arrays. I just needed to tell NCL to allow
me to project the data onto the grid.
jimmyc

On Wed, Oct 22, 2008 at 12:46 PM, Mary Haley <haley_at_ucar.edu> wrote:

> James,
>
> You have some conflicting information in your script that might be
> causing a problem.
>
> First you have:
>
> res_at_tfDoNDCOverlay = True
>
> which tells NCL that the data has already been projected onto a particular
> map projection, so no calculations will be done to
> transform your data to the given map projection. This setting
> only works if you know the *exact* projection your data
> was measured on. And, given that you are calling WRF_mapres_c,
> this is supposed to set up your map resources to set up
> the correct map projection.
>
> But, then you have:
>
> res_at_mpRightCornerLonF = lona(y2,x2)
> res_at_mpRightCornerLatF = lata(y2,x2)
> res_at_mpLeftCornerLonF = lona(y1,x1)
> res_at_mpLeftCornerLatF = lata(y1,x1)
>
> This is effectively changing the map projection to something different
> than what your data were actually measured, on, so now your data will
> probably not look correct.
>
> Finally, you have:
>
> res_at_sfXArray = lon
> res_at_sfYArray = lat
>
> I'm not sure where the "lon" and "lat" variables came from,
> but these should probably be "lata" and "lona", if anything.
> You don't want to set sfXArray/sfYArray if you've set tfDoNDCOverlay to
> True.
>
> To fix all of this, please try the following steps:
>
> Remove or comment out the line:
>
> res_at_tfDoNDCOverlay = True
>
> (The default of this resource is False).
>
> Change the following "if" statement:
>
> if (.not.res_at_tfDoNDCOverlay) then
> lat2d = f->XLAT(0,:,:) ; need for map limits
> lon2d = f->XLONG(0,:,:)
> end if
>
> to:
>
> if (.not.res_at_tfDoNDCOverlay) then
> cp_at_lat2d = f->XLAT(0,:,:) ; need for map limits
> cp_at_lon2d = f->XLONG(0,:,:)
> end if
>
> The gsn_csm_xxx_map scripts recognize the special "lat2d"
> and "lon2d" attributes and will use these to determine where
> on the map your data is projected. Hence, you no longer need to
> worry about getting the map projection exactly right.
>
> Finally, remove or comment out the lines:
>
> ; res_at_sfXArray = lon
> ; res_at_sfYArray = lat
>
> These two lines will be handled for you internally by virtue of
> setting the special lat2d/lon2d attributes.
>
> Hope this all makes sense.
>
> --Mary
>
>
>
> On Wed, 22 Oct 2008, James Correia wrote:
>
> All-
>> I am having trouble getting my station data to conform to the projection I
>> am using. I can use the gsn_add_text function to overlay numbers, but when
>> I
>> contour the data, the data are shifted relative to the map (looks more
>> like
>> "triangularmesh" assumes the grid is a rectangle, than actually
>> transforming
>> the lat-lon locations to match the LambertConformal projection).
>>
>> Perhaps an alternative is to use rgrid2rcm?
>>
>> jimmyc
>>
>> below is the relevant code.
>> wks = gsn_open_wks("ps" ,"freq") ; ps,pdf,x11,ncgm,eps
>> gsn_define_colormap(wks ,"BlAqGrYeOrReVi200"); choose colormap
>>
>> 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 ; color plot desired
>> res_at_cnLinesOn = False ; turn off contour lines
>> res_at_cnLineLabelsOn = False ; turn off contour labels
>> res_at_lbLabelAutoStride = True ; let NCL figure lb stride
>> res_at_cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal] cn
>> levels
>>
>> res_at_cnLevels = (/10,20,30,40,50,60,70,80,90/)
>> ;************************************************
>> ; Use WRF_contributed procedure to set map resources
>> ;************************************************
>> WRF_map_c(f,res,0) ; set map resources
>> ;************************************************
>> ; set True for native mapping (faster plotting)
>> ; set to False othewise
>> ;************************************************
>> res_at_tfDoNDCOverlay = True
>>
>> ;************************************************
>> ; associate the 2-dimensional coordinates to variables for plotting
>> ; only if res_at_tfDoNDCOverlay=False
>> ;************************************************
>> if (.not.res_at_tfDoNDCOverlay) then
>> lat2d = f->XLAT(0,:,:) ; need for map limits
>>
>> lon2d = f->XLONG(0,:,:)
>> end if
>>
>>
>> ;************************************************
>> ; allocate array for 3 plots
>> ;************************************************
>> plot = new (1,"graphic")
>> ;************************************************
>>
>>
>> lata = f->XLAT(0,:,:)
>> lona = f->XLONG(0,:,:)
>> ;x2 = 105
>> ;y2 = 80
>> ;x1 = 43
>> ;y1 = 18
>> x2 = 100
>> y2 = 85
>> x1 = 38
>> y1 = 22
>> ;x2 = 143
>> ;y2 = 118
>> ;x1 = 10
>> ;y1 = 10
>>
>> res_at_mpRightCornerLonF = lona(y2,x2)
>> res_at_mpRightCornerLatF = lata(y2,x2)
>> res_at_mpLeftCornerLonF = lona(y1,x1)
>> res_at_mpLeftCornerLatF = lata(y1,x1)
>>
>> ;************************************************
>> ; Tell NCL not to draw or advance frame for individual plots
>> ;************************************************
>> ; res_at_gsnDraw = False ; (a) do not draw
>> ; res_at_gsnFrame = False ; (b) do not advance
>> 'frame'
>> res_at_trGridType = "TriangularMesh" ; The default if
>> you
>> ; have 1D data
>> res_at_sfXArray = lon
>> res_at_sfYArray = lat
>> print(res)
>>
>> res_at_gsnLeftString ="CAPE 500 J kg-1"
>> ;plot(0) = gsn_csm_map(wks,res)
>> print(cp)
>> plot = gsn_csm_contour_map(wks,cp,res)
>>
>> --
>> James Correia Jr.
>> Post Doc
>> Climate Physics Group, PNNL
>>
>>

-- 
James Correia Jr.
Post Doc
Climate Physics Group, PNNL
Received on Wed Oct 22 2008 - 14:21:44 MDT

This archive was generated by hypermail 2.2.0 : Fri Oct 24 2008 - 14:07:49 MDT