[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[142] | 3 | ; @file_comments |
---|
[231] | 4 | ; Allow to pass from a 2d sill level array to the 3d mask array with 1s in |
---|
[142] | 5 | ; levels above the sill level and 0s below (and on it) |
---|
[2] | 6 | ; |
---|
[231] | 7 | ; @categories |
---|
[157] | 8 | ; Without loop |
---|
[2] | 9 | ; |
---|
[163] | 10 | ; @param TAB {in}{required}{type=2d array} |
---|
[266] | 11 | ; 2d level array of sill level (or a structure respecting <pro>litchamp</pro> |
---|
| 12 | ; criterions) |
---|
[2] | 13 | ; |
---|
[142] | 14 | ; @returns |
---|
| 15 | ; It is a 3d array containing the mask associated to the 2d sill level array |
---|
[2] | 16 | ; |
---|
[142] | 17 | ; @uses |
---|
[370] | 18 | ; <pro>common</pro> |
---|
[2] | 19 | ; |
---|
[142] | 20 | ; @history |
---|
[157] | 21 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[2] | 22 | ; 17/6/1999 |
---|
[266] | 23 | ; Sept 2004: boundary level have 0 values and not 1 (as it was |
---|
[25] | 24 | ; explained before in the header). see: |
---|
| 25 | ; print, array_equal(niveau, total(level2mask(niveau),3)) |
---|
| 26 | ; |
---|
[142] | 27 | ; @version |
---|
| 28 | ; $Id$ |
---|
| 29 | ; |
---|
[2] | 30 | ;- |
---|
| 31 | FUNCTION level2mask, tab |
---|
[114] | 32 | ; |
---|
| 33 | compile_opt idl2, strictarrsubs |
---|
| 34 | ; |
---|
[142] | 35 | tempsun = systime(1) ; To key_performance |
---|
[2] | 36 | @common |
---|
| 37 | ;------------------------------------------------------------ |
---|
[142] | 38 | ; Reading of the input field and recovery of the size of the used subdomain |
---|
[2] | 39 | ;------------------------------------------------------------ |
---|
| 40 | niveaux = litchamp(tab) |
---|
[25] | 41 | grille,maskterre, -1, -1, -1,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz |
---|
[2] | 42 | ;--------------------------------------------------------------- |
---|
[367] | 43 | ; verification of the coherence between the array's size and the defined by |
---|
| 44 | ; domdef domain |
---|
[2] | 45 | ;--------------------------------------------------------------- |
---|
| 46 | IF ny EQ 1 THEN niveaux = reform(niveaux, nx, ny, /over) |
---|
| 47 | taille = size(niveaux) |
---|
| 48 | if taille[0] NE 2 then return, report('le champ en entree doit contenir un tableau 2d') |
---|
| 49 | case 1 of |
---|
[25] | 50 | taille[1] eq jpi and taille[2] eq jpj:niveaux=niveaux[firstx:lastx, firsty:lasty] |
---|
[2] | 51 | taille[1] eq nx and taille[2] eq ny: |
---|
| 52 | else:return, report('Probleme d''adequation entre les tailles du domaine et celle du champ.') |
---|
| 53 | endcase |
---|
| 54 | ;------------------------------------------------------------ |
---|
| 55 | ;------------------------------------------------------------ |
---|
[142] | 56 | ; We transform the 2d leval array in 3d mask array |
---|
[2] | 57 | ;------------------------------------------------------------ |
---|
| 58 | mask = reform( niveaux[*]#(1./(indgen(nz)+1)), nx, ny, nz ) |
---|
| 59 | mask = floor(temporary(mask)) < 1 |
---|
| 60 | mask = temporary(mask)*temporary(maskterre) |
---|
| 61 | ;------------------------------------------------------------ |
---|
| 62 | ;------------------------------------------------------------ |
---|
| 63 | ;------------------------------------------------------------ |
---|
[231] | 64 | if keyword_set(key_performance) THEN print, 'temps level2mask', systime(1)-tempsun |
---|
[2] | 65 | return, mask |
---|
| 66 | end |
---|