[2] | 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 | ; CONT_THICK: l''epaisseur du trait pour tracer les |
---|
| 20 | ; continents. par defaut c''est 1. |
---|
| 21 | ; |
---|
| 22 | ; OUTPUTS: none |
---|
| 23 | ; |
---|
| 24 | ; COMMON BLOCKS:common.pro |
---|
| 25 | ; |
---|
| 26 | ; SIDE EFFECTS: |
---|
| 27 | ; |
---|
| 28 | ; RESTRICTIONS: |
---|
| 29 | ; |
---|
| 30 | ; EXAMPLE: |
---|
| 31 | ; |
---|
| 32 | ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
| 33 | ; |
---|
| 34 | ;- |
---|
| 35 | ;------------------------------------------------------------ |
---|
| 36 | ;------------------------------------------------------------ |
---|
| 37 | ;------------------------------------------------------------ |
---|
| 38 | PRO tracemask, maskentree, xin, yin, CONT_THICK = cont_thick, OVERPLOT = overplot, _extra = ex |
---|
| 39 | xentree = xin |
---|
| 40 | yentree = yin |
---|
| 41 | if keyword_set(overplot) then return |
---|
| 42 | @common |
---|
| 43 | tempsun = systime(1) ; pour key_performance |
---|
| 44 | ; on s''afranchit des problemes de bord: |
---|
| 45 | tempdeux = systime(1) ; pour key_performance =2 |
---|
| 46 | tailleentree = size(maskentree) |
---|
| 47 | nx = tailleentree[1]+1 |
---|
| 48 | ny = tailleentree[2]+1 |
---|
| 49 | ; on agrandi le mask de une colonne a gauche et de une colonne a droite. |
---|
| 50 | mask = intarr(tailleentree[1]+1, tailleentree[2]+1) |
---|
| 51 | mask[1:tailleentree[1], 1:tailleentree[2]] = maskentree |
---|
| 52 | ; les 2 premieres colonnes sont identiques |
---|
| 53 | mask[0, 1:tailleentree[2]] = maskentree[0, *] |
---|
| 54 | ; les 2 premieres lignes sont identiques |
---|
| 55 | mask[1:tailleentree[1], 0] = maskentree[*, 0] |
---|
| 56 | ; on calcul la position suivant x des points qui seviront a tracer le |
---|
| 57 | ; masque. ils sont situes entre chaque points du masque, sauf pour la |
---|
| 58 | ; derniere colonne que l''on ne peut pas calculer et que l''on met |
---|
| 59 | ; donc a max(!x.range) |
---|
| 60 | xrange = !x.range[sort(!x.range)] ; si reverse_x est utilise! |
---|
| 61 | xentree = .5*(xentree+shift(xentree, -1, 0)) |
---|
| 62 | IF not keyword_set(overplot) THEN xentree[nx-2, *] = xrange[1] $ |
---|
| 63 | ELSE xentree[nx-2, *] = xentree[nx-3, *] |
---|
| 64 | ; on seuil |
---|
| 65 | xentree = xrange[0] > xentree < xrange[1] |
---|
| 66 | ; on agrandit le tableau |
---|
| 67 | xf = fltarr(nx, ny) |
---|
| 68 | xf[1:nx-1, 1:ny-1] = xentree |
---|
| 69 | IF not keyword_set(overplot) THEN xf[0, *] = xrange[0] $ |
---|
| 70 | ELSE xf[0, *] = xf[1, *] |
---|
| 71 | xf[1:nx-1, 0] = xentree[*, 0] |
---|
| 72 | ; |
---|
| 73 | yinverse = yentree[0, 0] GT yentree[0, ny-2] |
---|
| 74 | yrange = !y.range[sort(!y.range)] |
---|
| 75 | yentree = .5*(yentree+shift(yentree, 0, -1)) |
---|
| 76 | IF not keyword_set(overplot) THEN BEGIN |
---|
| 77 | if yinverse then yentree[*, ny-2] = yrange[0] ELSE yentree[*, ny-2] = yrange[1] |
---|
| 78 | ENDIF ELSE yentree[*, ny-2] = yentree[*, ny-3] |
---|
| 79 | yentree = yrange[0] > yentree < yrange[1] |
---|
| 80 | yf = fltarr(nx, ny) |
---|
| 81 | yf[1:nx-1, 1:ny-1] = yentree |
---|
| 82 | yf[0, 1:ny-1] = yentree[0, *] |
---|
| 83 | IF not keyword_set(overplot) THEN BEGIN |
---|
| 84 | if yinverse then yf[*, 0] = yrange[1] ELSE yf[*, 0] = yrange[0] |
---|
| 85 | ENDIF ELSE yentree[*, 0] = yentree[*, 1] |
---|
| 86 | ; |
---|
| 87 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 88 | print, 'temps tracemask: determination du mask et des ses coordonnes', systime(1)-tempdeux |
---|
| 89 | ; |
---|
| 90 | ; on trace les segments verticaux: |
---|
| 91 | ; |
---|
| 92 | tempdeux = systime(1) ; pour key_performance =2 |
---|
| 93 | liste = where(mask+shift(mask, -1, 0) EQ 1) |
---|
| 94 | IF liste[0] NE -1 THEN BEGIN |
---|
| 95 | ; on recupere lx et ly qui sont les indices ds un tableau 2d des |
---|
| 96 | ; points donnes par liste |
---|
| 97 | ly = liste/nx & lx = temporary(liste)-nx*ly |
---|
| 98 | indice = where(ly NE 0) ; on ne prend pas les points concernant |
---|
| 99 | ; la premiere ligne car ds ce cas le pt j-1 n''est pas definit |
---|
| 100 | if indice[0] NE -1 then begin |
---|
| 101 | lx = lx[indice] & ly = ly[temporary(indice)] |
---|
| 102 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 103 | print, 'temps tracemask: liste traits verticaux', systime(1)-tempdeux |
---|
| 104 | tempdeux = systime(1) ; pour key_performance =2 |
---|
| 105 | ; boucle sur les points concernes et trace du segment |
---|
| 106 | ; rq: on utilise plots au lieu de plot car plots est bcp plus rapide. |
---|
| 107 | for pt = 0, n_elements(lx)-1 do BEGIN |
---|
| 108 | i = lx[pt] & j = ly[pt] |
---|
| 109 | plots, [xf[i, j-1], xf[i, j]], [yf[i, j-1], yf[i, j]] $ |
---|
| 110 | , color=c_cote,thick=cont_thick, _extra = ex |
---|
| 111 | if pt LT 5 then begin |
---|
| 112 | endif |
---|
| 113 | endfor |
---|
| 114 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 115 | print, 'temps tracemask: trace traits verticaux', systime(1)-tempdeux |
---|
| 116 | endif |
---|
| 117 | ENDIF |
---|
| 118 | ; |
---|
| 119 | ; on trace les segments horizontaux: |
---|
| 120 | ; |
---|
| 121 | tempdeux = systime(1) ; pour key_performance =2 |
---|
| 122 | liste = where(mask+shift(mask, 0, -1) EQ 1) |
---|
| 123 | IF liste[0] NE -1 THEN BEGIN |
---|
| 124 | ly = liste/nx & lx = temporary(liste)-nx*ly |
---|
| 125 | indice = where(lx NE 0) ; on ne prend pas les points de la premiere colonne |
---|
| 126 | if indice[0] EQ -1 then return |
---|
| 127 | lx = lx[indice] & ly = ly[temporary(indice)] |
---|
| 128 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 129 | print, 'temps tracemask: liste traits horizontaux', systime(1)-tempdeux |
---|
| 130 | tempdeux = systime(1) ; pour key_performance =2 |
---|
| 131 | for pt = 0, n_elements(lx)-1 do BEGIN |
---|
| 132 | i = lx[pt] & j = ly[pt] |
---|
| 133 | plots, [xf[i-1, j], xf[i, j]], [yf[i-1, j], yf[i, j]] $ |
---|
| 134 | , color=c_cote,thick=cont_thick, _extra = ex |
---|
| 135 | endfor |
---|
| 136 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 137 | print, 'temps tracemask: trace traits horizontaux', systime(1)-tempdeux |
---|
| 138 | endif |
---|
| 139 | ; |
---|
| 140 | ; |
---|
| 141 | if keyword_set(key_performance) THEN print, 'temps tracemask', systime(1)-tempsun |
---|
| 142 | |
---|
| 143 | return |
---|
| 144 | end |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | |
---|