[ncl-talk] Set desired color map

Setareh Rahimi setareh.rahimi at gmail.com
Mon Nov 7 02:47:22 MST 2022


Dear NCL users,
I need to set my desired color map for my plot. I defined it this way in
NCL: gsn_define_colormap(wks,"GMT_no_green")  (CHECK the attached).
But NCL used the default color map (https://
www.ncl.ucar.edu/Document/Graphics/ColorTables/ncl_default.shtml).
Moreover, I tested this command line: res at cnFillPalette        =
"GMT_no_green", bud did not work!
How can I manage this issue, please?
Best wishes,


-- 
S.Rahimi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221107/6705d712/attachment.htm>
-------------- next part --------------
;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/wrf/WRF_contributed.ncl"
;***************************************************************************************************************************



  f = addfile ("wrfout_d01_2011-06-22_00:00:00", "r")
      print(f)                              ; same as "nmcdump -h"

  Times = f->Times                          ; [Time | 41] x [DateStrLen | 19]  (character)
  Time_0 = wrf_times_c( Times, 0 )          ; "hours since" initial time on file   (double)
                                            ;  Time_0 is recognized by cd_calendar
  Time_3 = wrf_times_c( Times, 3 )          ; yyyymmddhh  (type "integer") 
  Time_3 = Time_3/100                       ; remove 'ss' part of Time_3
  Time_3 at units = "yyyymmdd"      
 
  print("********************************************************************************************************************")
  
  wks = gsn_open_wks("png" ,"WRF_aod_Daily-Average")                   ; ps,pdf,x11,ncgm,eps  
  gsn_define_colormap(wks,"GMT_no_green")                         ; select color map
    
  res = True    ; plot mods desired
  res at cnConstFEnableFill =  True
  res at gsnMaximize = True
  res at gsnSpreadColors = True
  res at cnFillOn = True
  res at cnLinesOn = False
  res at cnLineLabelsOn = Fals
  WRF_map_c(f, res, 0)
  res at tfDoNDCOverlay = True

;**************************************************************************************
;**************************************************************************************
   
 res at cnLevelSelectionMode = "ExplicitLevels"
  res at cnLevels = (/0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2,2.1,2.2,2.3,2.4,2.5/)
 

  res at mpFillOn             = False
  res at mpLimitMode          = "LatLon"          ; choose region of map
  res at mpLeftCornerLatF     = xlat(0,0)
  res at mpLeftCornerLonF     = xlon(0,0)
  res at mpRightCornerLatF    = xlat(nlat-1,mlon-1)
  res at mpRightCornerLonF    = xlon(nlat-1,mlon-1)
  res at mpDataBaseVersion    = "MediumRes"        ; better map outlines
  res at pmTickMarkDisplayMode= "Always"           ; turn on tickmarks
  ;res at mpOutlineBoundarySets = "GeophysicalAndUSStates"
  res at pmTickMarkDisplayMode = "Always"
  res at mpMaxLatF            = 40      ; choose subregion
  res at mpMinLatF            = 24
  res at mpMaxLonF            = 63
  res at mpMinLonF            = 44
  ;res at sfXArray = xlon                              ; equivalently x at lon2d = xlon
  ;res at sfYArray = xlat                              ; equivalently x at lat2d = xlat
  
 ;***************************************************************************************************************************
  
  
  ymd = cd_calendar(Time_0, -2)
  print(ymd)    
  YMD = 20110629
  mt  = ind(YMD.eq.ymd) 

wks = gsn_open_wks("png" ,"WRF_aod_Daily-Average"+YMD)  
;;print(mt) 
 
  A2           = f->TAUAER2      ; (Time, south_north, west_east)
  A2&Time      = Time_0          ; associate the 'Time' coordinate with the variable using  standard NCL & syntax

  a2           = A2(mt,:,:,:)    ; (Time, south_north, west_east)
  printVarSummary(a2)            ; [Time | 8] x [bottom_top | 35] x [south_north | 199] x [west_east | 199]
  delete(A2)

  B3           = f->TAUAER3      ; (Time, south_north, west_east)
  B3&Time      = Time_0          ; associate the 'Time' coordinate with the variable using  standard NCL & syntax

  b3           = B3(mt,:,:,:)    ; (Time, south_north, west_east)
  printVarSummary(b3)            ; [Time | 8] x [bottom_top | 35] x [south_north | 199] x [west_east | 199]
  delete(B3)

  time_3       = Time_3(mt)      ; (Time | 8)
  print(time_3)

  print("********************************************************************************************************************")
  

  opt_cdv = True                 ; option for calculate_daily_values  (cdv)
  opt_cdv at nval_crit = 4          ; default is 1

  a2Day = calculate_daily_values (a2, "avg", 0, opt_cdv)
  printVarSummary(a2Day)         ; [Time | 1] x [bottom_top | 35] x [south_north | 199] x [west_east | 199]        
  printMinMax (a2Day,1)
  
  b3Day = calculate_daily_values (b3, "avg", 0, opt_cdv)
  printVarSummary(b3Day)         ; [Time | 1] x [bottom_top | 35] x [south_north | 199] x [west_east | 199]
  printMinMax (b3Day,1)
  
  print("")
  print("***********************************************************************************************************")
  print("")
  
  angstrom_exponent = -(log(a2Day)-log(b3Day))/log(400./600.)
  printVarSummary(angstrom_exponent)          ; [1] x [35] x [199] x [199]
  printMinMax((angstrom_exponent)          ; [1] x [35] x [199] x [199]
  
  AOD550_3D = a2Day * ((400.0/550.0)^angstrom_exponent)
 ;AOD550_3D at long_name   =  "AOD550_3D"
  AOD550_3D at description =  "AOD550_3D"
  copy_VarCoords(a2Day,AOD550_3D )
  printVarSummary(AOD550_3D)      ; [Time | 1] x [bottom_top | 35] x [south_north | 199] x [west_east | 199]
  
  AOD550_2D = dim_sum_n_Wrap(AOD550_3D,1)
 ;AOD550_2D at long_name   =  "AOD550_2D"
  ;AOD550_2D at description =  "AOD550_2D"
  printVarSummary(AOD550_2D)      ; [bottom_top | 35] x [south_north | 199] x [west_east | 199]
  
  if (any(isnan_ieee(AOD550_2D))) then
     value = 9.96921e+36  
     replace_ieeenan (AOD550_2D,value,0)
     AOD550_2D at _FillValue = value
  end if
  
  printVarSummary(AOD550_2D)
  printMinMax (AOD550_2D,1)
  print("")
  print("***********************************************************************************************************")
  print("")

  res at tiMainString = "AOD-" + time_3(0)
;;res at gsnLeftString = a at description                            ; ?????????????????
  res at gsnLeftString = AOD550_2D at description
  print(res)

plot = gsn_csm_contour_map(wks,AOD550_2D(0,:,:),res)
 shapefile_name1 = "world-administrative-boundaries.shp"
  shapefile_name2 = "gadm36_IRN_0.shp"
  lnres = True
  lnres at gsLineThicknessF = 3.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)


More information about the ncl-talk mailing list