;+ ; ; @file_comments ; We want, from a 3d matrix, to extract a 2d (x,y) array whose each element ; has been extract from a level specified by the 2d level array (typically, ; we want to obtain the salinity along an isopycn we have repered by its level). ; level2index is a function who give, in function of level, a 2d indexes array ; which will allow to extract the 2d array from the 3d array... ; ; @categories ; Without loop ; ; @param LEVEL {in}{required}{type=2d array} ; A 2d level array ; ; @returns ; a 2d indexes array ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; 24/11/1999 ; ; @version ; $Id$ ; ;- ; FUNCTION level2index, level ; An element of 3d array (whose the two first dimensions are nx and ny) whose ; coordinates are i, j and k have for index in the same 3d array i + j*nx + k*(nx*ny) ; level given, for each point of level, we know i, j et k, ; so we can calculate the index ; compile_opt idl2, strictarrsubs ; taille = size(level) nx = taille[1] ny = taille[2] ; array k*(nx*ny) tabknxny = (nx*ny)*long(level) ; ; return, lindgen(nx, ny)+tabknxny end