source: trunk/CALCULS/projectondepth.pro @ 2

Last change on this file since 2 was 2, checked in by opalod, 22 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
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 2o
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   tempsun = systime(1)         ; pour key_performance
56@common
57;------------------------------------------------------------
58   depth = litchamp(depthin)
59   array = litchamp(arrayin)
60; petites verifications
61   tailledepth = size(depth)
62   taillearray = size(array)
63   if tailledepth[0] NE 2 THEN return, report('Depth array must have 2 dimensions')
64   if taillearray[0] NE 3 THEN return, report('Array in must have 3 dimensions')
65; verification de la coherence entre la taille du tableau et le
66; domaine
67   grille,mask,glam,gphi,gdep,nx,ny,nz,premierx,premiery,premierz,dernierx,derniery,dernierz
68   case 1 of
69      tailledepth[1] eq jpi and tailledepth[2] eq jpj:depth=depth[premierx:dernierx, premiery:derniery]
70      tailledepth[1] eq  nx and tailledepth[2] eq  ny:
71      else:return, report('Probleme d''adequation entre les tailles du domaine et celle du tableau de profondeur')
72   endcase
73   case 1 OF
74      taillearray[3] NE jpk:return, report('Le tableau 3d doit avoir sa 3eme dimension egale a jpk')
75      taillearray[1] eq jpi and taillearray[2] eq jpj:array=array[premierx:dernierx, premiery:derniery, *]
76      taillearray[1] eq  nx and taillearray[2] eq  ny:
77      else:return, report('Probleme d''adequation entre les tailles du domaine et celle du tableau de profondeur')
78   endcase
79;
80; c''est parti
81;
82   flevel = depth2floatlevel(depth)
83; on vire les points a !values.f_nan
84   notanumber = where(finite(flevel, /nan) EQ 1)
85   if notanumber[0] NE -1 then flevel[notanumber] = 0
86; on seuil (vire les points terres a valmask par ex)
87   flevel = 0 > flevel < (jpk-1)
88;
89   indexup = level2index(floor(flevel))
90   indexlow = nx*ny+indexup
91   out = where(indexlow GE nx*ny*jpk-1)
92   if out[0] NE -1 then indexlow[out] = indexlow[out]-nx*ny
93;
94   weight = flevel-floor(flevel)
95   res = array[indexup]
96   res = res+weight*(array[indexlow]-res)
97;
98; on replace les points a !values.f_nan
99   if notanumber[0] NE -1 then res[notanumber] = !values.f_nan
100   if out[0] NE -1 then res[out] = !values.f_nan
101; on masque les points terres a valmask
102   grille,mask
103   if n_elements(valmask) EQ 0 then valmask = 1e20
104   terre = where((temporary(mask))[*, *, 0] EQ 0)
105   if terre[0] NE -1 then res[terre] = valmask
106;------------------------------------------------------------
107   if keyword_set(key_performance) THEN print, 'temps projectondepth', systime(1)-tempsun
108   return, res
109end
Note: See TracBrowser for help on using the repository browser.