compress f1
BoaF1.f90
! NAM: compress (subroutine) ! DES: compress array based on mask ! INP: data_input (f): 1-D array with data to be returned where flag = flag_value ! flag (i): 1-D array, must be same size as data_input ! flag_value (i): select data where flag=flag_value ! OUT: tuple (x,ii): 1-D array of same size as data_input where first n elements are ! those of data_input where flag = flag_value ! HIS: FB040430 created ! USE: ! Unfortunately it is not possible to pass from fortran to python an output ! array the size of which is computed in fortran. Therefore we must truncate ! the returned array at the size of the selected true mask elements. ! ! Example: ! input_array = array(range(5),'f') ! flag_array = array([0,1,0,1,0],'i') ! compress_array,nmax = f90.f1.compress(input_array,flag_array,1) ! compress_array = compress_array[0:nmax] ! print "nmax compressed:",nmax,compress_array