Changeset 3456


Ignore:
Timestamp:
Aug 4, 2006, 5:04:14 PM (19 years ago)
Author:
duncan
Message:

change output from speed to velocity

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • development/dam_2006/project.py

    r3423 r3456  
    3939#gaugetimeseries = gaugedir + 'onslow'
    4040depth_filename = outputtimedir + "depth.csv"
    41 velocity_filename = outputtimedir + "velocity.csv"
     41velocity_x_filename = outputtimedir + "velocity_x.csv"
     42velocity_y_filename = outputtimedir + "velocity_y.csv"
    4243
    4344
  • development/dam_2006/run_dam.py

    r3447 r3456  
    126126                        points,
    127127                        project.depth_filename,
    128                         project.velocity_filename)
     128                        project.velocity_x_filename,
     129                        project.velocity_y_filename)
    129130
    130131#-------------------------------------------------------------
  • inundation/fit_interpolate/interpolate.py

    r3452 r3456  
    281281                        points,
    282282                        depth_file,
    283                         velocity_file,
     283                        velocity_x_file,
     284                        velocity_y_file,
    284285                        #quantities = ['depth', 'velocity'],
    285286                        verbose=True,
     
    309310   
    310311    depth_writer = writer(file(depth_file, "wb"))
    311     velocity_writer = writer(file(velocity_file, "wb"))
     312    velocity_x_writer = writer(file(velocity_x_file, "wb"))
     313    velocity_y_writer = writer(file(velocity_y_file, "wb"))
    312314    # Write heading
    313315    heading = [str(x[0])+ ':' + str(x[1]) for x in points]
    314316    heading.insert(0, "time")
    315317    depth_writer.writerow(heading)
    316     velocity_writer.writerow(heading)
    317     #for row in someiterable:
    318         #csvwriter.writerow(row)
     318    velocity_x_writer.writerow(heading)
     319    velocity_y_writer.writerow(heading)
     320   
    319321    for time in callable_sww.get_time():
    320322        depths = [time]
    321         velocitys = [time]
     323        velocity_xs = [time]
     324        velocity_ys = [time]
    322325        for point_i, point in enumerate(points):
    323326            quantities = callable_sww(time,point_i)
     
    326329            w = quantities[0]
    327330            z = quantities[1]
    328             uh = quantities[2]
    329             vh = quantities[3]
     331            momentum_x = quantities[2]
     332            momentum_y = quantities[3]
    330333            depth = w - z
    331334             
    332             if w == NAN or z == NAN or uh == NAN or vh == NAN:
    333                 velocity = NAN
     335            if w == NAN or z == NAN or momentum_x == NAN:
     336                velocity_x = NAN
    334337            else:
    335                 momentum = sqrt(uh*uh + vh*vh)
    336338                if depth > 1.e-30: # use epsilon
    337                     velocity = momentum / depth  #Absolute velocity
     339                    velocity_x = momentum_x / depth  #Absolute velocity
    338340                else:
    339                     velocity = 0
     341                    velocity_x = 0
     342            if w == NAN or z == NAN or momentum_y == NAN:
     343                velocity_y = NAN
     344            else:
     345                if depth > 1.e-30: # use epsilon
     346                    velocity_y = momentum_y / depth  #Absolute velocity
     347                else:
     348                    velocity_y = 0
    340349            depths.append(depth)
    341             velocitys.append(velocity)
     350            velocity_xs.append(velocity_x)
     351            velocity_ys.append(velocity_y)
    342352        depth_writer.writerow(depths)
    343         velocity_writer.writerow(velocitys)
     353        velocity_x_writer.writerow(velocity_xs)
     354        velocity_y_writer.writerow(velocity_ys)
    344355
    345356class Interpolation_function:
  • inundation/fit_interpolate/test_interpolate.py

    r3452 r3456  
    14091409        points = [[5.0,1.],[0.5,2.]]
    14101410        depth_file = tempfile.mktemp(".csv")
    1411         velocity_file = tempfile.mktemp(".csv")
    1412         interpolate_sww2csv(sww.filename, points, depth_file, velocity_file,
     1411        velocity_x_file = tempfile.mktemp(".csv")
     1412        velocity_y_file = tempfile.mktemp(".csv")
     1413        interpolate_sww2csv(sww.filename, points, depth_file,
     1414                            velocity_x_file,
     1415                            velocity_y_file,
    14131416                            verbose=False)
    14141417
    14151418        depth_answers_array = [[0.0, 6.0, 1.5], [2.0, 15., 10.5]]
    1416         velocity_answers_array = [[0.0, 5./6.0, 5./1.5], [2.0, 5./15.,5./10.5]]
     1419        velocity_x_answers_array = [[0.0, 3./6.0, 3./1.5],
     1420                                    [2.0, 3./15., 3/10.5]]
     1421        velocity_y_answers_array = [[0.0, 4./6.0, 4./1.5],
     1422                                    [2.0, 4./15., 4./10.5]]
    14171423        depth_file_handle = file(depth_file)
    14181424        depth_reader = csv.reader(depth_file_handle)
    14191425        depth_reader.next()
    1420         velocity_file_handle = file(velocity_file)
    1421         velocity_reader = csv.reader(velocity_file_handle)
    1422         velocity_reader.next()
     1426        velocity_x_file_handle = file(velocity_x_file)
     1427        velocity_x_reader = csv.reader(velocity_x_file_handle)
     1428        velocity_x_reader.next()
    14231429        for depths, velocitys, depth_answers, velocity_answers in map(None,
    14241430                                              depth_reader,
    1425                                               velocity_reader,
     1431                                              velocity_x_reader,
    14261432                                              depth_answers_array,
    1427                                               velocity_answers_array):
     1433                                              velocity_x_answers_array):
    14281434            for i in range(len(depths)):
    14291435                #print "depths",depths[i]
     
    14351441                assert allclose(float(velocitys[i]), velocity_answers[i]), msg
    14361442
     1443        velocity_y_file_handle = file(velocity_y_file)
     1444        velocity_y_reader = csv.reader(velocity_y_file_handle)
     1445        velocity_y_reader.next()
     1446        for velocitys, velocity_answers in map(None,
     1447                                              velocity_y_reader,
     1448                                              velocity_y_answers_array):
     1449            for i in range(len(depths)):
     1450                #print "depths",depths[i]
     1451                #print "depth_answers",depth_answers[i]
     1452                #print "velocitys",velocitys[i]
     1453                #print "velocity_answers_array", velocity_answers[i]
     1454                msg = 'Interpolation failed'
     1455                assert allclose(float(depths[i]), depth_answers[i]), msg
     1456                assert allclose(float(velocitys[i]), velocity_answers[i]), msg
     1457               
    14371458        # clean up
    14381459        depth_file_handle.close()
    1439         velocity_file_handle.close()
     1460        velocity_y_file_handle.close()
     1461        velocity_x_file_handle.close()
    14401462        #print "sww.filename",sww.filename
    14411463        os.remove(sww.filename)
    14421464        os.remove(depth_file)
    1443         os.remove(velocity_file)
     1465        os.remove(velocity_x_file)
     1466        os.remove(velocity_y_file)
    14441467#-------------------------------------------------------------
    14451468if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.