[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
[150] | 5 | ; @file_comments |
---|
[163] | 6 | ; Build the triangulation for a E-grid type |
---|
[2] | 7 | ; |
---|
[150] | 8 | ; @categories |
---|
[157] | 9 | ; Graphics |
---|
[150] | 10 | ; |
---|
[163] | 11 | ; @param MASKENTREE {in}{optional}{type=2d array} |
---|
[150] | 12 | ; It is a 2d array which will serve to mask the field we will trace after with CONTOUR, |
---|
| 13 | ; ...TRIANGULATION=triangule(mask) |
---|
| 14 | ; If this argument is not specified, the function use tmask |
---|
| 15 | ; |
---|
| 16 | ; @keyword BASIC |
---|
| 17 | ; Specify that the mask is on a basic grid (use the triangulation for vertical cuts and hovmoellers) |
---|
| 18 | ; |
---|
[163] | 19 | ; @keyword COINMONTE {type=array} |
---|
| 20 | ; To obtain the array of "ascending land corner" to be treated with |
---|
[150] | 21 | ; completecointerre.pro in the variable array instead of make it pass by the global |
---|
| 22 | ; variable twin_corners_up. |
---|
[2] | 23 | ; |
---|
[163] | 24 | ; @keyword COINDESCEND {type=array} |
---|
| 25 | ; See COINMONTE |
---|
[2] | 26 | ; |
---|
[150] | 27 | ; @keyword SHIFTED |
---|
[2] | 28 | ; |
---|
[150] | 29 | ; @uses |
---|
| 30 | ; common.pro |
---|
| 31 | ; |
---|
| 32 | ; @history |
---|
[157] | 33 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[2] | 34 | ; june 2001 |
---|
[150] | 35 | ; |
---|
| 36 | ; @version |
---|
| 37 | ; $Id$ |
---|
| 38 | ; |
---|
| 39 | ; @todo |
---|
| 40 | ; seb L.152->153 je ne pense pas que ce soit ce que tu voulais dire mais |
---|
| 41 | ; c'est la traduction de ce qu'il y avait écrit. Correction si besoin. |
---|
[2] | 42 | ;- |
---|
| 43 | ;------------------------------------------------------------ |
---|
| 44 | ;------------------------------------------------------------ |
---|
| 45 | ;------------------------------------------------------------ |
---|
| 46 | FUNCTION triangule_e, maskentree, COINMONTE = coinmonte, COINDESCEND = coindescend $ |
---|
[29] | 47 | , SHIFTED = shifted, BASIC = basic |
---|
| 48 | ;--------------------------------------------------------- |
---|
[114] | 49 | ; |
---|
| 50 | compile_opt idl2, strictarrsubs |
---|
| 51 | ; |
---|
[29] | 52 | @cm_4mesh |
---|
| 53 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 54 | @updatenew |
---|
| 55 | ENDIF |
---|
| 56 | ;--------------------------------------------------------- |
---|
[150] | 57 | tempsun = systime(1) ; For key_performance |
---|
[2] | 58 | ;------------------------------------------------------------ |
---|
[150] | 59 | ; Is the mask given or do we have to take tmask? |
---|
[2] | 60 | ;------------------------------------------------------------ |
---|
| 61 | ; |
---|
| 62 | msk = maskentree |
---|
| 63 | sizem = size(msk) |
---|
| 64 | nx = sizem[1] |
---|
| 65 | ny = sizem[2] |
---|
| 66 | ;------------------------------------------------------------ |
---|
[29] | 67 | if keyword_set(key_periodic)*(nx EQ jpi) $ |
---|
| 68 | AND NOT keyword_set(basic) then BEGIN |
---|
[2] | 69 | msk = [msk, msk[0, *]] |
---|
| 70 | nx = nx+1 |
---|
| 71 | ENDIF |
---|
| 72 | ; |
---|
| 73 | ; we will find the diamond that must be cut in two triangle using the |
---|
| 74 | ; horizontal diagonal. |
---|
| 75 | ; |
---|
| 76 | index = lindgen(nx, ny) |
---|
| 77 | index = index[0:nx-2, 1:ny-2] |
---|
| 78 | if n_elements(shifted) EQ 0 then shifted = 1 |
---|
| 79 | oddeven = (index/nx+1-shifted) MOD 2 |
---|
| 80 | msk1 = msk[index] |
---|
| 81 | msk2 = msk[index+1] |
---|
| 82 | sum = msk[index-nx+oddeven]+msk[index+nx+oddeven] |
---|
| 83 | sum1 = msk2+sum |
---|
| 84 | sum2 = msk1+sum |
---|
| 85 | ; |
---|
| 86 | ; horizontal |
---|
| 87 | ; |
---|
| 88 | singularpoint = where((msk1 EQ 0 AND sum1 EQ 3) OR (msk1 EQ 1 AND sum1 EQ 0) $ |
---|
| 89 | OR (msk2 EQ 0 AND sum2 EQ 3) OR (msk2 EQ 1 AND sum2 EQ 0) $ |
---|
| 90 | OR (sum EQ 0 AND (msk1+msk2) EQ 2) ) |
---|
| 91 | if singularpoint[0] NE -1 then begin |
---|
| 92 | horizontal = index[singularpoint] |
---|
| 93 | triang = definetri_e(nx, ny, horizontal, SHIFTED = shifted) |
---|
| 94 | ENDIF ELSE triang = definetri_e(nx, ny, SHIFTED = shifted) |
---|
| 95 | ; coinmont = index[where(sum EQ 2 AND (msk1+msk2) EQ 0)] |
---|
| 96 | ; coindesc = index[where(sum EQ 0 AND (msk1+msk2) EQ 2)] |
---|
| 97 | ; |
---|
| 98 | ; we keep only the triangles which are outside the land |
---|
| 99 | ; but for some reasons we will in fact delete the land diamond |
---|
| 100 | ; |
---|
| 101 | ; allrecinland = where(sum1+msk1 EQ 0) |
---|
| 102 | ; indexallinland = index[allrecinland] |
---|
| 103 | ; otherrec = (lindgen(nx, ny))[0:nx-2, 1:ny-2] |
---|
| 104 | ; otherrec = different(otherrec, indexallinland) |
---|
| 105 | ; ; |
---|
| 106 | ; index = lindgen(nx, ny) |
---|
| 107 | ; index = index[0:nx-3, 2:ny-3] |
---|
| 108 | ; out = inter(index, indexallinland) |
---|
| 109 | ; IF out[0] NE -1 THEN begin |
---|
| 110 | ; out = inter(out+1, indexallinland) |
---|
| 111 | ; IF out[0] NE -1 THEN begin |
---|
| 112 | ; out = out-1 |
---|
| 113 | ; oddeven = (out/nx+1-shifted) MOD 2 |
---|
| 114 | ; out = inter(out-nx+oddeven, otherrec) |
---|
| 115 | ; IF out[0] NE -1 THEN begin |
---|
| 116 | ; out = inter(out+2*nx, otherrec) |
---|
| 117 | ; IF out[0] NE -1 THEN begin |
---|
| 118 | ; out = out-(nx+((out/nx+shifted) MOD 2)) |
---|
| 119 | ; endif |
---|
| 120 | ; endif |
---|
| 121 | ; endif |
---|
| 122 | ; ENDIF |
---|
| 123 | ; help, out |
---|
| 124 | ; ; |
---|
| 125 | ; index = lindgen(nx, ny) |
---|
| 126 | ; index = index[0:nx-3, 2:ny-3] |
---|
| 127 | ; out = inter(index, otherrec) |
---|
| 128 | ; IF out[0] NE -1 THEN begin |
---|
| 129 | ; out = inter(out+1, otherrec) |
---|
| 130 | ; IF out[0] NE -1 THEN begin |
---|
| 131 | ; out = out-1 |
---|
| 132 | ; oddeven = (out/nx+1-shifted) MOD 2 |
---|
| 133 | ; out = inter(out-nx+oddeven, indexallinland) |
---|
| 134 | ; IF out[0] NE -1 THEN begin |
---|
| 135 | ; out = inter(out+2*nx, indexallinland) |
---|
| 136 | ; IF out[0] NE -1 THEN begin |
---|
| 137 | ; out = out-(nx+((out/nx+shifted) MOD 2)) |
---|
| 138 | ; endif |
---|
| 139 | ; endif |
---|
| 140 | ; endif |
---|
| 141 | ; endif |
---|
| 142 | ; help, out |
---|
| 143 | ; ; |
---|
| 144 | ; IF out[0] EQ -1 THEN out = different(indexallinland, out) ELSE out = indexallinland |
---|
| 145 | ; triout = numtri(out, nx, ny) |
---|
| 146 | ; triout = [triout, triout+1] |
---|
| 147 | ; goodtri = lindgen(2*(nx-1)*(ny-1)) |
---|
| 148 | ; goodtri = different(goodtri, triout) |
---|
| 149 | ; triang = triang[*, temporary(goodtri)] |
---|
| 150 | |
---|
| 151 | ; ; |
---|
| 152 | ;------------------------------------------------------------ |
---|
[150] | 153 | ; When key_periodic equal 1, triang is a list of indexes's array which |
---|
| 154 | ; have a surplus column. |
---|
| 155 | ; We have to put it back to the initial matrix by putting indexes of |
---|
| 156 | ; the last column equal to these of the last column... |
---|
[2] | 157 | ;------------------------------------------------------------ |
---|
[150] | 158 | tempdeux = systime(1) ; For key_performance =2 |
---|
[29] | 159 | if keyword_set(key_periodic)*(nx-1 EQ jpi) $ |
---|
| 160 | AND NOT keyword_set(basic) then BEGIN |
---|
[2] | 161 | indicey = triang/nx |
---|
| 162 | indicex = triang-indicey*nx |
---|
| 163 | nx = nx-1 |
---|
| 164 | liste = where(indicex EQ nx) |
---|
| 165 | if liste[0] NE -1 then indicex[liste] = 0 |
---|
| 166 | triang = indicex+nx*indicey |
---|
| 167 | nx = nx+1 |
---|
| 168 | ; if coinmont[0] NE -1 then begin |
---|
| 169 | ; indicey = coinmont/nx |
---|
| 170 | ; indicex = coinmont-indicey*nx |
---|
| 171 | ; nx = nx-1 |
---|
| 172 | ; liste = where(indicex EQ nx) |
---|
| 173 | ; if liste[0] NE -1 THEN indicex[liste] = 0 |
---|
| 174 | ; coinmont = indicex+nx*indicey |
---|
| 175 | ; nx = nx+1 |
---|
| 176 | ; endif |
---|
| 177 | ; if coindesc[0] NE -1 then begin |
---|
| 178 | ; indicey = coindesc/nx |
---|
| 179 | ; indicex = coindesc-indicey*nx |
---|
| 180 | ; nx = nx-1 |
---|
| 181 | ; liste = where(indicex EQ nx) |
---|
| 182 | ; if liste[0] NE -1 THEN indicex[liste] = 0 |
---|
| 183 | ; coindesc = indicex+nx*indicey |
---|
| 184 | ; nx = nx+1 |
---|
| 185 | ; endif |
---|
| 186 | endif |
---|
| 187 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 188 | print, 'temps triangule: finitions', systime(1)-tempdeux |
---|
| 189 | |
---|
| 190 | ;------------------------------------------------------------ |
---|
[150] | 191 | if arg_present(coinmonte) THEN coinmonte = coinmont ELSE twin_corners_up = coinmont |
---|
| 192 | if arg_present(coindescend) THEN coindescend = coindesc ELSE twin_corners_dn = coindesc |
---|
| 193 | |
---|
| 194 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 195 | @updateold |
---|
| 196 | ENDIF |
---|
[2] | 197 | ;------------------------------------------------------------ |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | IF keyword_set(key_performance) THEN print, 'temps triangule', systime(1)-tempsun |
---|
| 201 | |
---|
| 202 | return, triang |
---|
| 203 | |
---|
| 204 | END |
---|