Ignore:
Timestamp:
Jun 8, 2010, 2:31:04 PM (15 years ago)
Author:
James Hudson
Message:

Added aggressive psyco optimisation, fixed benchmark app to work with new API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/fit_interpolate/interpolate.py

    r7778 r7810  
    12341234
    12351235
    1236 ##
    1237 # @brief ??
    1238 # @param file_name Name of the .SWW file to read.
    1239 def read_sww(file_name):
    1240     """
    1241     obsolete - Nothing should be calling this
    1242 
    1243     Read in an sww file.
    1244 
    1245     Input;
    1246     file_name - the sww file
    1247 
    1248     Output;
    1249     x - Vector of x values
    1250     y - Vector of y values
    1251     z - Vector of bed elevation
    1252     volumes - Array.  Each row has 3 values, representing
    1253     the vertices that define the volume
    1254     time - Vector of the times where there is stage information
    1255     stage - array with respect to time and vertices (x,y)
    1256     """
    1257 
    1258     msg = 'Function read_sww in interpolat.py is obsolete'
    1259     raise Exception, msg
    1260 
    1261     #FIXME Have this reader as part of data_manager?
    1262 
    1263     from Scientific.IO.NetCDF import NetCDFFile
    1264     import tempfile
    1265     import sys
    1266     import os
    1267 
    1268     #Check contents
    1269     #Get NetCDF
    1270 
    1271     # see if the file is there.  Throw a QUIET IO error if it isn't
    1272     # I don't think I could implement the above
    1273 
    1274     #throws prints to screen if file not present
    1275     junk = tempfile.mktemp(".txt")
    1276     fd = open(junk,'w')
    1277     stdout = sys.stdout
    1278     sys.stdout = fd
    1279     fid = NetCDFFile(file_name, netcdf_mode_r)
    1280     sys.stdout = stdout
    1281     fd.close()
    1282     #clean up
    1283     os.remove(junk)
    1284 
    1285     # Get the variables
    1286     x = fid.variables['x'][:]
    1287     y = fid.variables['y'][:]
    1288     volumes = fid.variables['volumes'][:]
    1289     time = fid.variables['time'][:]
    1290 
    1291     keys = fid.variables.keys()
    1292     keys.remove("x")
    1293     keys.remove("y")
    1294     keys.remove("volumes")
    1295     keys.remove("time")
    1296      #Turn NetCDF objects into numeric arrays
    1297     quantities = {}
    1298     for name in keys:
    1299         quantities[name] = fid.variables[name][:]
    1300 
    1301     fid.close()
    1302     return x, y, volumes, time, quantities
    1303 
    1304 
    1305 #-------------------------------------------------------------
    1306 if __name__ == "__main__":
    1307     names = ["x","y"]
    1308     someiterable = [[1,2],[3,4]]
    1309     csvwriter = writer(file("some.csv", "wb"))
    1310     csvwriter.writerow(names)
    1311     for row in someiterable:
    1312         csvwriter.writerow(row)
Note: See TracChangeset for help on using the changeset viewer.