[14] | 1 | ;+ |
---|
| 2 | ; |
---|
[142] | 3 | ; @file_comments |
---|
[254] | 4 | ; Similar to <pro>grille</pro>. |
---|
| 5 | ; Here, when vargrid is not 'T' or 'W', we have to |
---|
| 6 | ; recuperate tmask, glamt, gphit and the array of triangulation on the |
---|
| 7 | ; considered sub-domain for the drawing. |
---|
| 8 | ; The specificity of decoupeterre, in comparaison with <pro>grille</pro>, is |
---|
| 9 | ; that we take, if possible, a sub-domain just a little bit bigger than the |
---|
| 10 | ; one defined by <pro>domdef</pro> in order to be |
---|
[142] | 11 | ; sure that the mask we draw will cover over all the drawing. |
---|
[14] | 12 | ; |
---|
[142] | 13 | ; @categories |
---|
[268] | 14 | ; Grid |
---|
[14] | 15 | ; |
---|
[163] | 16 | ; @param MASK |
---|
| 17 | ; |
---|
| 18 | ; @param GLAM |
---|
| 19 | ; |
---|
| 20 | ; @param GPHI |
---|
| 21 | ; |
---|
| 22 | ; @param GDEP |
---|
| 23 | ; |
---|
| 24 | ; @keyword TYPE |
---|
| 25 | ; |
---|
| 26 | ; @keyword INDICEZOOM |
---|
| 27 | ; |
---|
| 28 | ; @keyword COINMONTE |
---|
| 29 | ; |
---|
| 30 | ; @keyword COINDESCEND |
---|
| 31 | ; |
---|
| 32 | ; @keyword REALSECTION |
---|
| 33 | ; |
---|
| 34 | ; @keyword USETRI |
---|
| 35 | ; |
---|
| 36 | ; @keyword _EXTRA |
---|
[231] | 37 | ; Used to pass keywords |
---|
[163] | 38 | ; |
---|
[226] | 39 | ; @keyword TRI |
---|
[268] | 40 | ; This keyword serve to obtain, thanks to <pro>grille</pro>, the triangulation which |
---|
| 41 | ; refer to the grid but only on the part of the zoom. This array of triangulation |
---|
[142] | 42 | ; is passed in the variable we have equate at TRI. |
---|
| 43 | ; For example: grille,...,tri=triangulation_reduite. |
---|
[231] | 44 | ; This keyword is used in <pro>plt</pro>. |
---|
[14] | 45 | ; |
---|
[142] | 46 | ; @keyword WDEPTH |
---|
[226] | 47 | ; To specify that the field is at W depth instead of T |
---|
[142] | 48 | ; depth (automatically activated if vargrid eq 'W') |
---|
[14] | 49 | ; |
---|
[142] | 50 | ; @uses |
---|
| 51 | ; common.pro |
---|
[14] | 52 | ; |
---|
[142] | 53 | ; @history |
---|
[157] | 54 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[142] | 55 | ; 24/2/99 |
---|
[14] | 56 | ; |
---|
[142] | 57 | ; @version |
---|
| 58 | ; $Id$ |
---|
[14] | 59 | ; |
---|
[231] | 60 | ; @todo |
---|
| 61 | ; seb : manque tous les param et plein de keywords. |
---|
[14] | 62 | ; |
---|
[231] | 63 | ;- |
---|
[232] | 64 | PRO decoupeterre, mask, glam, gphi, gdep, TYPE = type, TRI = tri, INDICEZOOM = indicezoom, COINMONTE = coinmonte, COINDESCEND = coindescend, WDEPTH = wdepth, REALSECTION = realsection, USETRI = usetri, _EXTRA = ex |
---|
[114] | 65 | ; |
---|
| 66 | compile_opt idl2, strictarrsubs |
---|
| 67 | ; |
---|
[14] | 68 | @cm_4mesh |
---|
| 69 | @cm_4data |
---|
| 70 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 71 | @updatenew |
---|
| 72 | ENDIF |
---|
| 73 | ;--------------------------------------------------------- |
---|
[142] | 74 | tempsun = systime(1) ; For key_performance |
---|
[14] | 75 | ;------------------------------------------------------------ |
---|
| 76 | if vargrid EQ 'W' then wdepth = 1 |
---|
| 77 | ;------------------------------------------------------------ |
---|
| 78 | ;------------------------------------------------------------ |
---|
| 79 | ; horizontal parameters |
---|
| 80 | ;------------------------------------------------------------ |
---|
| 81 | ; if possible extent the domain according to the grid type |
---|
| 82 | ; default case |
---|
| 83 | case vargrid of |
---|
| 84 | 'U':BEGIN |
---|
| 85 | firstx = 0 > (min([firstxt, firstxu])-1) |
---|
| 86 | lastx = (max([lastxt, lastxu])+1) < (jpi-1) |
---|
| 87 | firsty = 0 > (min([firstyt, firstyu])-1) |
---|
| 88 | lasty = (max([lastyt, lastyu])+1) < (jpj-1) |
---|
| 89 | end |
---|
| 90 | 'V':BEGIN |
---|
| 91 | firstx = 0 > (min([firstxt, firstxv])-1) |
---|
| 92 | lastx = (max([lastxt, lastxv])+1) < (jpi-1) |
---|
| 93 | firsty = 0 > (min([firstyt, firstyv])-1) |
---|
| 94 | lasty = (max([lastyt, lastyv])+1) < (jpj-1) |
---|
| 95 | end |
---|
| 96 | 'F':BEGIN |
---|
| 97 | firstx = 0 > (min([firstxt, firstxf])-1) |
---|
| 98 | lastx = (max([lastxt, lastxf])+1) < (jpi-1) |
---|
| 99 | firsty = 0 > (min([firstyt, firstyf])-1) |
---|
| 100 | lasty = (max([lastyt, lastyf])+1) < (jpj-1) |
---|
| 101 | END |
---|
| 102 | ELSE:BEGIN |
---|
| 103 | firstx = firstxt |
---|
| 104 | lastx = lastxt |
---|
| 105 | firsty = firstyt |
---|
| 106 | lasty = lastyt |
---|
| 107 | END |
---|
| 108 | ENDCASE |
---|
[297] | 109 | ; however for the vertical section we don''t want to extent the domain |
---|
[14] | 110 | ; in the direction perpendicular to the vertical section |
---|
| 111 | if type EQ 'xz' then begin |
---|
| 112 | case vargrid of |
---|
| 113 | 'U':BEGIN |
---|
| 114 | firsty = firstyu |
---|
| 115 | lasty = lastyu |
---|
| 116 | END |
---|
| 117 | 'V':BEGIN |
---|
| 118 | firsty = firstyv |
---|
| 119 | lasty = lastyv |
---|
| 120 | END |
---|
| 121 | 'F':BEGIN |
---|
| 122 | firsty = firstyf |
---|
| 123 | lasty = lastyf |
---|
| 124 | END |
---|
| 125 | ELSE: |
---|
| 126 | ENDCASE |
---|
| 127 | endif |
---|
| 128 | ; |
---|
| 129 | if type EQ 'yz' then begin |
---|
| 130 | case vargrid of |
---|
| 131 | 'U':BEGIN |
---|
| 132 | firstx = firstxu |
---|
| 133 | lastx = lastxu |
---|
| 134 | END |
---|
| 135 | 'V':BEGIN |
---|
| 136 | firstx = firstxv |
---|
| 137 | lastx = lastxv |
---|
| 138 | END |
---|
| 139 | 'F':BEGIN |
---|
| 140 | firstx = firstxf |
---|
| 141 | lastx = lastxf |
---|
| 142 | END |
---|
| 143 | ELSE: |
---|
| 144 | ENDCASE |
---|
| 145 | endif |
---|
| 146 | ; |
---|
| 147 | nx = lastx-firstx+1 |
---|
| 148 | ny = lasty-firsty+1 |
---|
| 149 | ;------------------------------------------------------------ |
---|
| 150 | ; horizontal grid |
---|
| 151 | ;------------------------------------------------------------ |
---|
| 152 | ; default case |
---|
| 153 | glam = glamt[firstx:lastx, firsty:lasty] |
---|
| 154 | gphi = gphit[firstx:lastx, firsty:lasty] |
---|
| 155 | ; for the vertical section, 2 cases: |
---|
| 156 | ; 1) keyword_set(realsection) eq 1: then we use drawsectionbottom.pro |
---|
| 157 | ; that directly draw the bottom using polyfill and plot. In this case, |
---|
| 158 | ; the position of the mask must given by the edge of the mask |
---|
| 159 | ; cells. As we are considering the edges of the mask cells, glam or |
---|
| 160 | ; gphi as one more point than the mask (if it is possible) |
---|
| 161 | ; 2) keyword_set(realsection) eq 0: then we draw the mask by contouring |
---|
| 162 | ; the mask with contour (contouring the level=.5). In this case, the |
---|
| 163 | ; mask position must be given by the middle on the mask cells. |
---|
| 164 | CASE type OF |
---|
| 165 | 'xz':BEGIN |
---|
| 166 | if keyword_set(realsection) EQ 0 then begin |
---|
| 167 | if vargrid EQ 'V' OR vargrid EQ 'F' then $ |
---|
| 168 | glam = glamv[firstx:lastx, firsty:lasty] |
---|
[226] | 169 | ENDIF ELSE BEGIN ; to drawsectionbottom |
---|
[14] | 170 | if vargrid EQ 'V' OR vargrid EQ 'F' OR finite(glamu[0]) EQ 0 then $ |
---|
| 171 | glam = glamf[0 > (firstx-1):lastx, firsty:lasty] $ |
---|
| 172 | ELSE glam = glamu[0 > (firstx-1):lastx, firsty:lasty] |
---|
| 173 | ENDELSE |
---|
| 174 | END |
---|
| 175 | 'yz':BEGIN |
---|
| 176 | if keyword_set(realsection) EQ 0 then begin |
---|
| 177 | if vargrid EQ 'U' OR vargrid EQ 'F' then $ |
---|
| 178 | gphi = gphiu[firstx:lastx, firsty:lasty] |
---|
[226] | 179 | ENDIF ELSE BEGIN ; to drawsectionbottom |
---|
[14] | 180 | if vargrid EQ 'U' OR vargrid EQ 'F' OR finite(gphiv[0]) EQ 0 then $ |
---|
| 181 | gphi = gphif[firstx:lastx, 0 > (firsty-1):lasty] $ |
---|
| 182 | ELSE gphi = gphiv[firstx:lastx, 0 > (firsty-1):lasty] |
---|
| 183 | ENDELSE |
---|
| 184 | END |
---|
| 185 | ELSE: |
---|
| 186 | ENDCASE |
---|
| 187 | ;------------------------------------------------------------ |
---|
| 188 | ; vertical boundaries |
---|
| 189 | ;------------------------------------------------------------ |
---|
| 190 | if keyword_set(wdepth) then begin |
---|
| 191 | firstz = 0 > (min([firstzt, firstzw])-1) |
---|
| 192 | lastz = (max([lastzt, lastzw])+1) < (jpk-1) |
---|
| 193 | ENDIF ELSE BEGIN |
---|
| 194 | firstz = firstzt |
---|
| 195 | lastz = lastzt |
---|
[226] | 196 | ENDELSE |
---|
[14] | 197 | nz = lastz-firstz+1 |
---|
| 198 | ;------------------------------------------------------------ |
---|
| 199 | ; mask |
---|
| 200 | ;------------------------------------------------------------ |
---|
| 201 | case type of |
---|
| 202 | 'xy':BEGIN |
---|
| 203 | mask = tmask[firstx:lastx, firsty:lasty, firstz] |
---|
| 204 | profond = firstz NE 0 |
---|
| 205 | END |
---|
[226] | 206 | ; for the vertical section, we have to choose the right mask according |
---|
[14] | 207 | ; to the grid point and to the direction of the section |
---|
| 208 | 'xz':BEGIN |
---|
| 209 | if vargrid EQ 'V' OR vargrid EQ 'F' then begin |
---|
| 210 | mask = (vmask())[firstx:lastx, firstyv:lastyv, firstz:lastz] |
---|
| 211 | ENDIF ELSE mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
| 212 | END |
---|
| 213 | 'yz':BEGIN |
---|
| 214 | if vargrid EQ 'U' OR vargrid EQ 'F' then begin |
---|
| 215 | mask = (umask())[firstxu:lastxu, firsty:lasty, firstz:lastz] |
---|
| 216 | ENDIF ELSE mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
| 217 | END |
---|
| 218 | ELSE:mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
| 219 | endcase |
---|
| 220 | ;------------------------------------------------------------ |
---|
| 221 | ; vertical axis |
---|
| 222 | ;------------------------------------------------------------ |
---|
| 223 | ; when we do a real section we directly plot the gdepw |
---|
| 224 | ; (in drawsectionbottom.pro) instead of contouring the mask at 0.5 at |
---|
| 225 | ; gdept |
---|
| 226 | IF keyword_set(realsection) EQ 0 then gdep = gdept[firstz:lastz] $ |
---|
| 227 | ELSE BEGIN |
---|
| 228 | ; if lastz EQ jpk-1 then $ |
---|
| 229 | ; we add some fictive very deep level that will not be used but that is |
---|
| 230 | ; necessary to avoid array size bugs in draw bottom section |
---|
| 231 | ; gdep = [gdepw[firstz+1:lastz], 2*gdept[jpk-1]] $ |
---|
| 232 | ; ELSE gdep = gdepw[firstz+1:lastz+1] |
---|
| 233 | gdep = gdepw[firstz:lastz] |
---|
| 234 | ; special case when we are using the partial steps in the vertical |
---|
| 235 | ; section that are only 1 point wide. |
---|
| 236 | ; in that case, the z axis is a 2d array and we modify the depth of |
---|
| 237 | ; the last level ocean with hdepw that is the real depth of the bottom. |
---|
| 238 | CASE 1 OF |
---|
| 239 | keyword_set(key_partialstep) and type EQ 'xz' $ |
---|
| 240 | AND ny EQ 1 AND keyword_set(realsection):BEGIN |
---|
| 241 | bottom = total(mask, 3) |
---|
| 242 | good = where(bottom NE 0 AND bottom NE nz+1) |
---|
| 243 | bottom = lindgen(nx)+(bottom)*nx |
---|
| 244 | IF good[0] NE -1 THEN BEGIN |
---|
| 245 | bottom = bottom[good] |
---|
| 246 | gdep = replicate(1, nx)#gdep |
---|
| 247 | truegdep = hdepw[firstx:lastx, firsty:lasty] |
---|
| 248 | gdep[bottom] = truegdep[good] |
---|
| 249 | ENDIF |
---|
| 250 | END |
---|
| 251 | keyword_set(key_partialstep) and type EQ 'yz' $ |
---|
[226] | 252 | AND nx EQ 1 AND keyword_set(realsection):BEGIN |
---|
[14] | 253 | bottom = total(mask, 3) |
---|
| 254 | good = where(bottom NE 0 AND bottom NE nz+1) |
---|
| 255 | bottom = lindgen(ny)+(bottom)*ny |
---|
| 256 | IF good[0] NE -1 THEN BEGIN |
---|
| 257 | bottom = bottom[good] |
---|
| 258 | gdep = replicate(1, ny)#gdep |
---|
| 259 | truegdep = hdepw[firstx:lastx, firsty:lasty] |
---|
| 260 | gdep[bottom] = truegdep[good] |
---|
| 261 | ENDIF |
---|
| 262 | END |
---|
| 263 | ELSE: |
---|
| 264 | ENDCASE |
---|
| 265 | ENDELSE |
---|
| 266 | ;------------------------------------------------------------ |
---|
[142] | 267 | ; Triangulation vector when TRI is activated. |
---|
[14] | 268 | ;------------------------------------------------------------ |
---|
| 269 | IF arg_present(TRI) then $ |
---|
| 270 | if triangles_list[0] EQ -1 OR usetri LT 1 then tri = -1 ELSE BEGIN |
---|
[142] | 271 | ; If we are tracing a deep level, we redo the triangulation |
---|
[14] | 272 | if keyword_set(profond) then begin |
---|
| 273 | tri = triangule(mask, coinmonte = coinmonte, coindescend = coindescend, _extra = ex) |
---|
| 274 | indicezoom = (lindgen(jpi, jpj))[firstx:lastx, firsty:lasty] |
---|
[226] | 275 | ENDIF ELSE BEGIN |
---|
[142] | 276 | ; Otherwise, we recuperate the part of triangulation that interest us and we number them well!! |
---|
[226] | 277 | if nx EQ jpi AND ny EQ jpj then tri = triangles_list ELSE BEGIN |
---|
[14] | 278 | msk = bytarr(jpi, jpj) |
---|
| 279 | msk[firstx:lastx, firsty:lasty] = 1 |
---|
| 280 | ind = where( msk[triangles_list[0, *]] EQ 1 $ |
---|
| 281 | AND msk[triangles_list[1, *]] EQ 1 $ |
---|
| 282 | AND msk[triangles_list[2, *]] EQ 1 ) |
---|
| 283 | tri = triangles_list[*, ind]-(firstx+firsty*jpi) |
---|
| 284 | y = tri/jpi |
---|
| 285 | x = tri-y*jpi |
---|
| 286 | tri = x+y*nx |
---|
| 287 | ENDELSE |
---|
| 288 | ENDELSE |
---|
| 289 | ENDELSE |
---|
| 290 | ;------------------------------------------------------------------- |
---|
[226] | 291 | if keyword_set(key_performance) THEN print, 'temps decoupeterre', systime(1)-tempsun |
---|
[14] | 292 | ;------------------------------------------------------------ |
---|
| 293 | return |
---|
| 294 | end |
---|