Re: How to fix this image

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 23 2014 - 08:36:02 MDT

Ipshita,

If you have new questions about your script, please create a new subject
and a new email thread. Otherwise your new question becomes buried in an
old thread.

If you simply want to draw a lat/lon box around some area of interest, you
can use gsn_add_polyline. See example polyg_4.ncl at:

http://www.ncl.ucar.edu/Applications/polyg.shtml

You can also see polyg_13.ncl for a more complicated way of doing this, but
it will give you straight edges, if you need them.

As for writing a loop across time, I'm not sure what you mean by "extract
and save the data from the different boxes". Do you mean save to a NetCDF
file?

I assume your snow_cover_extent variable has time on the leftmost
dimension. If so, then to simply plot the variable for each time step, do
something like:

sce=a->snow_cover_extent ; Read whole variable
dims = dimsizes(sce)
ntime = dims(0)

. . .
do nt=0,ntime-1
    res@tiMainString = ..... ; put something in the main title to
indicate the new time step
   plot = gsn_csm_contour_map_polar(wks,sce(nt,:,:),res) ; create the
plot
end do

--Mary



On Tue, Jul 22, 2014 at 1:04 PM, Ipshita Majhi <ipmajhi@alaska.edu> wrote:

> Hi Alan and Karen,
>
> I got the transparent color going and now the plot looks great!
> Thank you both for your support so far
>
> I wanted to put the box in the polar plot for Kara/Barent sea or Tibetian
> Plateau. How can I do it in a polar plot. I know how to do it in simple
> mercator plot.
>
> How can I write a loop with all the time considered and extract and save
> the date from the different boxes.
>
> Thank you so much in advance.
> Ipshita
>
>
> On Tue, Jul 22, 2014 at 8:47 AM, Brammer, Alan P <abrammer@albany.edu>
> wrote:
>
>> To add to Karens resposne, the black box is because you have it set to
>> plot no_snow pixels black. If you don’t want them black, then se=
t that
>> color to something else ( e.g below)
>>
>>
>> No_snow set to white;
>>
>> res@cnLevelSelectionMode = "ExplicitLevels"
>> res@cnLevels = (/ 0.5 /) ;;;; Only have 2 levels so only need 1
>> contour between them.
>> res@cnFillColors = (/ 0, 4 /) ;;;; 0 = “White”
>> res@lbLabelStrings = (/"no_snow" , "snow_covered"/)
>>
>>
>> No_snow set to transparent;
>>
>> res@cnLevelSelectionMode = "ExplicitLevels"
>> res@cnLevels = (/ 0.5 /) ;;;; Only have 2 levels so only need 1
>> contour between them.
>> res@cnFillColors = (/ -1, 4 /) ;;;;;; -1 = "Transparent"
>> res@lbLabelStrings = (/"no_snow" , "snow_covered”/)
>>
>>
>> The land/water type is a separate variable in the file, if you want
>> that as well then you’ll have to add that to the mix somehow.
>>
>>
>>
>> To get into the lat / lon region extraction, take a look at the
>> numerous functions and try and find one that fits your requirements.
>>
>> http://www.ncl.ucar.edu/Document/Functions/latlon_funcs.shtml
>>
>>
>>
>>
>> Alan.
>>
>>
>>
>>
>> On Jul 22, 2014, at 4:38, Karin Meier-Fleischer <meier-fleischer@dkrz.d=
e>
>> wrote:
>>
>> ;*******************************************
>> 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/csm/contributed.ncl"
>>
>> a =addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602=
.nc
>> ","r")
>> sce=a->snow_cover_extent(0,:,:)
>>
>> lat=a->latitude ;-- if you want the complete array you
>> don't have to use (:,:)
>>
>> print(lat(:,1))
>>
>> lon=a->longitude ;-- if you want the complete array you
>> don't have to use (:,:)
>>
>> ;print(sce)
>> ;print("Hello")
>> ;printVarSummary(sce)
>> ;printVarSummary(lat)
>> ;printVarSummary(lon)
>>
>> ;;; delete_VarAtts(sce, -1) ;-- why are you deleting all variable
>> attributes??
>>
>> ;Attaching variables
>> ;;sce!0="lat2d" ;-- no
>> ;;sce!1="lon2d" ;-- no
>>
>> sce@lat2d=lat
>> sce@lon2d=lon
>>
>> printVarSummary(sce)
>>
>> ; Plotting code
>>
>> wks = gsn_open_wks("ps","sce_ims")
>> gsn_define_colormap(wks,"default")
>>
>> res = True
>> res@cnFillOn = True
>> res@cnLinesOn = False
>> res@cnLineLabelsOn = False
>> res@cnFillMode = "rasterfill"
>> res@cnMissingValFillColor = 28 ; "gray"
>> ;
>> ; Since the data is categorical, values between the categories need to b=
e
>> ; excluded. Use Explicit level selection to accomplish this.
>> ;
>> res@cnLevelSelectionMode = "explicitlevels"
>> res@cnLevels = (/ 0.99,1.99, 2.99, 3.99, 4.99 /)
>> res@cnFillColors = (/ 1, 4, 19, 6, 0, 1 /) ; (/"black", "blue", "green=
",
>> "yellow", "white", "black" /)
>> res@lbLabelAlignment = "boxcenters"
>> res@lbLabelStrings = (/ "water", "land", "ice", "snow" /)
>> ;
>> ; First draw the plot without projecting into map coordinates.
>> ; This has the drawback that only index values are used as tick marks
>> ; but it is fast
>> ;
>> res@gsnPolar = "NH" ; specify the hemispher=
e
>> plot = gsn_csm_contour_map_polar(wks,sce,res) ; create the plot
>> ;*******************************************
>>
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

Received on Wed Jul 23 02:36:02 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT