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