1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Allows to pass from a 2d level array to a 2d depth array corresponding to these levels |
---|
5 | ; |
---|
6 | ; @categories |
---|
7 | ; Without loop |
---|
8 | ; |
---|
9 | ; @param TAB {in}{required}{type=2d array} |
---|
10 | ; 2d level array of sill levels (or a structure respecting <pro>litchamp</pro> criterions) |
---|
11 | ; |
---|
12 | ; @keyword NOMASK |
---|
13 | ; To do not mask land points. |
---|
14 | ; |
---|
15 | ; @returns |
---|
16 | ; 2d array containing depths |
---|
17 | ; |
---|
18 | ; @uses |
---|
19 | ; common.pro |
---|
20 | ; |
---|
21 | ; @history |
---|
22 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
23 | ; 17/6/1999 |
---|
24 | ; 14/6/2000 accepte !values.f_nan |
---|
25 | ; |
---|
26 | ; @version |
---|
27 | ; $Id$ |
---|
28 | ; |
---|
29 | ;- |
---|
30 | ; |
---|
31 | FUNCTION level2depth, tab, NOMASK = nomask |
---|
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 used subdomain's size |
---|
39 | ;------------------------------------------------------------ |
---|
40 | niveaux = litchamp(tab) |
---|
41 | grille,mask, -1, -1,gdep,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz |
---|
42 | ;--------------------------------------------------------------- |
---|
43 | ; verification of the coherence between array's size and the domain defined by domdef |
---|
44 | ;--------------------------------------------------------------- |
---|
45 | taille = size(niveaux) |
---|
46 | if taille[0] NE 2 then return, report('input field must be a 2d array') |
---|
47 | case 1 of |
---|
48 | taille[1] eq jpi and taille[2] eq jpj:niveaux=niveaux[firstx:lastx, firsty:lasty] |
---|
49 | taille[1] eq nx and taille[2] eq ny: |
---|
50 | else:return, report('Probleme d''adequation entre les tailles du domaine et celle du champ.') |
---|
51 | endcase |
---|
52 | ;--------------------------------------------------------------- |
---|
53 | |
---|
54 | wherenan = where(finite(niveaux, /nan) EQ 1) |
---|
55 | if wherenan[0] NE -1 then niveaux[wherenan] = 0 |
---|
56 | niveaux = 0 > niveaux < (jpk-1) |
---|
57 | ;--------------------------------------------------------------- |
---|
58 | gdep = replicate(1, nx*ny)#gdep |
---|
59 | niveaux = lindgen(nx*ny)+(nx*ny)*niveaux |
---|
60 | gdep = reform(gdep[niveaux], nx, ny) |
---|
61 | ; |
---|
62 | if wherenan[0] NE -1 then gdep[wherenan] = !values.f_nan |
---|
63 | if NOT keyword_set(nomask) then begin |
---|
64 | if n_elements(valmask) EQ 0 then valmask = 1e20 |
---|
65 | terre = where(mask[*, *, 0] EQ 0) |
---|
66 | if terre[0] NE -1 then gdep[terre] = valmask |
---|
67 | endif |
---|
68 | ; |
---|
69 | if keyword_set(key_performance) THEN print, 'temps level2depth', systime(1)-tempsun |
---|
70 | return, gdep |
---|
71 | end |
---|