[ncl-talk] *******Position of shape-file move to the right by narrowing the lat/lon*******

Setareh Rahimi setareh.rahimi at gmail.com
Sat Apr 6 05:20:51 MDT 2024


Dear Adam,

Thank you so much for your suggestion. I added the following lines
(highlighted) to my script but I still have the same problem.

  res at mpLimitMode          = "LatLon"          ; choose region of map

  *res at ZoomIn               = True*

  res at mpMaxLatF            = 40      ; choose subregion

  res at mpMinLatF            = 30

  res at mpMaxLonF            = 61

  res at mpMinLonF            = 42


 r*es = wrf_map_resources(f,res) **  ; must call this again after setting
ZoomIn/X/Ystart/end*

please check the attached and please advise me where I made the mistakes.
Thanks,

On Sat, Apr 6, 2024 at 3:25 AM Adam Phillips <asphilli at ucar.edu> wrote:

> Hi Setareh,
> See example #2 here for how to zoom in on a plot when you are
> using wrf_map_resources:
> https://www.ncl.ucar.edu/Applications/wrfzoom.shtml#ex2
> Best,
> Adam
>
> On Wed, Apr 3, 2024 at 4:26 AM Setareh Rahimi via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
>> Dear NCL users,
>>
>> I tried to plot the total precipitation for 2021-03_12 (24 hours), using
>> the attached script. However, once I tried to zoom in on the study area to
>> better show the result by shortening the lat/lon range I noticed the
>> position of the shapefile on the plot was not correct ( it moved to the
>> right). How can I fix the shape file to the right position? ( please check
>> the attached images).
>>
>> please help me to sole this issue.
>> Thanks.
>>
>> --
>> S.Rahimi
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at mailman.ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
>
> --
> Adam Phillips
> Associate Scientist IV, Climate Analysis Section
> Climate and Global Dynamics Laboratory
> National Center for Atmospheric Research
> www.cgd.ucar.edu/staff/asphilli/
>
> <http://www.cgd.ucar.edu/staff/asphilli>
>


-- 
S.Rahimi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20240406/d2dd43ec/attachment.htm>
-------------- next part --------------

  f       = addfile ("wrfout_d01_2021-03-06_19:00:00","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
  print(times)
  
  dims    = dimsizes(rainc)
  print(dims)
;
; 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")

  
  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 gsnDraw             = False          ; don't draw plot yet
  res at gsnFrame            = False          ; don't advance frame yet
  res at mpDataBaseVersion   = "MediumRes"    ; slightly better resolution  



  res at cnFillOn              = True             ; color plot desired
  res at cnFillPalette         = "BlAqGrYeOrReVi200" ; select color map
  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,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60/)
 
 
 
  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
  
  ;res at mpDataBaseVersion    = "MediumRes"        ; better map outlines
  res at mpLimitMode          = "LatLon"          ; choose region of map
  res at ZoomIn               = True
  res at mpMaxLatF            = 40      ; choose subregion
  res at mpMinLatF            = 30
  res at mpMaxLonF            = 61
  res at mpMinLonF            = 42

 res = wrf_map_resources(f,res)   ; must call this again after setting ZoomIn/X/Ystart/end

;
; Plot one time and level for demo
; .  create u and v on a common grid for visualization: nothing fancy
;
                           
     ;res at tiMainString             = times(nt)
     h=(rainTot(148,:,:) - rainTot(125,:,:))
      ;plot = gsn_csm_vector_scalar_map(wks,u10(nt,:,:),v10(nt,:,:),(rainTot(nt,:,:) - rainTot(nt-1,:,:)),res)
      plot = gsn_csm_contour_map(wks,h,res)
   

  shapefile_name1 = "Ostan.shp"
  shapefile_name2 = "City-Poligon6.shp"
  lnres = True
  lnres at gsLineThicknessF = 4.0
  lnres at gsLineColor = "Black"
  shape1 = gsn_add_shapefile_polylines(wks,plot,shapefile_name1,lnres)
  shape2 = gsn_add_shapefile_polylines(wks,plot,shapefile_name2,lnres)



  res at gsnDraw = False
  res at gsnFrame= False


draw(plot)
frame(wks)

 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: no zoom.png
Type: image/png
Size: 122376 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20240406/d2dd43ec/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zoom.png
Type: image/png
Size: 107734 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20240406/d2dd43ec/attachment-0001.png>


More information about the ncl-talk mailing list