Changeset 2484


Ignore:
Timestamp:
Mar 3, 2006, 3:01:35 PM (19 years ago)
Author:
ole
Message:

Added timeseries extraction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • development/stochastic_study/run_model.py

    r2448 r2484  
    3131from pyvolution.data_manager import xya2pts
    3232from pyvolution.util import file_function
     33from caching.caching import cache
    3334
    3435# Application specific imports
     
    7576
    7677# Get prefitted realisations
     78
     79finaltime = 22.5
     80timestep = 0.05
     81
     82
     83
    7784realisation = 0
    7885for filename in os.listdir('.'):
     
    8592        # For each column (each realisation)
    8693        for i in range(V.shape[1]):
    87             name = project.basename + '_realisation_%d' %realisation
    88             domain.set_name(name)                     #Output name
     94            domain.set_name(project.basename)         #Output name
    8995            domain.set_quantity('elevation', V[:,i])  #Assign bathymetry
     96            domain.starttime = 0.0                    #Reset time
    9097
    9198            #---------------------------------------------------
     
    95102                  %(i, V.shape[1], filename)
    96103            t0 = time.time()
    97             for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5):
     104            for t in domain.evolve(yieldstep = timestep, finaltime = finaltime):
    98105                domain.write_time()
    99                 #domain.write_boundary_statistics(tags = 'wave')         
     106               
    100107       
    101108            print 'Realisation %d took %.2f seconds'\
    102109                  %(realisation, time.time()-t0)
    103110
    104             realisation += 1
     111
     112
     113
     114            #---------------------------------------------------
     115            # Now extract the 3 timeseries (Ch 5-7-9) and store them
     116            # in three files for this realisation
     117            gauges = [[4.521, 1.196],  [4.521, 1.696],  [4.521, 2.196]]
     118            gauge_names = ['ch5', 'ch7', 'ch9']
     119
     120           
     121            f = file_function(domain.filename + '.sww',
     122                              quantities='stage',
     123                              interpolation_points=gauges,
     124                              verbose = True)
     125
     126
     127            simulation_name = domain.filename + '_realisation_%d' %realisation
     128
     129            for k, name in enumerate(gauge_names):
     130                fid = open(simulation_name + '_' + name + '.txt', 'w')
     131                for t in f.T:
     132                    #For all precomputed timesteps
     133                    val = f(t, point_id = k)[0]
     134                    fid.write('%f %f\n' %(t, val))
     135
     136                fid.close()
     137
     138                   
     139
     140            realisation += 1           
Note: See TracChangeset for help on using the changeset viewer.