Re: Error with drawing a polygon in a polar sterographic map

From: Ipshita Majhi <ipmajhi_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 23 2014 - 15:04:23 MDT

Here is the complete code thank you for the support

;************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; read in netCDF file
;************************************************
 a =addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602.nc
","r")

sce=a->snow_cover_extent(0,:,:)
lat=a->latitude
lon=a->longitude


;Attaching latitude and longitude to sce
sce@lat2d=lat
sce@lon2d=lon


;************************************************
; create plot
;************************************************
  wks = gsn_open_wks("ps","polyg") ; open a ncgm file

  res = True ; plot mods desired
  res@gsnDraw = False ; don't draw yet
  res@gsnFrame = False ; don't advance yet

  res@mpMinLatF = 40 ; zoom in on a subregion
  res@mpMaxLatF = 60
  res@mpMinLonF = 10
  res@mpMaxLonF = 30

res@gsnPolar = "NH" ; specify the hemisphere
plot = gsn_csm_contour_map_polar(wks,sce,res) ; create the plot

;************************************************
; create points for box
;************************************************
 ypts = (/ 30.0, 30.0, 0.0, 0.0, 30.0/)
 xpts = (/-90.0, -45.0,-45.0, -90.0,-90.0/)
;************************************************
; add the box
;************************************************
  resp = True ; polyline mods desir=
ed
  resp@gsLineColor = "red" ; color of lines
  resp@gsLineThicknessF = 2.0 ; thickness of lines
  resp@gsLineLabelString= "test" ; adds a line label
string

; create array of dummy graphic variables. This is required, b/c each line
; must be associated with a unique dummy variable.

  dum = new(4,graphic)

; draw each line separately. Each line must contain two points.
  do i = 0 , 3
  dum(i)=gsn_add_polyline(wks,plot,xpts(i:i+1),ypts(i:i+1),resp)
  end do

; label the box with additional text
;************************************************
  tres = True
  tres@txFontHeightF = 0.02
  gsn_text(wks,plot,"sample",-60.0,15.0,tres)

  draw(plot)
  frame(wks)

; now fill in some polygons and add to plot.

  resp@gsFillIndex = 17
  resp@gsFillColor = "purple"
  dum2 = gsn_add_polygon(wks,plot,xpts,ypts,resp)

  xtri = (/ -125, -115, -120 /)
  ytri = (/ -15, -10, 5 /)

  resp@gsFillIndex = 5
  resp@gsFillScaleF = 0.5
  resp@gsFillColor = "brown"
  dum3 = gsn_add_polygon(wks,plot,xtri,ytri,resp)

  resp@gsFillScaleF = 0.75
  resp@gsFillColor = "blue"
  dum4 = gsn_add_polygon(wks,plot,xtri+10,ytri,resp)

  resp@gsFillScaleF = 1.0 ; Default
  resp@gsFillColor = "forestgreen"
  dum5 = gsn_add_polygon(wks,plot,xtri+20,ytri,resp)

  draw(plot)
  frame(wks)

end

  draw(plot)
  frame(wks)

end


On Wed, Jul 23, 2014 at 12:46 PM, Karin Meier-Fleischer <
meier-fleischer@dkrz.de> wrote:

> Hi Ipshita,
>
> Could you send the complete script. The polygon part is missing hence we
> can’t say anything about it.
>
> The warning about mpMinLonF and MaxLonF tells you what it is, you canâ=
€™t
> set it. Just mpMinLatF and
> mpMaxLatF can be used. See example polar_5.ncl on
> http://www.ncl.ucar.edu/Applications/polar.shtml
>
> Bye,
> Karin
>
>
> Am 23.07.2014 um 21:44 schrieb Ipshita Majhi <ipmajhi@alaska.edu>:
>
> Hi,
>
> I am trying put a box around the region of interest. But I get two errors
> and I am not sure how to get a handle around it.
>
> One is
> Warning: You should not set the mpMinLonf and /or MarLonF resources.
>
> fatal: NhlCvStringToEnum:Unable to convert string "missing" to requested
> type
>
> Warning : Error retrieving resource om Just from args-Ignoring Args.
>
> Here is the code:-
>
> I want to put a box around a particular region and the extract the data
> and take average of that region. Do it for all the time series
>
> ;Date:07/23/2014
> ;Ipshita Majhi
>
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> ;************************************************
> begin
> ;************************************************
> ; read in netCDF file
> ;************************************************
> a =addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602.=
nc
> ","r")
>
> sce=a->snow_cover_extent(0,:,:)
> lat=a->latitude
> lon=a->longitude
>
>
> ;Attaching latitude and longitude to sce
> sce@lat2d=lat
> sce@lon2d=lon
>
>
> ;************************************************
> ; create plot
> ;************************************************
> wks = gsn_open_wks("ps","polyg") ; open a ncgm file
>
> res = True ; plot mods desired
> res@gsnDraw = False ; don't draw yet
> res@gsnFrame = False ; don't advance yet
>
> res@mpMinLatF = 40 ; zoom in on a subregi=
on
> res@mpMaxLatF = 60
> res@mpMinLonF = 10
> res@mpMaxLonF = 30
>
> res@gsnPolar = "NH" ; specify the hemisphere
> plot = gsn_csm_contour_map_polar(wks,sce,res) ; create the plot
>
> ;************************************************
> ; create points for box
> ;************************************************
> ypts = (/ 30.0, 30.0, 0.0, 0.0, 30.0/)
> xpts = (/-90.0, -45.0,-45.0, -90.0,-90.0/)
> ;************************************************
> ; add the box
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>

Received on Wed Jul 23 09:04:29 2014

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2014 - 15:10:55 MDT