1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME:tracemask |
---|
6 | ; |
---|
7 | ; PURPOSE:dessiner des contour d''un mask |
---|
8 | ; |
---|
9 | ; CATEGORY:plus simple que tracecote, car ne s''occuppe pas du type de |
---|
10 | ; projection et de la periodicite de la grille |
---|
11 | ; |
---|
12 | ; CALLING SEQUENCE: tracemask, maskentree, xentree, yentree |
---|
13 | ; |
---|
14 | ; INPUTS:maskentree, xentree, yentree tableaux 2d specifiant le mask |
---|
15 | ; et ses coordonees en longitude te latitude. |
---|
16 | ; |
---|
17 | ; KEYWORD PARAMETERS: |
---|
18 | ; |
---|
19 | ; COAST_COLOR: the color of the coastline. |
---|
20 | ; defaut value is 0 => black |
---|
21 | ; |
---|
22 | ; COAST_THICK: l''epaisseur du trait pour tracer les |
---|
23 | ; continents. par defaut c''est 1. |
---|
24 | ; |
---|
25 | ; OUTPUTS: none |
---|
26 | ; |
---|
27 | ; COMMON BLOCKS:common.pro |
---|
28 | ; |
---|
29 | ; SIDE EFFECTS: |
---|
30 | ; |
---|
31 | ; RESTRICTIONS: |
---|
32 | ; |
---|
33 | ; EXAMPLE: |
---|
34 | ; |
---|
35 | ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
36 | ; |
---|
37 | ;- |
---|
38 | ;------------------------------------------------------------ |
---|
39 | ;------------------------------------------------------------ |
---|
40 | ;------------------------------------------------------------ |
---|
41 | PRO tracemask, maskentree, xin, yin, COAST_COLOR = coast_color, COAST_THICK = coast_thick, OVERPLOT = overplot, _extra = ex |
---|
42 | ; |
---|
43 | ; |
---|
44 | compile_opt idl2, strictarrsubs |
---|
45 | ; |
---|
46 | if keyword_set(overplot) then return |
---|
47 | ;--------------------------------------------------------- |
---|
48 | @cm_general |
---|
49 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
50 | @updatekwd |
---|
51 | ENDIF |
---|
52 | ;--------------------------------------------------------- |
---|
53 | tempsun = systime(1) ; pour key_performance |
---|
54 | ; on s''afranchit des problemes de bord: |
---|
55 | tempdeux = systime(1) ; pour key_performance =2 |
---|
56 | tailleentree = size(maskentree) |
---|
57 | nx = tailleentree[1]+1 |
---|
58 | ny = tailleentree[2]+1 |
---|
59 | ; we check the input axis |
---|
60 | IF n_elements(xin) EQ 0 THEN xentree = findgen(nx-1) ELSE xentree = xin |
---|
61 | IF (size(xentree))[0] EQ 1 THEN xentree = xentree#replicate(1,ny-1) |
---|
62 | IF n_elements(yin) EQ 0 THEN yentree = findgen(ny-1) ELSE yentree = yin |
---|
63 | IF (size(yentree))[0] EQ 1 THEN yentree = replicate(1,nx-1)#yentree |
---|
64 | ; on agrandi le mask de une colonne a gauche et de une colonne en bas |
---|
65 | mask = intarr(tailleentree[1]+1, tailleentree[2]+1) |
---|
66 | mask[1:tailleentree[1], 1:tailleentree[2]] = maskentree |
---|
67 | ; les 2 premieres colonnes sont identiques |
---|
68 | mask[0, 1:tailleentree[2]] = maskentree[0, *] |
---|
69 | ; les 2 premieres lignes sont identiques |
---|
70 | mask[1:tailleentree[1], 0] = maskentree[*, 0] |
---|
71 | ; on calcul la position suivant x des points qui seviront a tracer le |
---|
72 | ; masque. ils sont situes entre chaque points du masque, sauf pour la |
---|
73 | ; derniere colonne que l''on ne peut pas calculer et que l''on met |
---|
74 | ; donc a max(!x.range) |
---|
75 | xrange = !x.range[sort(!x.range)] ; si reverse_x est utilise! |
---|
76 | xentree = .5*(xentree+shift(xentree, -1, 0)) |
---|
77 | IF not keyword_set(overplot) THEN xentree[nx-2, *] = xrange[1] $ |
---|
78 | ELSE xentree[nx-2, *] = xentree[nx-3, *] |
---|
79 | ; on seuil |
---|
80 | xentree = xrange[0] > xentree < xrange[1] |
---|
81 | ; on agrandit le tableau |
---|
82 | xf = fltarr(nx, ny) |
---|
83 | xf[1:nx-1, 1:ny-1] = xentree |
---|
84 | IF not keyword_set(overplot) THEN xf[0, *] = xrange[0] $ |
---|
85 | ELSE xf[0, *] = xf[1, *] |
---|
86 | xf[1:nx-1, 0] = xentree[*, 0] |
---|
87 | ; |
---|
88 | yinverse = yentree[0, 0] GT yentree[0, ny-2] |
---|
89 | yrange = !y.range[sort(!y.range)] |
---|
90 | yentree = .5*(yentree+shift(yentree, 0, -1)) |
---|
91 | IF not keyword_set(overplot) THEN BEGIN |
---|
92 | if yinverse then yentree[*, ny-2] = yrange[0] ELSE yentree[*, ny-2] = yrange[1] |
---|
93 | ENDIF ELSE yentree[*, ny-2] = yentree[*, ny-3] |
---|
94 | yentree = yrange[0] > yentree < yrange[1] |
---|
95 | yf = fltarr(nx, ny) |
---|
96 | yf[1:nx-1, 1:ny-1] = yentree |
---|
97 | yf[0, 1:ny-1] = yentree[0, *] |
---|
98 | IF not keyword_set(overplot) THEN BEGIN |
---|
99 | if yinverse then yf[*, 0] = yrange[1] ELSE yf[*, 0] = yrange[0] |
---|
100 | ENDIF ELSE yentree[*, 0] = yentree[*, 1] |
---|
101 | ; |
---|
102 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
103 | print, 'temps tracemask: determination du mask et des ses coordonnes', systime(1)-tempdeux |
---|
104 | ; |
---|
105 | ; on trace les segments verticaux: |
---|
106 | ; |
---|
107 | tempdeux = systime(1) ; pour key_performance =2 |
---|
108 | liste = where(mask+shift(mask, -1, 0) EQ 1) |
---|
109 | IF liste[0] NE -1 THEN BEGIN |
---|
110 | ; on recupere lx et ly qui sont les indices ds un tableau 2d des |
---|
111 | ; points donnes par liste |
---|
112 | ly = liste/nx & lx = temporary(liste)-nx*ly |
---|
113 | indice = where(ly NE 0) ; on ne prend pas les points concernant |
---|
114 | ; la premiere ligne car ds ce cas le pt j-1 n''est pas definit |
---|
115 | if indice[0] NE -1 then begin |
---|
116 | lx = lx[indice] & ly = ly[temporary(indice)] |
---|
117 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
118 | print, 'temps tracemask: liste traits verticaux', systime(1)-tempdeux |
---|
119 | tempdeux = systime(1) ; pour key_performance =2 |
---|
120 | ; boucle sur les points concernes et trace du segment |
---|
121 | ; rq: on utilise plots au lieu de plot car plots est bcp plus rapide. |
---|
122 | for pt = 0L, n_elements(lx)-1 do BEGIN |
---|
123 | i = lx[pt] & j = ly[pt] |
---|
124 | plots, [xf[i, j-1], xf[i, j]], [yf[i, j-1], yf[i, j]] $ |
---|
125 | , color = coast_color, thick = coast_thick, _extra = ex |
---|
126 | if pt LT 5 then begin |
---|
127 | endif |
---|
128 | endfor |
---|
129 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
130 | print, 'temps tracemask: trace traits verticaux', systime(1)-tempdeux |
---|
131 | endif |
---|
132 | ENDIF |
---|
133 | ; |
---|
134 | ; on trace les segments horizontaux: |
---|
135 | ; |
---|
136 | tempdeux = systime(1) ; pour key_performance =2 |
---|
137 | liste = where(mask+shift(mask, 0, -1) EQ 1) |
---|
138 | IF liste[0] NE -1 THEN BEGIN |
---|
139 | ly = liste/nx & lx = temporary(liste)-nx*ly |
---|
140 | indice = where(lx NE 0) ; on ne prend pas les points de la premiere colonne |
---|
141 | if indice[0] EQ -1 then return |
---|
142 | lx = lx[indice] & ly = ly[temporary(indice)] |
---|
143 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
144 | print, 'temps tracemask: liste traits horizontaux', systime(1)-tempdeux |
---|
145 | tempdeux = systime(1) ; pour key_performance =2 |
---|
146 | for pt = 0L, n_elements(lx)-1 do BEGIN |
---|
147 | i = lx[pt] & j = ly[pt] |
---|
148 | plots, [xf[i-1, j], xf[i, j]], [yf[i-1, j], yf[i, j]] $ |
---|
149 | , color = coast_color, thick = coast_thick, _extra = ex |
---|
150 | endfor |
---|
151 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
152 | print, 'temps tracemask: trace traits horizontaux', systime(1)-tempdeux |
---|
153 | endif |
---|
154 | ; |
---|
155 | ; |
---|
156 | if keyword_set(key_performance) THEN print, 'temps tracemask', systime(1)-tempsun |
---|
157 | |
---|
158 | return |
---|
159 | end |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | |
---|
164 | |
---|