''' Created on Jul 17, 2013 @author: dominiquef ''' def get_UBC_mesh(meshfile): """ Read UBC mesh file and extract parameters Works for the condenced version (20 * 3) --> [20 20 20] """ fid = open(meshfile,'r') from numpy import zeros # Go through the log file and extract data and the last achieved misfit for ii in range (1, 6): line = fid.readline() line = line.split(' ') # First line: number of cells in i, j, k if ii == 1: numcell=[] for jj in range(len(line)): t = int(line[jj]) numcell.append(t) nX = numcell[0] nY = numcell[1] nZ = numcell[2] # Second line: origin coordinate (X,Y,Z) elif ii==2: origin = [] for jj in range(len(line)): t = float(line[jj]) origin.append(t) # Other lines for the xn, yn, zn (nodes location) elif ii==3: xn=zeros((nX+1,1), dtype=float) xn[0] = origin[0] count_entry = 0; count = 0; while (count