source: trunk/SRC/ToBeReviewed/CALCULS/projectondepth.pro @ 134

Last change on this file since 134 was 134, checked in by navarro, 18 years ago

change *.pro file properties (del eof-style, del executable, set keywords Id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:projectondepth
6;
7; PURPOSE: routine permettant de projeter un champ 3d suivant un
8; tableau de profondeurs.
9;
10; CATEGORY: sans boucles
11;
12; CALLING SEQUENCE:res=projectondepth(arrayin, depthin)
13;
14; INPUTS:
15;       arrayin: un tableau 3d dont la 3eme dimension doit etre egale
16;       a jpk
17;       depthin: un tableau 2d indiquant n chaque point a quel
18;       profondeur projeter
19;       
20; KEYWORD PARAMETERS:none
21;
22; OUTPUTS:res: un tableau 2d projection du tableau 3d suivant les
23; profondeurs indiquees par depthin
24;
25; COMMON BLOCKS:common.pro
26;
27; SIDE EFFECTS: points a !values.f_nan qd calcul impossible. points
28; terres masques a Valmask.
29;
30; RESTRICTIONS:
31;
32; EXAMPLE:
33;
34; on contruit un tableau de profondeurs possibles
35;   IDL> a=gdept[jpk-1]/(1.*jpi*jpj)*findgen(jpi,jpj)
36; on contruit un tableau a projeter sur ces profondeurs. pour le test
37; on construit un tableau 3d dont chaque vecteur suivant z est la
38; profondeur.
39;   IDL> arraytest=replicate(1,jpi*jpj)#gdept
40;   IDL> arraytest=reform(arraytest,jpi,jpj,jpk, /over)
41; on test la projection du tabeau profondeur sur la profondeur...
42;   IDL> plt, 1e6*(a-projectondepth(arraytest,a)),/nocontour
43;   ->champ nul a 1e-6 pres
44;
45;  verifcation en projettant la temperature sur la profondeur de la 20
46;  degres par exemple...
47;
48; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
49;                      15/6/2000
50;-
51;------------------------------------------------------------
52;------------------------------------------------------------
53;------------------------------------------------------------
54FUNCTION projectondepth, arrayin, depthin
55;
56  compile_opt idl2, strictarrsubs
57;
58   tempsun = systime(1)         ; pour key_performance
59@common
60;------------------------------------------------------------
61   depth = litchamp(depthin)
62   array = litchamp(arrayin)
63; petites verifications
64   tailledepth = size(depth)
65   taillearray = size(array)
66   if tailledepth[0] NE 2 THEN return, report('Depth array must have 2 dimensions')
67   if taillearray[0] NE 3 THEN return, report('Array in must have 3 dimensions')
68; verification de la coherence entre la taille du tableau et le
69; domaine
70   grille, mask, -1, -1, -1,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz
71   case 1 of
72      tailledepth[1] eq jpi and tailledepth[2] eq jpj:depth=depth[firstx:lastx, firsty:lasty]
73      tailledepth[1] eq  nx and tailledepth[2] eq  ny:
74      else:return, report('Probleme d''adequation entre les tailles du domaine et celle du tableau de profondeur')
75   endcase
76   case 1 OF
77      taillearray[3] NE jpk:return, report('Le tableau 3d doit avoir sa 3eme dimension egale a jpk')
78      taillearray[1] eq jpi and taillearray[2] eq jpj:array=array[firstx:lastx, firsty:lasty, *]
79      taillearray[1] eq  nx and taillearray[2] eq  ny:
80      else:return, report('Probleme d''adequation entre les tailles du domaine et celle du tableau de profondeur')
81   endcase
82;
83; c''est parti
84;
85   flevel = depth2floatlevel(depth)
86; on vire les points a !values.f_nan
87   notanumber = where(finite(flevel, /nan) EQ 1)
88   if notanumber[0] NE -1 then flevel[notanumber] = 0
89; on seuil (vire les points terres a valmask par ex)
90   flevel = 0 > flevel < (jpk-1)
91;
92   indexup = level2index(floor(flevel))
93   indexlow = nx*ny+indexup
94   out = where(indexlow GE nx*ny*jpk-1)
95   if out[0] NE -1 then indexlow[out] = indexlow[out]-nx*ny
96;
97   weight = flevel-floor(flevel)
98   res = array[indexup]
99   res = res+weight*(array[indexlow]-res)
100;
101; on replace les points a !values.f_nan
102   if notanumber[0] NE -1 then res[notanumber] = !values.f_nan
103   if out[0] NE -1 then res[out] = !values.f_nan
104; on masque les points terres a valmask
105   if n_elements(valmask) EQ 0 then valmask = 1e20
106   terre = where((temporary(mask))[*, *, 0] EQ 0)
107   if terre[0] NE -1 then res[terre] = valmask
108;------------------------------------------------------------
109   if keyword_set(key_performance) THEN print, 'temps projectondepth', systime(1)-tempsun
110   return, res
111end
Note: See TracBrowser for help on using the repository browser.