;+ ; ; @file_comments ; Rather comparable to level2depth. ; It is the invert function of depth2floatlevel. ; ; @categories ; Without loop ; ; @param TAB ; 2d array of sill levels (or a structure respecting litchamp criterions) ; ; @keyword NOMASK ; To do not mask land points ; ; @returns ; 2d array containing depths ; ; @uses ; common ; ; @examples ; IDL> a=gdept[jpk-1]/(1.*jpi*jpj)*findgen(jpi,jpj) ; IDL> plt, 1e6*(a-floatlevel2depth(depth2floatlevel(a))),/nocontour ; ; ->null field at 1e-6 pres ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; 15/6/2000 ; ; @version ; $Id$ ; ;- FUNCTION floatlevel2depth, tab, NOMASK=nomask ; compile_opt idl2, strictarrsubs ; tempsun = systime(1) ; To key_performance @common ;------------------------------------------------------------ flevelin = litchamp(tab) ; We delete points at !values.f_nan notanumber = where(finite(flevelin, /nan) EQ 1) if notanumber[0] NE -1 then flevelin[notanumber] = 0 ; We sill (delete land points at valmask for example) flevelin = 0 > flevelin < (jpk-1) ; We calculate the depth depthup = level2depth(floor(flevelin), /nomask) depthlow= level2depth(ceil(flevelin), /nomask) weight = flevelin-floor(flevelin) res = depthup+weight*(depthlow-depthup) ; We put back points at !values.f_nan if notanumber[0] NE -1 then res[notanumber] = !values.f_nan ; We mask land points 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 floatlevel2depth', systime(1)-tempsun ; return, res end