Background map

The NCL graphics package.

Background map

Postby carinavb » Thu Mar 17, 2011 9:59 am

Hello everybody: I used wrf_ script to generate real-data plots,
For example I generate precipitation, in the other hand I have a "background" map, which I used shapefile.ncl to generate this using a shp file.
The question is, how I put that background in my precipitacion plot?
I want to se my region limits, that's why I want to do this.

I hope you understand what I'm trying to do.

Regards
carinavb
 
Posts: 31
Joined: Wed Jun 23, 2010 4:05 pm

Re: Background map

Postby dbh409 » Tue Mar 29, 2011 9:15 am

What you want to use is wrf_map_overlays in which you will need to define mpres. For example:

Code: Select all
  res = True
  mpres = True
  res@cnFillOn  = True
  res@cnLevelSelectionMode = "ManualLevels"
  res@cnMinLevelValF       = -140.                 ; set min contour level
  res@cnMaxLevelValF       = 140.                 ; set max contour level
  res@cnLevelSpacingF = 20.
  res@cnLevelSelectionMode = "ManualLevels"
  mpres@mpUSStateLineThicknessF = 2
  mpres@mpUSStateLineColor = "black"
  mpres@mpGeophysicalLineColor = "black"
  mpres@mpGeophysicalLineThicknessF = 2
  mpres@mpNationalLineThicknessF = 2
  mpres@mpNationalLineColor = "black"

  plotjl = wrf_contour(nc_file_in_jl_C,wks,precipdiff_jl,res)
  map_cont_jl = wrf_map_overlays(nc_file_in_jl_C, wks,plotjl,True,mpres)


You can find details on how to use wrf_map_overlays at http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_map_overlays.shtml

HTH,

Dave
dbh409
 
Posts: 89
Joined: Wed Mar 24, 2010 11:46 am

Re: Background map

Postby carinavb » Thu Mar 31, 2011 7:28 am

Thanks fot the answer.
What I finally did was, using the example shapefiles.ncl and create a function and then add this plot in my wrf_xx.ncl plot
The function was modificated by Mary Haley from ncl, if someone need this let me know.

Regards
carinavb
 
Posts: 31
Joined: Wed Jun 23, 2010 4:05 pm

Re: Background map

Postby Arturo.Lomas » Fri Aug 05, 2011 11:47 am

Greetings!
Please can send me the NCL script to plot the shape + wrfout
Thanks
Arturo.Lomas
 
Posts: 1
Joined: Sat Sep 04, 2010 2:44 pm

Re: Background map

Postby cycle_13 » Wed Jan 02, 2013 2:58 am

to carinavb,
I also want to plot wrf output map using shape file data, but I always plot two map in my output files, which are one wrf output map and one map of my shapefile map. So can you send me the NCL script to plot the shape + wrfout.
Thanks
cycle_13
 
Posts: 27
Joined: Mon Jun 21, 2010 8:48 pm

Re: Background map

Postby cycle_13 » Wed Jan 02, 2013 2:59 am

my email address is cyclesj@gmail.com
cycle_13
 
Posts: 27
Joined: Mon Jun 21, 2010 8:48 pm

Re: Background map

Postby sam » Sat Sep 21, 2013 4:08 am

Hi, Can you send me this script too. My email is simba.kz@gmail.com
sam
 
Posts: 1
Joined: Sat Sep 21, 2013 4:04 am

Re: Background map

Postby hano » Thu Feb 13, 2014 9:35 am

Hi, could You send me the shape+WRF code too? (hbrys@wp.pl) or tell me whats wrong with my code (I recive always separate maps); Thanks:

Code: Select all
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
a = addfile("/home/data/WRF/wrfout_d02_2010-01-02_00:00:00.nc","r")
type="x11"
wks=gsn_open_wks(type,"SO2_DolnySlask")
res=True

res@MainTitle = "Stezenie SO2"
res@InitTime = False
res@Footer = False
pltres = True
mpres = True
mpres1 = True

