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