;+
;
; @file_comments
; Rather comparable to depth2level but here, the calculated level
; is in float.
; For example, the level 5.4 correspond to a depth equal
; to gdep[5]+.4*(gdep[6]-gdep[5])
;
; @categories
; Without loop
;
; @param TAB {in}{required}
; 2d depth array (or a structure respecting litchamp criterion)
;
; @keyword NOMASK
; To do not mask land points
;
; @returns
; An 2d array of float containing levels's values.
;
; @uses
; common.pro
;
; @restrictions
; Accept values at !values.f_nan and mask land points at valmask.
;
; @examples
; IDL> a=(jpk-1)/(1.*jpi*jpj)*findgen(jpi,jpj)
; IDL> plt, 1e6*(a-floatlevel2depth(depth2floatlevel(a))),/nocontour
;
; ->champ nul a 1e-6 pres
;
; @history
; Sebastien Masson (smasson\@lodyc.jussieu.fr)
; 15/06/2000
;
; @version
; $Id$
;
;-
FUNCTION depth2floatlevel, tab, NOMASK=nomask
;
compile_opt idl2, strictarrsubs
;
tempsun = systime(1) ; for key_performance
@common
;------------------------------------------------------------
depthin = litchamp(tab)
;
levelup = depth2level(depthin, /UPPER, /nomask)
depthup = level2depth(levelup, /nomask)
;
levellow = depth2level(depthin, /lower, /nomask)
depthlow = level2depth(levellow, /nomask)
; calculate the distance depthlow-depthup and management of the case
; of this distance is null or equal to !values.f_nan
divi = depthlow-depthup
nan = where(finite(divi) EQ 0)
if nan[0] NE -1 then divi[nan] = 0
nan = where(divi EQ 0)
if nan[0] NE -1 then divi[nan] = !values.f_nan
; calculation of the result
res = levelup+(depthin-depthup)/divi
; We mask land point at valmask
if NOT keyword_set(nomask) then begin
grille,mask
if n_elements(valmask) EQ 0 then valmask = 1e20
terre = where((temporary(mask))[*, *, 0] EQ 0)
if terre[0] NE -1 then res[terre] = valmask
endif
;------------------------------------------------------------
if keyword_set(key_performance) THEN print, 'temps depth2floatlevel', systime(1)-tempsun
;
return, res
end