times = wrf_user_getvar(a,"times",-1)
ntimes=dimsizes(times)
do it = 0,ntimes -1,1
print("Time" + times(it))
res@TimeLabel = times(it)
SO2 = wrf_user_getvar(a,"so2",it)
SO2@description = "Stezenie SO2"
SO2@units="ppmv"
U10 = wrf_user_getvar(a,"U10",it)
V10 = wrf_user_getvar(a,"V10",it)
U10@units = "m/s"
V10@units = "m/s"
lats = (/ 50.0, 52.0 /)
lons = (/ 14.5, 18.0 /)
loc = wrf_user_ll_to_ij(a, lons, lats, True)
x_start = loc(0,0) -1
x_end = loc(0,1) -1
y_start = loc(1,0) -1
y_end = loc(1,1) -1
mpres1@ZoomIn = True
mpres1@Xstart = x_start
mpres1@Ystart = y_start
mpres1@Xend = x_end
mpres1@Yend = y_end

shape= addfile("/home/hano/Downloads/POL_adm1.shp","r")

segments=shape->segments
geometry=shape->geometry
segsDims=dimsizes(segments)
geomDims=dimsizes(geometry)

geom_segIndex=shape@geom_segIndex
geom_numSegs=shape@geom_numSegs
segs_xyzIndex=shape@segs_xyzIndex
segs_numPnts=shape@segs_numPnts
numFeatures=geomDims(0)

SO2_zoom = SO2(:,y_start:y_end,x_start:x_end)
U10_zoom = U10(y_start:y_end,x_start:x_end)
V10_zoom = U10(y_start:y_end,x_start:x_end)
dimsv = dimsizes(SO2)
do level = 0, dimsv(0)-1,1
display_level = level + 1
res@PlotLevelID = "Poziom" + display_level
opts = res
opts@cnFillOn = True
opts@gsnSpreadColorEnd = -3
contour_SO2 = wrf_contour(a,wks,SO2_zoom(level,:,:),opts)
delete(opts)
opts=res
opts@FieldTitle = "Predkosc wiatru"
opts@NumVectors = 40
vector = wrf_vector(a,wks,U10_zoom,V10_zoom,opts)
delete(opts)

plot = wrf_map_overlays(a,wks,(/contour_SO2,vector/),pltres,mpres1)

shape= addfile("/home/hano/Downloads/POL_adm1.shp","r")

segments=shape->segments
geometry=shape->geometry
segsDims=dimsizes(segments)
geomDims=dimsizes(geometry)

geom_segIndex=shape@geom_segIndex
geom_numSegs=shape@geom_numSegs
segs_xyzIndex=shape@segs_xyzIndex
segs_numPnts=shape@segs_numPnts
numFeatures=geomDims(0)

shres = True
shres@gsLineColor="black"

lines = new(segsDims(0),graphic)

numFeatures = geomDims(0)

lon=shape->x
lat=shape->y
segNum=0
do i=0, numFeatures-1
  startSegment=geometry(i, geom_segIndex)
  numSegments=geometry(i, geom_numSegs)
  do seg=startSegment, startSegment+numSegments-1
    startPT = segments(seg, segs_xyzIndex)
    endPT = startPT + segments(seg, segs_numPnts) - 1
    lines(segNum) = gsn_add_polyline(wks, plot, lon(startPT:endPT), lat(startPT:endPT), shres)
    segNum = segNum + 1
  end do
end do

draw(plot)

end do
end do
end
hano
 
Posts: 1
Joined: Wed Feb 12, 2014 10:23 am

Re: Background map

Postby Mat45 » Tue Apr 12, 2016 3:22 am

Hi, can you send me this script too ? My email is: mateusz4586@gmail.com
Thanks :)
Mat45
 
Posts: 1
Joined: Tue Apr 12, 2016 3:18 am


Return to NCL

Who is online

Users browsing this forum: No registered users and 1 guest