- Timestamp:
- Jun 6, 2008, 5:33:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/Hinwood_2008/prepare_time_boundary.py
r5392 r5395 91 91 92 92 93 def combine_velocity_depth(velocity_file, depth_file, out_file ):93 def combine_velocity_depth(velocity_file, depth_file, out_file, metadata_dic): 94 94 """ 95 95 … … 101 101 102 102 The format for the velocity file is; 103 [time, sec], [x-velocity +ve is towards the wave generator, m/sec],103 [time, sec], [x-velocity +ve is towards the wave generator, cm/sec], 104 104 [y-velocity], [z-velocity] 105 105 106 106 The format for the pressure file is 107 107 [time, sec], [mm above SWL for sensor A], many other sensors... 108 109 The format of the output file is; 110 [time, sec], [m above SWL for sensor A], 111 [x-velocity +ve is towards the shore, m/sec], 112 [y-velocity +ve is towards the left of the tank, looking from the 113 generator to the shore, m/sec] 114 115 108 116 """ 109 117 missing = 1e+20 … … 162 170 missing=missing/1000.00 # Do to missing what is done to depths_at_vtimes 163 171 x_velocities = ensure_numeric(x_velocities) 164 x_velocities = x_velocities * -1.0 # Swap axis around 172 # Swap axis around convert cm/sec to m/sec 173 x_velocities = x_velocities * -0.01 165 174 y_velocities = ensure_numeric(y_velocities) 166 y_velocities = y_velocities * -1.0 # Swap axis around 175 # Swap axis around convert cm/sec to m/sec 176 y_velocities = y_velocities * -0.01 167 177 168 178 fid = open(out_file,'w') … … 177 187 # Make the times start at zero. 178 188 if start_time is None: 179 start_time = vtimes[i] 180 fid.write(str(vtimes[i]-start_time) \ 189 start_time = vtimes[i] 190 final_time = vtimes[i]-start_time 191 fid.write(str(final_time) \ 181 192 + ',' + str(depths_at_vtimes[i]) \ 182 193 + ',' + str(x_velocities[i]) \ … … 187 198 # Since there is a new time reference save the depth info using this 188 199 # new reference. 189 fid = open(depth_file[:-4] + '_ new_time'+depth_file[-4:],'w')200 fid = open(depth_file[:-4] + '_exp_depth.csv','w') 190 201 sensors[:,0] -= start_time 191 202 #print "depth_file", depth_file 192 203 #print "start_time", start_time 193 for i in xrange(len(dtimes)): 194 fid.write(str(sensors[i,0])) 195 for j in xrange(1,len(sensors[0])): 196 fid.write(' ' + str(sensors[i,j])) 204 205 # Write a header 206 fid.write('Time') 207 for gauge_x in metadata_dic['gauge_x']: 208 fid.write(',' + str(gauge_x)) 209 fid.write('\n') 210 for i in xrange(len(dtimes)): 211 fid.write(str(sensors[i,0])) # Time 212 # Don't write sensor A. 213 # It is the boundary condition. 214 for j, bed_elevation in map(None,xrange(2,len(sensors[0])), 215 metadata_dic['gauge_bed_elevation']): 216 # depth, m 217 gauge = sensors[i,j]/1000 - bed_elevation # Convert from mm to m 218 fid.write(',' + str(gauge)) 197 219 fid.write('\n') 198 220 fid.close() 221 return final_time 199 222 200 223 def prepare_time_boundary(metadata_dic, raw_data_dir, output_dir): … … 205 228 depth_file = join(raw_data_dir,scenario_id+'pressfilt.txt') 206 229 out_file = join(output_dir, scenario_id+'_boundary.csv') 207 208 combine_velocity_depth(velocity_file, depth_file, out_file) 209 tsm_file = out_file[:-4] + '.tsm' 230 #out_depth_file = join(output_dir, scenario_id+'_exp_depth.csv') 231 232 final_time = combine_velocity_depth(velocity_file, depth_file, out_file, 233 metadata_dic) 210 234 if metadata_dic['xleft'][1] >= 0.0: 211 235 # This should be a -ve value, since the still water level is the 212 236 # z origin. 213 print "Warning: The z origin seems incorrect." 214 237 print "Warning: The z origin seems incorrect." 238 tsm_file = out_file[:-4] + '.tsm' 215 239 csv2tms(tsm_file, metadata_dic['xleft'][1]) 216 240 return final_time 217 241 218 242 #-------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.