[ncl-talk] Getting North to be Up on plots from WRF_lc_8.ncl ?

Mary Haley haley at ucar.edu
Wed Dec 19 09:08:23 MST 2018


Hi Ronald,

The reason the map is oriented this way is because this is how it is
defined on your WRF output file. When you call this function:

 res = wrf_map_resources(f,res)

this queries the WRF NetCDF file to get the map projection parameters
necessary to plot your data in the "native" WRF map projection.

If you don't want to draw your data in the native projection, then you will
need to attach the WRF lat/lon arrays to the variables being plotted and
set your own map projection resources.  You can see an example of how to do
this on the "Using gsn_csm scripts to plot WRF-ARW data" page.

Look at example wrf_gsn_8.ncl, and in particular, look at the first plot
created by this example.

http://www.ncl.ucar.edu/Applications/wrfgsn.shtml#ex8

It has these lines, which attach the lat/lon variables to the variables
being plotted:

;---Required for plotting over map (not using WRF's map projection here)
  u10 at lat2d = lat
  u10 at lon2d = lon
  v10 at lat2d = lat
  v10 at lon2d = lon

It sets the min/max lat/lon area to look at:

  res at mpMinLatF          = min(lat)-1
  res at mpMaxLatF          = max(lat)+1
  res at mpMinLonF          = min(lon)-1
  res at mpMaxLonF          = max(lon)+1

Finally, in order to plot data this way, you must make sure you are NOT
setting this resource:

  res at tfDoNDCOverlay   = True          ; Tell NCL you are doing a native plot


The second plot of this example shows how to plot the data in the native
projection, which is what you already have.

--Mary



On Mon, Dec 17, 2018 at 1:15 PM Ronald Stenz <rds238 at cornell.edu> wrote:

> How do I get North to be on the top of my plots using WRF_lc_8.ncl?  I am
> using the same code given on the website, where the plots shown have north
> in the upward direction.  However, on my plot which is attached, north is
> towards the upper right corner of the plot... it is not directly upward.
> What should I be doing to fix this?
>
> I am using the lambert conformal grid in WRF.  My code is below (same as
> the website)  Thanks!  :
>
>
> ;----------------------------------------------------------------------
> ; WRF_lc_8.ncl
> ;
> ; Concepts illustrated:
> ;   - Plotting WRF data that's on a Lambert Conformal map projection
> ;   - Using gsn_csm_vector_scalar_map to plot WRF-ARW data
> ;   - Drawing wind barbs over filled contours
> ;   - Creating a color map using named colors
> ;   - Drawing raster contours
> ;----------------------------------------------------------------------
> ; WRF: near surface winds and total precipitation
> ;----------------------------------------------------------------------
> ; These files are loaded by default in NCL V6.2.0 and newer
> ; 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/wrf/WRFUserARW.ncl"
>
> begin
> ;
> ; Open file
> ; Read U10 and V10, Cumulus (rinc) and Non-cumulus (rainnc) prc
> ;
>   f       = addfile ("wrfout_d01_000000_25time.nc","r")
>   rainc   = f->RAINC                 ; (Time, south_north, west_east)
>   rainnc  = f->RAINNC
>   u10     = f->U10                   ; (Time, south_north, west_east)
>   v10     = f->V10
>
>   times   = wrf_user_getvar(f,"times",-1)
>   ntim    = dimsizes(times)          ; # time steps
>
> ;
> ; Use NCL operator > to make sure all values >=0.0
> ; Sum components and assign attributes
> ;
>   rainc   = rainc  > 0.0
>   rainnc  = rainnc > 0.0
>   rainTot = rainc + rainnc
>   rainTot at description = "Total Precipitation"
>   rainTot at units       =  rainc at units
>
>   wks = gsn_open_wks("png","WRF_lc")
>
>   colors = (/"white","azure"          \
>             ,"green","palegreen","yellowgreen", "greenyellow" \
>             ,"yellow","goldenrod","orange","orangered"        \
>             ,"red","deeppinK", "violet","darkviolet"          \
>             ,"blueviolet","blue"                              /)
>
>   res                       = True             ; plot mods desired
>   res at gsnMaximize           = True             ; maximize size
>   res at gsnScalarContour      = True               ; contours desired
>   res at gsnLeftString         = "Wind Vectors (m/s)"
>   res at gsnRightString        = "Total Precipitation (mm)"
>
>   res at cnFillOn              = True             ; color plot desired
>   res at cnFillPalette         = colors           ; define colors for contour plot
>   res at cnLinesOn             = False            ; turn off contour lines
>   res at cnLineLabelsOn        = False            ; turn off contour labels
>   res at cnFillMode            = "RasterFill"     ; raster
>   res at cnLevelSelectionMode  = "ExplicitLevels" ; explicit [unequal] cn levels
>   res at cnLevels              = (/0,0.1,1,2.5,5,7.5,10,15,20,25,37.5,50,75,100,125,150/)
>
>   res at vcGlyphStyle          = "WindBarb"
>   res at vcRefLengthF          = 0.025            ; ref vec length
>   res at vcMinDistanceF        = 0.025            ; larger means sparser
>   res at vcWindBarbTickLengthF = 0.4              ; default 0.3
>   res at vcRefAnnoOn           = False
>
>   res = wrf_map_resources(f,res)
>   res at gsnAddCyclic          = False            ; regional data: not cyclic
>   res at tfDoNDCOverlay        = True
>
>   res at mpFillOn                    = False
>   res at mpGeophysicalLineColor      = "black"    ; wrf_map_resources uses "gray"
>   res at mpUSStateLineColor          = "black"
>   res at mpGeophysicalLineThicknessF = 2.0        ; wrf_map_resources uses 0.5
>   res at mpUSStateLineThicknessF     = 2.0
> ;
> ; Plot one time and level for demo
> ; .  create u and v on a common grid for visualization: nothing fancy
> ;
>   nt = 12
> ;;do nt=0,ntim-1                               ; uncomment to loop
>      res at tiMainString             = times(nt)
>      plot = gsn_csm_vector_scalar_map(wks,u10(nt,:,:),v10(nt,:,:),rainTot(nt,:,:),res)
> ;;end do
>
> end
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#m_-2210190844247256452_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> _______________________________________________
> ncl-talk mailing list
> 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/20181219/ae20f215/attachment.html>


More information about the ncl-talk mailing list