can't set explicit colours

From: Katja Lohmüller <lohmueller_at_nyahnyahspammersnyahnyah>
Date: Fri Jun 21 2013 - 05:10:43 MDT

Hello NCL-talk,

I'm drawing a trajectory of a flight and on its way, the trajectory
should be coloured depending on the differnt temperatures which were
taken along the flight. Now my problem is that NCL uses some haphazard
colors of the RGB file ("BlWhRe") but I want to choose which colours
should be used. So I tried different resources and functions but none
I could find did work.(In my script the tries appear as commented
lines) It would be great, if one of you will be able to help me with
my problem.

My script is as follows:

;*************************************************
; traj_2.ncl
;*************************************************
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"
;**************************************************
begin
;*************************************
; read in data
;************************************
   path = "/home/lohmueller/Desktop/BA/Amdardaten/Flutra01JanDLH_1.asc"
   data = asciiread(path,(/72,4/),"float")
  ; print(data)
   ntime=72

;********************************************
  wks = gsn_open_wks("pdf","trajectory") ; open workstation
;*********************************************
; color preps
;*****************************

  cnLevels=fspan(-55.0,5.0,13)
   gsn_define_colormap(wks,"BlWhRe")
    cmap = gsn_retrieve_colormap (wks)
; cmap=(/0.0,0.0,0.0/),(/1.0,1.0,1.0/),(/1.0,0.0,0.0/),(/0.0,1.0,0.0/),
; (/0.0,0.0,1.0/),(/1.0,1.0,0.0/),(/0.0,1.0,1.0/),(/1.0,0.0,1.0/),
; (/0.5,0.0,0.0/),(/0.5,1.0,1.0/),(/0.0,0.0,0.5/),(/1.0,1.0,0.5/),
  ; (/0.5,0.0,1.0/),(/1.0,0.5,0.0/),(/0.0,0.5,1.0/),(/0.5,1.0,0.0/),
; (/0.5,0.0,0.5/)
     gsn_define_colormap (wks,cmap)

;printVarSummary (cmap)

    res = True ; map resources

    res@gsnDraw = False ; don't draw
    res@gsnFrame = False ; don't advance frame
    res@vpWidthF = 0.90 ; make map bigger
    res@vpHeightF = 0.90
    res@mpMaxLatF = 55 ; select subregion
    res@mpMinLatF = 20
    res@mpMaxLonF = 65
    res@mpMinLonF = 5
    res@gsnMaximize = True
    res@gsnPaperOrientation = "landscape"

    ;res@cnFillColors = (/64,80,96/)

; label bar resources
    res_lb = True
    res_lb@vpWidthF = 0.60
    res_lb@vpHeightF = 0.10
    res_lb@lbPerimOn = False ; Turn off perimeter.
    res_lb@lbOrientation = "Horizontal" ; Default is vertical.
    res_lb@lbLabelStride = 2
    res_lb@lbLabelAlignment = "InteriorEdges" ; Default is "BoxCenters".
    res_lb@lbFillColors = (/"red","blue"/) ; Colors for boxes.
    res_lb@lbMonoFillPattern = True ; Fill them all solid.
    res_lb@lbLabelFontHeightF = 0.015

    res@tiMainString = "Trajektorie" ; title

    map = gsn_csm_map_ce(wks,res) ; create map
   delete(res)
;*********************************************
;trajectory parameters
;*********************************************

xpt= new(ntime,float)
ypt= new(ntime,float)
t= new(ntime,float)

;*********************************************
;plot parameters
;*********************************************

pres = True
pres@gsLineThicknessF = 2.0
;pres@cnFillColors =(/2,8,14,20,25,31,37,42,48,55,61,67,68/)
;pres@gsLineColor =(/2,8,14,20,25,31,37,42,48,55,61,67,68/)

mres = True
first= True
last= True

;*********************************************

do i=0,ntime-1
   ypt(i) = data(i,0) ;extract latitude(Breite(N))
   xpt(i)= data(i,1) ;extract longitude(Länge(E))
   t(i) = data(i,3)
end do

draw(map)

    do j= 0,ntime-2
       pres@gsLineColor=GetFillColor(cnLevels,cmap,avg((/t(j),t(j+1)/)))
      gsn_polyline(wks,map,(/xpt(j),xpt(j+1)/),(/ypt(j),ypt(j+1)/),pres)
    end do

; create a unique marker to indicate the start of the trajectory

       first@gsMarkerSizeF = 20.0 ; marker size
       first@gsMarkerColor = "red" ; marker color
       last@gsMarkerSizeF = 9.0 ; marker size
       last@gsMarkerColor = "blue" ; marker color

       gsn_polymarker(wks,map,xpt(0),ypt(0),first) ;draw start of trajectory
       gsn_polymarker(wks,map,xpt(71),ypt(71),last) ;draw start of trajectory
       ;delete(first@gsMarkerColor)
       ;delete(first@gsMarkerSizeF)

gsn_labelbar_ndc(wks,dimsizes(cnLevels)+1,cnLevels,0.20,0.20,res_lb)
frame(wks)
delete(wks)

end

-- 
Katja Lohmüller
Institut fuer Meteorologie und Klimatologie
Leibniz Universitaet Hannover
Herrenhaeuser Str. 2
30419 Hannover
Email: lohmueller@muk.uni-hannover.de
Mobil: 0049 176 61396963
Buero: 0049 511 762 2396
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jun 21 05:10:54 2013

This archive was generated by hypermail 2.1.8 : Mon Jun 24 2013 - 11:46:47 MDT