; ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME:level2depht ; ; PURPOSE: permet de passer d''un tableau 2d de niveau au ; tableau 2d de profondeur correspondant a ces niveaux ; ; CATEGORY: SANS BOUCLE ; ; CALLING SEQUENCE: res=level2depth(niveau) ; ; INPUTS: niveau tableau 2d de niveaux seuil (ou une structure repondant ; aux criteres de litchamp) ; ; KEYWORD PARAMETERS: ; /NOMASK: pour ne pas masquer les points terres ; ; OUTPUTS: un tableau 2d contenant des profondeurs ; ; COMMON BLOCKS: ; common.pro ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) ; 17/6/1999 ; 14/6/2000 accepte !values.f_nan ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ FUNCTION level2depth, tab, NOMASK = nomask tempsun = systime(1) ; pour key_performance @common ;------------------------------------------------------------ ; lecture du champ d''entree et recuperation de la taille du sous ; domaine utilise ;------------------------------------------------------------ niveaux = litchamp(tab) grille,mask,glam,gphi,gdep,nx,ny,nz,premierx,premiery,premierz,dernierx,derniery,dernierz ;--------------------------------------------------------------- ; verification de la coherence entre la taille du tableau et le domaine definit par domdef ;--------------------------------------------------------------- taille = size(niveaux) if taille[0] NE 2 then return, report('le champ en entree doit contenir un tableau 2d') case 1 of taille[1] eq jpi and taille[2] eq jpj:niveaux=niveaux[premierx:dernierx, premiery:derniery] taille[1] eq nx and taille[2] eq ny: else:return, report('Probleme d''adequation entre les tailles du domaine et celle du champ.') endcase ;--------------------------------------------------------------- wherenan = where(finite(niveaux, /nan) EQ 1) if wherenan[0] NE -1 then niveaux[wherenan] = 0 niveaux = 0 > niveaux < (jpk-1) ;--------------------------------------------------------------- gdep = replicate(1, nx*ny)#gdep niveaux = lindgen(nx*ny)+(nx*ny)*niveaux gdep = reform(gdep[niveaux], nx, ny) ; if wherenan[0] NE -1 then gdep[wherenan] = !values.f_nan if NOT keyword_set(nomask) then begin if n_elements(valmask) EQ 0 then valmask = 1e20 terre = where(mask[*, *, 0] EQ 0) if terre[0] NE -1 then gdep[terre] = valmask endif ; if keyword_set(key_performance) THEN print, 'temps level2depth', systime(1)-tempsun return, gdep end