[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 | ;- |
---|
[327] | 64 | PRO decoupeterre, mask, glam, gphi, gdep $ |
---|
| 65 | , TYPE=type, TRI=tri, INDICEZOOM=indicezoom $ |
---|
| 66 | , COINMONTE=coinmonte, COINDESCEND=coindescend $ |
---|
| 67 | , WDEPTH=wdepth, REALSECTION=realsection, USETRI=usetri $ |
---|
| 68 | , _EXTRA=ex |
---|
[114] | 69 | ; |
---|
| 70 | compile_opt idl2, strictarrsubs |
---|
| 71 | ; |
---|
[14] | 72 | @cm_4mesh |
---|
| 73 | @cm_4data |
---|
| 74 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 75 | @updatenew |
---|
| 76 | ENDIF |
---|
| 77 | ;--------------------------------------------------------- |
---|
[142] | 78 | tempsun = systime(1) ; For key_performance |
---|
[14] | 79 | ;------------------------------------------------------------ |
---|
| 80 | if vargrid EQ 'W' then wdepth = 1 |
---|
| 81 | ;------------------------------------------------------------ |
---|
| 82 | ;------------------------------------------------------------ |
---|
| 83 | ; horizontal parameters |
---|
| 84 | ;------------------------------------------------------------ |
---|
| 85 | ; if possible extent the domain according to the grid type |
---|
| 86 | ; default case |
---|
| 87 | case vargrid of |
---|
| 88 | 'U':BEGIN |
---|
| 89 | firstx = 0 > (min([firstxt, firstxu])-1) |
---|
| 90 | lastx = (max([lastxt, lastxu])+1) < (jpi-1) |
---|
| 91 | firsty = 0 > (min([firstyt, firstyu])-1) |
---|
| 92 | lasty = (max([lastyt, lastyu])+1) < (jpj-1) |
---|
| 93 | end |
---|
| 94 | 'V':BEGIN |
---|
| 95 | firstx = 0 > (min([firstxt, firstxv])-1) |
---|
| 96 | lastx = (max([lastxt, lastxv])+1) < (jpi-1) |
---|
| 97 | firsty = 0 > (min([firstyt, firstyv])-1) |
---|
| 98 | lasty = (max([lastyt, lastyv])+1) < (jpj-1) |
---|
| 99 | end |
---|
| 100 | 'F':BEGIN |
---|
| 101 | firstx = 0 > (min([firstxt, firstxf])-1) |
---|
| 102 | lastx = (max([lastxt, lastxf])+1) < (jpi-1) |
---|
| 103 | firsty = 0 > (min([firstyt, firstyf])-1) |
---|
| 104 | lasty = (max([lastyt, lastyf])+1) < (jpj-1) |
---|
| 105 | END |
---|
| 106 | ELSE:BEGIN |
---|
| 107 | firstx = firstxt |
---|
| 108 | lastx = lastxt |
---|
| 109 | firsty = firstyt |
---|
| 110 | lasty = lastyt |
---|
| 111 | END |
---|
| 112 | ENDCASE |
---|
[297] | 113 | ; however for the vertical section we don''t want to extent the domain |
---|
[14] | 114 | ; in the direction perpendicular to the vertical section |
---|
| 115 | if type EQ 'xz' then begin |
---|
| 116 | case vargrid of |
---|
| 117 | 'U':BEGIN |
---|
| 118 | firsty = firstyu |
---|
| 119 | lasty = lastyu |
---|
| 120 | END |
---|
| 121 | 'V':BEGIN |
---|
| 122 | firsty = firstyv |
---|
| 123 | lasty = lastyv |
---|
| 124 | END |
---|
| 125 | 'F':BEGIN |
---|
| 126 | firsty = firstyf |
---|
| 127 | lasty = lastyf |
---|
| 128 | END |
---|
| 129 | ELSE: |
---|
| 130 | ENDCASE |
---|
| 131 | endif |
---|
| 132 | ; |
---|
| 133 | if type EQ 'yz' then begin |
---|
| 134 | case vargrid of |
---|
| 135 | 'U':BEGIN |
---|
| 136 | firstx = firstxu |
---|
| 137 | lastx = lastxu |
---|
| 138 | END |
---|
| 139 | 'V':BEGIN |
---|
| 140 | firstx = firstxv |
---|
| 141 | lastx = lastxv |
---|
| 142 | END |
---|
| 143 | 'F':BEGIN |
---|
| 144 | firstx = firstxf |
---|
| 145 | lastx = lastxf |
---|
| 146 | END |
---|
| 147 | ELSE: |
---|
| 148 | ENDCASE |
---|
| 149 | endif |
---|
| 150 | ; |
---|
| 151 | nx = lastx-firstx+1 |
---|
| 152 | ny = lasty-firsty+1 |
---|
| 153 | ;------------------------------------------------------------ |
---|
| 154 | ; horizontal grid |
---|
| 155 | ;------------------------------------------------------------ |
---|
| 156 | ; default case |
---|
| 157 | glam = glamt[firstx:lastx, firsty:lasty] |
---|
| 158 | gphi = gphit[firstx:lastx, firsty:lasty] |
---|
| 159 | ; for the vertical section, 2 cases: |
---|
| 160 | ; 1) keyword_set(realsection) eq 1: then we use drawsectionbottom.pro |
---|
| 161 | ; that directly draw the bottom using polyfill and plot. In this case, |
---|
| 162 | ; the position of the mask must given by the edge of the mask |
---|
| 163 | ; cells. As we are considering the edges of the mask cells, glam or |
---|
| 164 | ; gphi as one more point than the mask (if it is possible) |
---|
| 165 | ; 2) keyword_set(realsection) eq 0: then we draw the mask by contouring |
---|
| 166 | ; the mask with contour (contouring the level=.5). In this case, the |
---|
| 167 | ; mask position must be given by the middle on the mask cells. |
---|
| 168 | CASE type OF |
---|
| 169 | 'xz':BEGIN |
---|
| 170 | if keyword_set(realsection) EQ 0 then begin |
---|
| 171 | if vargrid EQ 'V' OR vargrid EQ 'F' then $ |
---|
| 172 | glam = glamv[firstx:lastx, firsty:lasty] |
---|
[226] | 173 | ENDIF ELSE BEGIN ; to drawsectionbottom |
---|
[14] | 174 | if vargrid EQ 'V' OR vargrid EQ 'F' OR finite(glamu[0]) EQ 0 then $ |
---|
| 175 | glam = glamf[0 > (firstx-1):lastx, firsty:lasty] $ |
---|
| 176 | ELSE glam = glamu[0 > (firstx-1):lastx, firsty:lasty] |
---|
| 177 | ENDELSE |
---|
| 178 | END |
---|
| 179 | 'yz':BEGIN |
---|
| 180 | if keyword_set(realsection) EQ 0 then begin |
---|
| 181 | if vargrid EQ 'U' OR vargrid EQ 'F' then $ |
---|
| 182 | gphi = gphiu[firstx:lastx, firsty:lasty] |
---|
[226] | 183 | ENDIF ELSE BEGIN ; to drawsectionbottom |
---|
[14] | 184 | if vargrid EQ 'U' OR vargrid EQ 'F' OR finite(gphiv[0]) EQ 0 then $ |
---|
| 185 | gphi = gphif[firstx:lastx, 0 > (firsty-1):lasty] $ |
---|
| 186 | ELSE gphi = gphiv[firstx:lastx, 0 > (firsty-1):lasty] |
---|
| 187 | ENDELSE |
---|
| 188 | END |
---|
| 189 | ELSE: |
---|
| 190 | ENDCASE |
---|
| 191 | ;------------------------------------------------------------ |
---|
| 192 | ; vertical boundaries |
---|
| 193 | ;------------------------------------------------------------ |
---|
| 194 | if keyword_set(wdepth) then begin |
---|
| 195 | firstz = 0 > (min([firstzt, firstzw])-1) |
---|
| 196 | lastz = (max([lastzt, lastzw])+1) < (jpk-1) |
---|
| 197 | ENDIF ELSE BEGIN |
---|
| 198 | firstz = firstzt |
---|
| 199 | lastz = lastzt |
---|
[226] | 200 | ENDELSE |
---|
[14] | 201 | nz = lastz-firstz+1 |
---|
| 202 | ;------------------------------------------------------------ |
---|
| 203 | ; mask |
---|
| 204 | ;------------------------------------------------------------ |
---|
| 205 | case type of |
---|
| 206 | 'xy':BEGIN |
---|
| 207 | mask = tmask[firstx:lastx, firsty:lasty, firstz] |
---|
| 208 | profond = firstz NE 0 |
---|
| 209 | END |
---|
[226] | 210 | ; for the vertical section, we have to choose the right mask according |
---|
[14] | 211 | ; to the grid point and to the direction of the section |
---|
| 212 | 'xz':BEGIN |
---|
| 213 | if vargrid EQ 'V' OR vargrid EQ 'F' then begin |
---|
| 214 | mask = (vmask())[firstx:lastx, firstyv:lastyv, firstz:lastz] |
---|
| 215 | ENDIF ELSE mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
| 216 | END |
---|
| 217 | 'yz':BEGIN |
---|
| 218 | if vargrid EQ 'U' OR vargrid EQ 'F' then begin |
---|
| 219 | mask = (umask())[firstxu:lastxu, firsty:lasty, firstz:lastz] |
---|
| 220 | ENDIF ELSE mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
| 221 | END |
---|
| 222 | ELSE:mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
| 223 | endcase |
---|
| 224 | ;------------------------------------------------------------ |
---|
| 225 | ; vertical axis |
---|
| 226 | ;------------------------------------------------------------ |
---|
| 227 | ; when we do a real section we directly plot the gdepw |
---|
| 228 | ; (in drawsectionbottom.pro) instead of contouring the mask at 0.5 at |
---|
| 229 | ; gdept |
---|
| 230 | IF keyword_set(realsection) EQ 0 then gdep = gdept[firstz:lastz] $ |
---|
| 231 | ELSE BEGIN |
---|
| 232 | ; if lastz EQ jpk-1 then $ |
---|
| 233 | ; we add some fictive very deep level that will not be used but that is |
---|
| 234 | ; necessary to avoid array size bugs in draw bottom section |
---|
| 235 | ; gdep = [gdepw[firstz+1:lastz], 2*gdept[jpk-1]] $ |
---|
| 236 | ; ELSE gdep = gdepw[firstz+1:lastz+1] |
---|
| 237 | gdep = gdepw[firstz:lastz] |
---|
| 238 | ; special case when we are using the partial steps in the vertical |
---|
| 239 | ; section that are only 1 point wide. |
---|
| 240 | ; in that case, the z axis is a 2d array and we modify the depth of |
---|
| 241 | ; the last level ocean with hdepw that is the real depth of the bottom. |
---|
| 242 | CASE 1 OF |
---|
| 243 | keyword_set(key_partialstep) and type EQ 'xz' $ |
---|
| 244 | AND ny EQ 1 AND keyword_set(realsection):BEGIN |
---|
| 245 | bottom = total(mask, 3) |
---|
| 246 | good = where(bottom NE 0 AND bottom NE nz+1) |
---|
| 247 | bottom = lindgen(nx)+(bottom)*nx |
---|
| 248 | IF good[0] NE -1 THEN BEGIN |
---|
| 249 | bottom = bottom[good] |
---|
| 250 | gdep = replicate(1, nx)#gdep |
---|
| 251 | truegdep = hdepw[firstx:lastx, firsty:lasty] |
---|
| 252 | gdep[bottom] = truegdep[good] |
---|
| 253 | ENDIF |
---|
| 254 | END |
---|
| 255 | keyword_set(key_partialstep) and type EQ 'yz' $ |
---|
[226] | 256 | AND nx EQ 1 AND keyword_set(realsection):BEGIN |
---|
[14] | 257 | bottom = total(mask, 3) |
---|
| 258 | good = where(bottom NE 0 AND bottom NE nz+1) |
---|
| 259 | bottom = lindgen(ny)+(bottom)*ny |
---|
| 260 | IF good[0] NE -1 THEN BEGIN |
---|
| 261 | bottom = bottom[good] |
---|
| 262 | gdep = replicate(1, ny)#gdep |
---|
| 263 | truegdep = hdepw[firstx:lastx, firsty:lasty] |
---|
| 264 | gdep[bottom] = truegdep[good] |
---|
| 265 | ENDIF |
---|
| 266 | END |
---|
| 267 | ELSE: |
---|
| 268 | ENDCASE |
---|
| 269 | ENDELSE |
---|
| 270 | ;------------------------------------------------------------ |
---|
[142] | 271 | ; Triangulation vector when TRI is activated. |
---|
[14] | 272 | ;------------------------------------------------------------ |
---|
| 273 | IF arg_present(TRI) then $ |
---|
| 274 | if triangles_list[0] EQ -1 OR usetri LT 1 then tri = -1 ELSE BEGIN |
---|
[142] | 275 | ; If we are tracing a deep level, we redo the triangulation |
---|
[14] | 276 | if keyword_set(profond) then begin |
---|
| 277 | tri = triangule(mask, coinmonte = coinmonte, coindescend = coindescend, _extra = ex) |
---|
| 278 | indicezoom = (lindgen(jpi, jpj))[firstx:lastx, firsty:lasty] |
---|
[226] | 279 | ENDIF ELSE BEGIN |
---|
[142] | 280 | ; Otherwise, we recuperate the part of triangulation that interest us and we number them well!! |
---|
[226] | 281 | if nx EQ jpi AND ny EQ jpj then tri = triangles_list ELSE BEGIN |
---|
[14] | 282 | msk = bytarr(jpi, jpj) |
---|
| 283 | msk[firstx:lastx, firsty:lasty] = 1 |
---|
| 284 | ind = where( msk[triangles_list[0, *]] EQ 1 $ |
---|
| 285 | AND msk[triangles_list[1, *]] EQ 1 $ |
---|
| 286 | AND msk[triangles_list[2, *]] EQ 1 ) |
---|
| 287 | tri = triangles_list[*, ind]-(firstx+firsty*jpi) |
---|
| 288 | y = tri/jpi |
---|
| 289 | x = tri-y*jpi |
---|
| 290 | tri = x+y*nx |
---|
| 291 | ENDELSE |
---|
| 292 | ENDELSE |
---|
| 293 | ENDELSE |
---|
| 294 | ;------------------------------------------------------------------- |
---|
[226] | 295 | if keyword_set(key_performance) THEN print, 'temps decoupeterre', systime(1)-tempsun |
---|
[14] | 296 | ;------------------------------------------------------------ |
---|
| 297 | return |
---|
| 298 | end |
---|