;***********************************************************************; ; This function returns the list of colormap names. ; This can be used to test for valid colormap names. ;***********************************************************************; undef("get_colormap_names") function get_colormap_names() local cmap_dirs, nfiles, ndirs, cmaps, i, j, tmp_files, tmp_names begin ;---Get the list of color map directories cmap_dirs = str_split(ncargpath("colormaps"),":") ndirs = dimsizes(cmap_dirs) max_files = 500 cmaps = new(max_files,string) nfiles = 0 do i=0,ndirs-1 tmp_files := systemfunc("ls -1 " + cmap_dirs(i)) ;---Skip directory if empty if(ismissing(tmp_files(0))) then continue end if nt = dimsizes(tmp_files) do j=0,nt-1 ;---Only look for files with xxxx.yyy names. They are not valid color map files otherwise. tmp_names := str_split(tmp_files(j),".") if(dimsizes(tmp_names).lt.2) then continue end if cmaps(nfiles) = str_join(tmp_names(0:dimsizes(tmp_names)-2),".") nfiles = nfiles + 1 if(nfiles.ge.max_files) then print("get_colormap_names: warning: reached maximum limit of color maps") print("Will only return " + max_files + " color map names.") break end if end do if(nfiles.ge.max_files) then break end if end do return(cmaps(0:nfiles-1)) end