source: trunk/SRC/ToBeReviewed/CALCULS/depth2floatlevel.pro @ 424

Last change on this file since 424 was 371, checked in by pinsard, 16 years ago

improvements of headers (alignments of IDL prompt in examples)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1;+
2;
3; @file_comments
4; Rather comparable to <pro>depth2level</pro> but here, the calculated level
5; is in float.
6; For example, the level 5.4 correspond to a depth equal
7; to gdep[5]+.4*(gdep[6]-gdep[5])
8;
9; @categories
10; Without loop
11;
12; @param TAB {in}{required}
13; 2d depth array (or a structure respecting <pro>litchamp</pro> criterion)
14;
15; @keyword NOMASK
16; To do not mask land points
17;
18; @returns
19; An 2d array of float containing levels's values.
20;
21; @uses
22; <pro>common</pro>
23;
24; @restrictions
25; Accept values at !values.f_nan and mask land points at valmask.
26;
27; @examples
28;
29;   IDL> a=(jpk-1)/(1.*jpi*jpj)*findgen(jpi,jpj)
30;   IDL> plt, 1e6*(a-floatlevel2depth(depth2floatlevel(a))),/nocontour
31;
32;  ->champ nul a 1e-6 pres
33;
34; @history
35; Sebastien Masson (smasson\@lodyc.jussieu.fr)
36;                      15/06/2000
37;
38; @version
39; $Id$
40;
41;-
42FUNCTION depth2floatlevel, tab, NOMASK=nomask
43;
44  compile_opt idl2, strictarrsubs
45;
46   tempsun = systime(1)         ; for key_performance
47@common
48;------------------------------------------------------------
49   depthin = litchamp(tab)
50;
51   levelup = depth2level(depthin, /UPPER, /nomask)
52   depthup = level2depth(levelup, /nomask)
53;
54   levellow = depth2level(depthin, /lower, /nomask)
55   depthlow = level2depth(levellow, /nomask)
56; calculate the distance depthlow-depthup and management of the case
57; of this distance is null or equal to !values.f_nan
58   divi = depthlow-depthup
59   nan = where(finite(divi) EQ 0)
60   if nan[0] NE -1 then divi[nan] = 0
61   nan = where(divi EQ 0)
62   if nan[0] NE -1 then divi[nan] = !values.f_nan
63; calculation of the result
64   res = levelup+(depthin-depthup)/divi
65; We mask land point at valmask
66   if NOT keyword_set(nomask) then begin
67      grille,mask
68      if n_elements(valmask) EQ 0 then valmask = 1e20
69      terre = where((temporary(mask))[*, *, 0] EQ 0)
70      if terre[0] NE -1 then res[terre] = valmask
71   endif
72;------------------------------------------------------------
73   if keyword_set(key_performance) THEN print, 'temps depth2floatlevel', systime(1)-tempsun
74;
75   return, res
76end
Note: See TracBrowser for help on using the repository browser.