Changeset 5586
- Timestamp:
- Jul 30, 2008, 4:59:59 PM (15 years ago)
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/culvert_flows/culvert_class.py
r5585 r5586 107 107 label += '_' + str(id(self)) 108 108 109 # Open log file for storing some specific results...110 self.log_filename = label + '.log'111 109 self.label = label 112 113 # Print something 110 111 # File for storing culvert quantities 112 self.timeseries_filename = label + '_timeseries.csv' 113 fid = open(self.timeseries_filename, 'w') 114 fid.write('time, E0, E1, Velocity, Discharge\n') 115 fid.close() 116 117 # Log file for storing general textual output 118 self.log_filename = label + '.log' 114 119 log_to_file(self.log_filename, self.label) 115 120 log_to_file(self.log_filename, description) … … 142 147 bounding_polygon = domain.get_boundary_polygon() 143 148 for key in P.keys(): 144 print 'Key', key145 149 if key in ['exchange_polygon0', 146 150 'exchange_polygon1', … … 149 153 for point in P[key]: 150 154 151 print 'Passing in:', point152 155 msg = 'Point %s in polygon %s for culvert %s did not'\ 153 156 %(str(point), key, self.label) … … 271 274 ux = xmomentum/(depth+velocity_protection/depth) # Velocity (x-direction) 272 275 uy = ymomentum/(depth+velocity_protection/depth) # Velocity (y-direction) 273 print 'Velocity in culvert:', ux, uy, depth, xmomentum, ymomentum276 #print 'Velocity in culvert:', ux, uy, depth, xmomentum, ymomentum 274 277 v = mean(sqrt(ux**2+uy**2)) # Average velocity 275 278 w = mean(stage) # Average stage … … 390 393 log_to_file(log_filename, s) 391 394 395 # Log timeseries to file 396 fid = open(self.timeseries_filename, 'a') 397 fid.write('%f, %f, %f, %f, %f\n'\ 398 %(time, 399 openings[0].total_energy, 400 openings[1].total_energy, 401 barrel_velocity, 402 Q)) 403 fid.close() 404 405 # Update momentum 392 406 delta_t = time - self.last_time 393 407 if delta_t > 0.0: -
anuga_core/source/anuga/shallow_water/data_manager.py
r5582 r5586 953 953 954 954 955 def csv2array(file_name): 956 """Convert CSV files of the form 957 958 time, discharge, velocity 959 0.0, 1.2, 0.0 960 0.1, 3.2, 1.1 961 ... 962 963 to a dictionary of numeric arrays. 964 965 966 See underlying function csv2dict for more details. 967 968 """ 969 970 971 X, _ = csv2dict(file_name) 972 973 Y = {} 974 for key in X.keys(): 975 Y[key] = array([float(x) for x in X[key]]) 976 977 return Y 978 979 955 980 def csv2dict(file_name, title_check_list=None): 956 981 """ … … 961 986 Two dictionaries are returned. 962 987 963 WARNING: Va ules are returned as strings.988 WARNING: Values are returned as strings. 964 989 do this to change a list of strings to a list of floats 965 990 time = [float(x) for x in time] -
anuga_core/source/anuga/utilities/system_tools.py
r5436 r5586 7 7 import os 8 8 9 def log_to_file(filename, s, verbose= True):10 """Log string to open file descriptor9 def log_to_file(filename, s, verbose=False): 10 """Log string to file name 11 11 """ 12 12
Note: See TracChangeset
for help on using the changeset viewer.