1 | ; |
---|
2 | ; read GMT palette into IDL color/intervals system |
---|
3 | ; |
---|
4 | ; --> common color2 used by label_gmt.pro |
---|
5 | ; |
---|
6 | PRO lec_pal_gmt, var_name, c_anot_str, fmt, found, readpal |
---|
7 | @common |
---|
8 | @com_eg |
---|
9 | |
---|
10 | IF n_elements(idx_pal) EQ 0 THEN idx_pal = 0 |
---|
11 | |
---|
12 | found = 1 |
---|
13 | IF pal_type NE '2dom' THEN BEGIN |
---|
14 | ; read palette |
---|
15 | ; build palette name |
---|
16 | CASE pal_type OF |
---|
17 | 'bw': col = '_BW' |
---|
18 | 'col': col = '' |
---|
19 | ENDCASE |
---|
20 | CASE field.origin OF |
---|
21 | 'diff': col = col+'d' |
---|
22 | ELSE: |
---|
23 | ENDCASE |
---|
24 | |
---|
25 | CASE readpal OF |
---|
26 | 1: palname = 'palet_'+strupcase(fldatt.assos)+col+'.cpt' |
---|
27 | 2: palname = 'palet_frequency_pwr'+col+'.cpt' |
---|
28 | 3: palname = 'palet_DIVISION.cpt' |
---|
29 | ELSE: palname = 'palet_'+strupcase(fldatt.assos)+col+'.cpt' |
---|
30 | ENDCASE |
---|
31 | ; if exist, read |
---|
32 | |
---|
33 | file_cpt = hom_def+'palettes/'+palname |
---|
34 | spawn, 'ls '+file_cpt, line |
---|
35 | line = strcompress(strtrim(line[0], 2)) |
---|
36 | length = strlen(line) |
---|
37 | |
---|
38 | IF length EQ 0 THEN BEGIN |
---|
39 | print, ' No palette found for ', var_name |
---|
40 | print, ' (', file_cpt, ')' |
---|
41 | found = 0 |
---|
42 | ENDIF ELSE BEGIN |
---|
43 | |
---|
44 | ; decode palette |
---|
45 | print, ' Reading palette : ', file_cpt |
---|
46 | print, ' ' |
---|
47 | spawn, 'awk -f '+hom_idl+'procs/awk_palette '+file_cpt, line |
---|
48 | line = strcompress(strtrim(line, 2)) |
---|
49 | length = strlen(line) |
---|
50 | ncont = n_elements(line) |
---|
51 | read_array = fltarr(4, ncont) |
---|
52 | i = 0 |
---|
53 | FOR i = 0, ncont-1 DO BEGIN |
---|
54 | read_array[0, i] = str_sep(line[i], ' ') |
---|
55 | ENDFOR |
---|
56 | levels_gmt = fltarr(ncont) |
---|
57 | levels_gmt = [-999999.0, reform(read_array[0, *], ncont)] |
---|
58 | ; build IDL palette in lct=<nn> |
---|
59 | red = reform(long(read_array[1, *]), ncont) |
---|
60 | green = reform(long(read_array[2, *]), ncont) |
---|
61 | blue = reform(long(read_array[3, *]), ncont) |
---|
62 | |
---|
63 | ; compute format fmt (uses tag 'piso' in color palet file) |
---|
64 | |
---|
65 | spawn, 'grep piso '+file_cpt, line |
---|
66 | IF n_elements(line) NE 0 AND (strpos(line, 'piso'))(0) NE -1 THEN BEGIN |
---|
67 | iso = abs(float(line[0])) |
---|
68 | IF iso EQ 0.1 THEN BEGIN |
---|
69 | fmt = '(f6.1)' |
---|
70 | ENDIF ELSE IF iso EQ .2 THEN BEGIN |
---|
71 | fmt = '(f6.1)' |
---|
72 | ENDIF ELSE IF iso EQ .05 THEN BEGIN |
---|
73 | fmt = '(f6.2)' |
---|
74 | ENDIF ELSE IF iso EQ .02 THEN BEGIN |
---|
75 | fmt = '(f6.2)' |
---|
76 | ENDIF ELSE IF iso LT .1 THEN BEGIN |
---|
77 | fmt = '(f6.3)' |
---|
78 | ENDIF ELSE IF iso LE .25 THEN BEGIN |
---|
79 | fmt = '(f6.3)' |
---|
80 | ENDIF ELSE IF iso LT 1 THEN BEGIN |
---|
81 | fmt = '(f5.1)' |
---|
82 | ENDIF ELSE BEGIN |
---|
83 | fmt = '(f5.0)' |
---|
84 | ENDELSE |
---|
85 | IF long(iso) NE 0 THEN BEGIN |
---|
86 | IF iso/long(iso) NE 1 THEN fmt = '(f5.1)' |
---|
87 | ENDIF |
---|
88 | ENDIF ELSE begin |
---|
89 | print, ' *** WARNING !!!! piso missing in file_cpt' |
---|
90 | |
---|
91 | ENDELSE |
---|
92 | |
---|
93 | IF idx_pal EQ 0 THEN BEGIN |
---|
94 | ; add black as first color |
---|
95 | red = [0, red] |
---|
96 | green = [0, green] |
---|
97 | blue = [0, blue] |
---|
98 | ENDIF |
---|
99 | |
---|
100 | tvlct, red, green, blue, idx_pal |
---|
101 | |
---|
102 | ncont_gmt = ncont+1 |
---|
103 | coul_gmt = findgen(ncont_gmt)+idx_pal |
---|
104 | max_gmt = levels_gmt(ncont_gmt-1) |
---|
105 | |
---|
106 | IF (idx_pal + ncont) GT 100 THEN BEGIN |
---|
107 | print, ' **** Warning idx_pal gt 100 : palette no updated' |
---|
108 | ENDIF ELSE BEGIN |
---|
109 | ; idx_pal = idx_pal + ncont + 1 |
---|
110 | ENDELSE |
---|
111 | |
---|
112 | ; annotation string |
---|
113 | c_anot_str = string(levels_gmt, format = fmt) |
---|
114 | |
---|
115 | found = 1 |
---|
116 | ENDELSE |
---|
117 | ENDIF |
---|
118 | |
---|
119 | |
---|
120 | END |
---|