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