==== Reading and writing files ==== === Ascii === === Binary === ''import numpy as np\\ fd = open(filename , 'rb') #'r' for read, 'b' for binary\\ read_data = np.fromfile(fd, np.float32) #'float32' or one of the other numpy-datatypes\\ shape_xy = (270,207)\\ tau = read_data.reshape(shape_xy)\\ fd.close()'' == Direct reading of bzipped files == ''import numpy as np\\ from bz2 import * \\ fd = BZ2File(filename, 'r') \\ read_data = array(fromstring(fd.read(), np.dtype('f4'))) #fd.read() returns a string, fromstring converts to float32\\ shape_xy = (270,207)\\ tau = read_data.reshape(shape_xy)\\ fd.close()'' === Netcdf ===