; ; read GMT palette into IDL color/intervals system ; ; --> common color2 used by label_gmt.pro ; PRO lec_pal_gmt, var_name, c_anot_str, fmt, found, readpal @common @com_eg IF n_elements(idx_pal) EQ 0 THEN idx_pal = 0 found = 1 IF pal_type NE '2dom' THEN BEGIN ; read palette ; build palette name CASE pal_type OF 'bw': col = '_BW' 'col': col = '' ENDCASE CASE field.origin OF 'diff': col = col+'d' ELSE: ENDCASE CASE readpal OF 1: palname = 'palet_'+strupcase(fldatt.assos)+col+'.cpt' 2: palname = 'palet_frequency_pwr'+col+'.cpt' 3: palname = 'palet_DIVISION.cpt' ELSE: palname = 'palet_'+strupcase(fldatt.assos)+col+'.cpt' ENDCASE ; if exist, read file_cpt = hom_def+'palettes/'+palname spawn, 'ls '+file_cpt, line line = strcompress(strtrim(line[0], 2)) length = strlen(line) IF length EQ 0 THEN BEGIN print, ' No palette found for ', var_name print, ' (', file_cpt, ')' found = 0 ENDIF ELSE BEGIN ; decode palette print, ' Reading palette : ', file_cpt print, ' ' spawn, 'awk -f '+hom_idl+'procs/awk_palette '+file_cpt, line line = strcompress(strtrim(line, 2)) length = strlen(line) ncont = n_elements(line) read_array = fltarr(4, ncont) i = 0 FOR i = 0, ncont-1 DO BEGIN read_array[0, i] = str_sep(line[i], ' ') ENDFOR levels_gmt = fltarr(ncont) levels_gmt = [-999999.0, reform(read_array[0, *], ncont)] ; build IDL palette in lct= red = reform(long(read_array[1, *]), ncont) green = reform(long(read_array[2, *]), ncont) blue = reform(long(read_array[3, *]), ncont) ; compute format fmt (uses tag 'piso' in color palet file) spawn, 'grep piso '+file_cpt, line IF n_elements(line) NE 0 AND (strpos(line, 'piso'))(0) NE -1 THEN BEGIN iso = abs(float(line[0])) IF iso EQ 0.1 THEN BEGIN fmt = '(f6.1)' ENDIF ELSE IF iso EQ .2 THEN BEGIN fmt = '(f6.1)' ENDIF ELSE IF iso EQ .05 THEN BEGIN fmt = '(f6.2)' ENDIF ELSE IF iso EQ .02 THEN BEGIN fmt = '(f6.2)' ENDIF ELSE IF iso LT .1 THEN BEGIN fmt = '(f6.3)' ENDIF ELSE IF iso LE .25 THEN BEGIN fmt = '(f6.3)' ENDIF ELSE IF iso LT 1 THEN BEGIN fmt = '(f5.1)' ENDIF ELSE BEGIN fmt = '(f5.0)' ENDELSE IF long(iso) NE 0 THEN BEGIN IF iso/long(iso) NE 1 THEN fmt = '(f5.1)' ENDIF ENDIF ELSE begin print, ' *** WARNING !!!! piso missing in file_cpt' ENDELSE IF idx_pal EQ 0 THEN BEGIN ; add black as first color red = [0, red] green = [0, green] blue = [0, blue] ENDIF tvlct, red, green, blue, idx_pal ncont_gmt = ncont+1 coul_gmt = findgen(ncont_gmt)+idx_pal max_gmt = levels_gmt(ncont_gmt-1) IF (idx_pal + ncont) GT 100 THEN BEGIN print, ' **** Warning idx_pal gt 100 : palette no updated' ENDIF ELSE BEGIN ; idx_pal = idx_pal + ncont + 1 ENDELSE ; annotation string c_anot_str = string(levels_gmt, format = fmt) found = 1 ENDELSE ENDIF END