import numpy as np; import re; # regexp import matplotlib.pyplot as ma; ################################################################ # Airfoil : load profile of a wing # # Reads a file whose lines contain coordinates of points, # separated by an empty line. # Every line not containing a couple of floats is discarded. # Returns a couple constitued of the list of points of the # extrados and the intrados. def load_foil(file): f = open(file, 'r') matchline = lambda line: re.match(r"\s*([\d\.-]+)\s*([\d\.-]+)", line) extra = []; intra = [] rextra = False; rintra = False for line in f: m = matchline(line) if (m != None) and not(rextra): rextra = True if (m != None) and rextra and not(rintra): extra.append(m.groups()) if (m != None) and rextra and rintra: intra.append(m.groups()) if (m == None) and rextra: rintra = True ex = np.array(map(lambda t: float(t[0]),extra)) ey = np.array(map(lambda t: float(t[1]),extra)) ix = np.array(map(lambda t: float(t[0]),intra)) iy = np.array(map(lambda t: float(t[1]),intra)) return(ex,ey,ix,iy) (ex,ey,ix,iy) = load_foil("boe103.dat")