<div dir="ltr"><div><div>Hi David,<br><br></div>As near as I can tell from studying the code, you are correct -- early on in NCL's initialization, the list of available colormaps is loaded into a list. The reasons for doing this so early on strike me as a bit odd, because this is wasted effort in the case of scripts that never generate graphics. But there it is -- it would be a very low priority task to re-engineer this. Without knowing more about your constraints, I don't offhand have a work-around to suggest.<br><br></div>Rick<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 8, 2018 at 9:41 AM, Vollaro, David <span dir="ltr"><<a href="mailto:dvollaro@albany.edu" target="_blank">dvollaro@albany.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div id="m_-4807228219261407744divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I am having an issue having my NCL script "see" my custom-generated colortable. I run the script(below) to generate a custom color table, check my NCARG colortable path and check if the table-file is located in my path.
I then plot out the color table and then delete the .rgb file. The issue is that when I run the script I get the dreaded error
<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span>fatal:CvtStringToCmap:Unable to convert string "tstcolx" to ColorMap</span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">If I have an older version of tstcolx.rgb in the color_table dir then it uses that version instead of the newly created one. It almost seems like NCL generates a listing of all color tables when it is initially called
and uses that list when the script runs, ignoring any updates to the color_table directory. I am running NCL v6.3.0...Thank you</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Dave Vollaro</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>; coltab-make.ncl<br>
; date: 12/16<br>
; Will generate a cusstom color table, copy it to the colortab dir and plot it...<br>
<br>
<br>
<br>
undef("make_coltbl_custom")<br>
;;############################<wbr>##############################<wbr>#################;;<br>
function make_coltbl_custom(ofile:<wbr>string,T0:numeric,T[*],icol:<wbr>numeric,icolor0[3][*]:numeric,<wbr>opt:logical)<br>
; make_coltab_custom.ncl<br>
; DJV 10/16<br>
; This function will create a Color Table in NCL format <br>
;<br>
begin<br>
Tk0 = 273+T0 ;temp above which use grayscale<br>
output = ofile+".rgb"<br>
ncolor = 239<br>
<br>
; ******************** User Temp levels and Colors *************** <br>
Tk = T+273<br>
Tloc = new((/icol/),"integer")<br>
icolor = icolor0*255<br>
; *********** establish output color array and initialize **********<br>
colors = new((/ncolor,3/), "float")<br>
colors(:,0) = 0<br>
colors(:,1) = 0<br>
colors(:,2) = 0<br>
<br>
; white and black occupy locs 0,1<br>
;;############# Grayscale Definition Section (RGB 0-1) ################<br>
; Find the location of 1st user-override of IR table and set all values<br>
; warmer than Tk0 to grayscale<br>
<br>
if (Tk0.ge.242.5) then<br>
Bloc = floattoint((247.-Tk0)*2.) + 166<br>
end if<br>
if (Tk0.le.242.) then<br>
Bloc = floattoint(242.-Tk0) + 176<br>
end if<br>
print("11st color="+Bloc)</div>
<div>; fspan will interp vals from 1 to 0 over ncolor-2pts.<br>
colors(2:(Bloc-1), 0) = fspan(2,Bloc-1,Bloc-2)<br>
colors(2:(Bloc-1), 1) = fspan(2,Bloc-1,Bloc-2)<br>
colors(2:(Bloc-1), 2) = fspan(2,Bloc-1,Bloc-2)<br>
;;################### END GRAYSCALE DEFINITION ####################<br>
<br>
;;############# COLOR DEFINITION SECTION (RGB 0-1) ################<br>
do i=0,icol-1<br>
if (Tk(i).ge.242.5) then<br>
Tloc(i) = floattoint((247.-Tk(i))*2.) + 166<br>
end if<br>
if (Tk(i).le.242.) then<br>
Tloc(i) = floattoint(242.-Tk(i)) + 176<br>
end if<br>
if (i.eq.0.and.T(i).eq.999) then<br>
Tloc(i) = 0<br>
end if<br>
if (i.eq.icol-1.and.T(i).eq.999) then<br>
Tloc(i) = ncolor<br>
end if<br>
print(Bloc+" "+Tloc(i))<br>
colors( Bloc:(Tloc(i)-1), 0) = icolor(i,0)<br>
colors( Bloc:(Tloc(i)-1), 1) = icolor(i,1)<br>
colors( Bloc:(Tloc(i)-1), 2) = icolor(i,2)<br>
Bloc=Tloc(i)<br>
end do<br>
;;###################### END COLOR DEFINITION #####################<br>
<div><br>
print("ncolors="+ncolor)<br>
print("# r g b")<br>
fmtx = "3(f8.2,1x)"<br>
opt = True<br>
opt@title = "# r g b"<br>
opt@tspace = 10<br>
opt@fout = "fff"<br>
write_matrix (colors, fmtx, opt)<br>
sys_cmd = "echo ncolors="+ncolor+" > "+ofile+" ; cat "+opt@fout+" >>"+ofile<br>
system(sys_cmd)<br>
;;############################ clean up ##############################<wbr>######;;<br>
sys_cmd = "echo cleaning up "+" ; rm "+opt@fout+"; mv "+ofile+" "+ofile+".rgb"<br>
system(sys_cmd)<br>
return(opt)<br>
end</div>
<br>
<div>;#############################<wbr># MAIN PROGRAM ###########################;;<br>
begin<br>
out_type="X11"<br>
; ******************** User def color table section ****************<br>
rescolor = True ;If False then will use default IR coltbl<br>
T0 = 20 ;Grayscale Temp value(warmer temps use grayscale)<br>
numtemps = 3 ;Number of color temp values<br>
temps = (/0.,-40.,999./) ;User deff temp values to color 999=go to end<br>
colors0 = (/(/1,0,0/),(/0,1,0/),(/0,0,1/<wbr>)/) ;r,g,b 0-1<br>
if (rescolor) then<br>
colfile = make_coltbl_custom("~/NCL/<wbr>color_tables/tstcolx",T0,<wbr>temps,numtemps,colors0,<wbr>rescolor)<br>
color_table = "~/NCL/color_tables/tstcolx.<wbr>rgb"<br>
end if<br>
; ******************************<wbr>******************************<wbr>******<br>
print(color_table)<br>
system("ls -al ~/NCL/color_tables/tst*")<br>
system("env |grep NCARG")<br>
wks = gsn_open_wks(out_type, "ddd")<br>
gsn_define_colormap(wks,"<wbr>tstcolx") <br>
gsn_draw_colormap(wks) <br>
system("\rm -f ~/NCL/color_tables/tstcolx.rgb ")<br>
end</div>
<br>
</div>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>