Changeset 6314 for anuga_core


Ignore:
Timestamp:
Feb 12, 2009, 10:11:02 AM (16 years ago)
Author:
kristy
Message:

Fixed get_timeseries so that it runs with all sww files, I also added time to the output of the csv file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r6277 r6314  
    13111311            thisfile = file_loc[j] + sep + 'gauges_time_series' + '_' \
    13121312                       + gaugeloc + '.csv'
    1313             fid_out = open(thisfile, 'w')
    1314             s = 'Time, Stage, Momentum, Speed, Elevation, xmom, ymom, Bearing \n'
    1315             fid_out.write(s)
     1313            if j == 0:
     1314                fid_out = open(thisfile, 'w')
     1315                s = 'Time, Stage, Momentum, Speed, Elevation, xmom, ymom, Bearing \n'
     1316                fid_out.write(s)           
    13161317
    13171318            #### generate quantities #######
     
    23732374##
    23742375# @brief ??
    2375 # @param sww_file ??
     2376# @param ??
    23762377# @param gauge_file ??
    23772378# @param out_name ??
     
    24912492                                 base_name=base,
    24922493                                 verbose=verbose)
     2494    print 'sww files just after get_all_swwfiles()', sww_files
     2495    # fudge to get SWW files in 'correct' order, oldest on the left
     2496    sww_files.sort()
    24932497
    24942498    if verbose:
     
    25072511    heading = [quantity for quantity in quantities]
    25082512    heading.insert(0,'time')
     2513    heading.insert(1,'hours')
    25092514
    25102515    #create a list of csv writers for all the points and write header
    25112516    points_writer = []
    2512     for i,point in enumerate(points):
     2517    for point_i,point in enumerate(points):
    25132518        points_writer.append(writer(file(dir_name + sep + gauge_file
    2514                                          + point_name[i] + '.csv', "wb")))
    2515         points_writer[i].writerow(heading)
     2519                                         + point_name[point_i] + '.csv', "wb")))
     2520        points_writer[point_i].writerow(heading)
    25162521   
    25172522    if verbose: print 'Writing csv files'
     2523
     2524    quake_offset_time = None
    25182525
    25192526    for sww_file in sww_files:
    25202527        sww_file = join(dir_name, sww_file+'.sww')
     2528        print 'sww file = ',sww_file
    25212529        callable_sww = file_function(sww_file,
    25222530                                     quantities=core_quantities,
     
    25242532                                     verbose=verbose,
    25252533                                     use_cache=use_cache)
    2526    
    2527    
     2534
     2535        if quake_offset_time is None:
     2536            quake_offset_time = callable_sww.starttime
     2537
    25282538        for time in callable_sww.get_time():
     2539            print 'time = ', str(time)
    25292540            for point_i, point in enumerate(points_array):
     2541                print 'gauge_file = ', str(point_name[point_i])
     2542                print 'point_i = ', str(point_i), ' point is = ', str(point)
    25302543                #add domain starttime to relative time.
    2531                 points_list = [time + callable_sww.starttime]
     2544                quake_time = time + quake_offset_time
     2545                points_list = [quake_time, quake_time/3600.]# fudge around SWW time bug
     2546                print 'point list = ', str(points_list)
    25322547                point_quantities = callable_sww(time,point_i)
     2548                print 'point quantities = ', str(point_quantities)
    25332549               
    25342550                for quantity in quantities:
     
    25792595                                                            point_quantities[3]))
    25802596
    2581             points_writer[point_i].writerow(points_list)
     2597                print 'point list before write (writer %s) = %s' % (str(point_name[point_i]), str(points_list))
     2598                points_writer[point_i].writerow(points_list)
    25822599           
    25832600
Note: See TracChangeset for help on using the changeset viewer.