[ncl-talk] problems when using the "res at cnFillPalette = "BlGrYeOrReVi200""
Rick Brownrigg
brownrig at ucar.edu
Mon May 10 09:48:24 MDT 2021
Hi Zoe,
I should have initially asked what version of NCL are you using (command
"ncl -v")? I am not getting that warning message, using the latest
v6.6.2. I get the attached plot (note, I don't have the RANGS database
handy, so it's not using the HighRes map database).
I also had to add a "draw(plot)" statement after the call to
wrf_map_overlays(). I'm not sure what you intend there in that loop "do
i=0,ntimes-1,2", whether there should be multiple plots or a panel plot?
Just a side comment, since "opts" doesn't change each time through the
loop, you could factor the settings outside the loop, and thus not reload
the colormap each time.
Not sure what to tell you about the warning message.
Rick
On Mon, May 10, 2021 at 8:56 AM ZUO Ziping <zzuoaa at connect.ust.hk> wrote:
> ZUO Ziping 已与你共享 OneDrive for Business 文件。若要查看,请单击下面的链接。
>
> <https://hkustconnect-my.sharepoint.com/:u:/g/personal/zzuoaa_connect_ust_hk/EeUL6jlxFXpLnHPqsHBboMMBbQVExXFpSnLO8ctJ_pR6Jg>
> wrfout_d04_2018-07-15_23_00_00
> <https://hkustconnect-my.sharepoint.com/:u:/g/personal/zzuoaa_connect_ust_hk/EeUL6jlxFXpLnHPqsHBboMMBbQVExXFpSnLO8ctJ_pR6Jg>
>
> <https://hkustconnect-my.sharepoint.com/:u:/g/personal/zzuoaa_connect_ust_hk/EeUL6jlxFXpLnHPqsHBboMMBbQVExXFpSnLO8ctJ_pR6Jg>
> Dear Rick,
>
> Please use the following script. And the attachment is the wrfout file.
> Thank you very much!
>
> 1 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> 2 load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> 3
> 4 begin
> 5
> 6 a = addfile("/wrfout/D4/wrfout_d04_2018-07-15_23:00:00","r")
> 7
> 8 type = "pdf"
> 9 wks = gsn_open_wks(type,"2m_temp")
> 10
> 11 res = True
> 12 res at MainTitle = "REAL-TIME WRF"
> 13 res at Footer = False
> 14
> 15 pltres = True
> 16 pltres at PanelPlot = True
> 17 pltres at FramePlot = False
> 18
> 19 mpres = True
> 20 mpres at mpDataBaseVersion = "HighRes"
> 21 mpres at mpGeophysicalLineColor = "Black"
> 22 mpres at mpGridLineColor = "Black"
> 23 mpres at mpDataResolution = "Finest"
> 24
> 25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 26 times = wrf_user_getvar(a,"times",-1) ; get all times in the file
> 27 ntimes = dimsizes(times) ; number of times in the file
> 28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 29
> 30 do it = 0,ntimes-1,2 ; TIME LOOP
> 31
> 32 print("Working on time: " + times(it) )
> 33 res at TimeLabel = times(it) ; Set Valid time to use on plots
> 34
> 35 print("Working on time: " + times(it) )
> 36 tc2 = wrf_user_getvar(a,"T2",it) ; T2 in Kelvin
> 37 tc2 = tc2-273.16 ; T2 in C
> 38
> 39 opts = res
> 40 opts at cnFillOn = True
> 41 opts at ContourParameters = (/23,37,1/)
> 42 ;opts at cnFillPalette = "BlGrYeOrReVi200"
> 43 gsn_define_colormap(wks,"BlGrYeOrReVi200")
> 44 contour_FLX = wrf_contour(a,wks,tc2,opts)
> 45 delete(opts)
> 46
> 47 plot = wrf_map_overlays(a,wks,contour_FLX,pltres,mpres)
> 48
> 49 end do ; END OF TIME LOOP
> 50
> 51 end
>
>
>
> Best regards
> Zoe
> ------------------------------
> *发件人:* Rick Brownrigg <brownrig at ucar.edu>
> *发送时间:* 2021年5月10日 21:45
> *收件人:* ZUO Ziping <zzuoaa at connect.ust.hk>
> *抄送:* ncl-talk at mailman.ucar.edu <ncl-talk at mailman.ucar.edu>
> *主题:* Re: [ncl-talk] problems when using the "res at cnFillPalette =
> "BlGrYeOrReVi200""
>
> Hi,
>
> I looked at the code where the error message arises, and this is indeed a
> bit of a mystery. If you might send me one of your WRF files, I'll try to
> run the script in the debugger to get a better idea of whats going on.
>
> Rick
>
>
> On Mon, May 10, 2021 at 12:10 AM ZUO Ziping via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
> Dear ncl-team,
>
> The other day when I was trying to use the colors in the "
> *BlGrYeOrReVi200*", I use the *res at cnFillPalette = "BlGrYeOrReVi200"*.
> However, it kept reminding me "*warning:ContourPlotSetValues: color index
> (204) exceeds size of palette, defaulting to foreground color for entry
> (12)*".
> But when I changed the instruction to
> *gsn_define_colormap(wks,"BlGrYeOrReVi200")*, it works fine. I'd like to
> ask the reason for these two instructions. The following is my full script.
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
>
> DATADir = "/disk/wrfout/"
> FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d04_2020-06* ")
> numFILES = dimsizes(FILES)
> print("numFILES = " + numFILES)
> print(FILES)
> print (" ")
>
> type = "pdf"
> wks = gsn_open_wks(type,"average_temp")
>
> res = True
> res at MainTitle = "REAL-TIME WRF"
> res at Footer = False
>
> pltres = True
> pltres at PanelPlot = True
> pltres at FramePlot = False
>
> mpres = True
> mpres at mpDataBaseVersion = "HighRes"
> mpres at mpGeophysicalLineColor = "Black"
> mpres at mpGridLineColor = "Black"
> mpres at mpDataResolution = "Finest"
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> a = addfiles(FILES+".nc","r")
>
> times = wrf_user_getvar(a,"times",-1) ; get all times in the file
> ntimes = dimsizes(times) ; number of times in the file
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> do k = 0,23,1
> meantemp = new((/162,213/),float)
> meantemp = 0
> temp = new((/ntimes,162,213/),float)
>
> do it = k,ntimes-1,24 ; TIME LOOP
> print("Working on time: " + times(it) )
> fi = addfile(FILES(it),"r")
> T_2 = fi ->T2 ; T2 in Kelvin
> tc2 = T_2-273.16 ; T2 in C
> temp(it,:,:) = tc2
> meantemp(:,:) = meantemp(:,:)+temp(it,:,:)
> end do
>
> meantemp(:,:) = meantemp(:,:)/30
>
> opts = res
> opts at cnFillOn = True
> opts at ContourParameters = (/23,37,1/)
> opts at cnFillPalette = "BlGrYeOrReVi200"
> contour_FLX = wrf_contour(a[k],wks,meantemp,opts)
> delete(opts)
>
> plot = wrf_map_overlays(a[k],wks,contour_FLX,pltres,mpres)
>
> end do ; END OF TIME LOOP
>
> end
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
> Thank you for your time!
>
> Best regards
> Zoe
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210510/b22bd759/attachment.html>
More information about the ncl-talk
mailing list