1 | ; |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;------------------------------------------------------------ |
---|
5 | ;+ |
---|
6 | ; NAME:level2depht |
---|
7 | ; |
---|
8 | ; PURPOSE: permet de passer d''un tableau 2d de niveau au |
---|
9 | ; tableau 2d de profondeur correspondant a ces niveaux |
---|
10 | ; |
---|
11 | ; CATEGORY: SANS BOUCLE |
---|
12 | ; |
---|
13 | ; CALLING SEQUENCE: res=level2depth(niveau) |
---|
14 | ; |
---|
15 | ; INPUTS: niveau tableau 2d de niveaux seuil (ou une structure repondant |
---|
16 | ; aux criteres de litchamp) |
---|
17 | ; |
---|
18 | ; KEYWORD PARAMETERS: |
---|
19 | ; /NOMASK: pour ne pas masquer les points terres |
---|
20 | ; |
---|
21 | ; OUTPUTS: un tableau 2d contenant des profondeurs |
---|
22 | ; |
---|
23 | ; COMMON BLOCKS: |
---|
24 | ; common.pro |
---|
25 | ; |
---|
26 | ; SIDE EFFECTS: |
---|
27 | ; |
---|
28 | ; RESTRICTIONS: |
---|
29 | ; |
---|
30 | ; EXAMPLE: |
---|
31 | ; |
---|
32 | ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
33 | ; 17/6/1999 |
---|
34 | ; 14/6/2000 accepte !values.f_nan |
---|
35 | ;- |
---|
36 | ;------------------------------------------------------------ |
---|
37 | ;------------------------------------------------------------ |
---|
38 | ;------------------------------------------------------------ |
---|
39 | FUNCTION level2depth, tab, NOMASK = nomask |
---|
40 | ; |
---|
41 | compile_opt idl2, strictarrsubs |
---|
42 | ; |
---|
43 | tempsun = systime(1) ; pour key_performance |
---|
44 | @common |
---|
45 | ;------------------------------------------------------------ |
---|
46 | ; lecture du champ d''entree et recuperation de la taille du sous |
---|
47 | ; domaine utilise |
---|
48 | ;------------------------------------------------------------ |
---|
49 | niveaux = litchamp(tab) |
---|
50 | grille,mask, -1, -1,gdep,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz |
---|
51 | ;--------------------------------------------------------------- |
---|
52 | ; verification de la coherence entre la taille du tableau et le domaine definit par domdef |
---|
53 | ;--------------------------------------------------------------- |
---|
54 | taille = size(niveaux) |
---|
55 | if taille[0] NE 2 then return, report('le champ en entree doit contenir un tableau 2d') |
---|
56 | case 1 of |
---|
57 | taille[1] eq jpi and taille[2] eq jpj:niveaux=niveaux[firstx:lastx, firsty:lasty] |
---|
58 | taille[1] eq nx and taille[2] eq ny: |
---|
59 | else:return, report('Probleme d''adequation entre les tailles du domaine et celle du champ.') |
---|
60 | endcase |
---|
61 | ;--------------------------------------------------------------- |
---|
62 | |
---|
63 | wherenan = where(finite(niveaux, /nan) EQ 1) |
---|
64 | if wherenan[0] NE -1 then niveaux[wherenan] = 0 |
---|
65 | niveaux = 0 > niveaux < (jpk-1) |
---|
66 | ;--------------------------------------------------------------- |
---|
67 | gdep = replicate(1, nx*ny)#gdep |
---|
68 | niveaux = lindgen(nx*ny)+(nx*ny)*niveaux |
---|
69 | gdep = reform(gdep[niveaux], nx, ny) |
---|
70 | ; |
---|
71 | if wherenan[0] NE -1 then gdep[wherenan] = !values.f_nan |
---|
72 | if NOT keyword_set(nomask) then begin |
---|
73 | if n_elements(valmask) EQ 0 then valmask = 1e20 |
---|
74 | terre = where(mask[*, *, 0] EQ 0) |
---|
75 | if terre[0] NE -1 then gdep[terre] = valmask |
---|
76 | endif |
---|
77 | ; |
---|
78 | if keyword_set(key_performance) THEN print, 'temps level2depth', systime(1)-tempsun |
---|
79 | return, gdep |
---|
80 | end |
---|