Changeset 7810 for trunk/anuga_core/source/anuga/fit_interpolate
- Timestamp:
- Jun 8, 2010, 2:31:04 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/fit_interpolate/interpolate.py
r7778 r7810 1234 1234 1235 1235 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 this1242 1243 Read in an sww file.1244 1245 Input;1246 file_name - the sww file1247 1248 Output;1249 x - Vector of x values1250 y - Vector of y values1251 z - Vector of bed elevation1252 volumes - Array. Each row has 3 values, representing1253 the vertices that define the volume1254 time - Vector of the times where there is stage information1255 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, msg1260 1261 #FIXME Have this reader as part of data_manager?1262 1263 from Scientific.IO.NetCDF import NetCDFFile1264 import tempfile1265 import sys1266 import os1267 1268 #Check contents1269 #Get NetCDF1270 1271 # see if the file is there. Throw a QUIET IO error if it isn't1272 # I don't think I could implement the above1273 1274 #throws prints to screen if file not present1275 junk = tempfile.mktemp(".txt")1276 fd = open(junk,'w')1277 stdout = sys.stdout1278 sys.stdout = fd1279 fid = NetCDFFile(file_name, netcdf_mode_r)1280 sys.stdout = stdout1281 fd.close()1282 #clean up1283 os.remove(junk)1284 1285 # Get the variables1286 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 arrays1297 quantities = {}1298 for name in keys:1299 quantities[name] = fid.variables[name][:]1300 1301 fid.close()1302 return x, y, volumes, time, quantities1303 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.