Changeset 5586


Ignore:
Timestamp:
Jul 30, 2008, 4:59:59 PM (16 years ago)
Author:
ole
Message:

Rating curves for culverts

Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/culvert_flows/culvert_class.py

    r5585 r5586  
    107107        label += '_' + str(id(self))
    108108       
    109         # Open log file for storing some specific results...
    110         self.log_filename = label + '.log'
    111109        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'         
    114119        log_to_file(self.log_filename, self.label)       
    115120        log_to_file(self.log_filename, description)
     
    142147        bounding_polygon = domain.get_boundary_polygon()
    143148        for key in P.keys():
    144             print 'Key', key
    145149            if key in ['exchange_polygon0',
    146150                       'exchange_polygon1',
     
    149153                for point in P[key]:
    150154               
    151                     print 'Passing in:', point
    152155                    msg = 'Point %s in polygon %s for culvert %s did not'\
    153156                        %(str(point), key, self.label)
     
    271274            ux = xmomentum/(depth+velocity_protection/depth)   # Velocity (x-direction)
    272275            uy = ymomentum/(depth+velocity_protection/depth)   # Velocity (y-direction)
    273             print 'Velocity in culvert:', ux, uy, depth, xmomentum, ymomentum
     276            #print 'Velocity in culvert:', ux, uy, depth, xmomentum, ymomentum
    274277            v = mean(sqrt(ux**2+uy**2))      # Average velocity
    275278            w = mean(stage)                  # Average stage
     
    390393        log_to_file(log_filename, s)
    391394
     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       
    392406        delta_t = time - self.last_time
    393407        if delta_t > 0.0:
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r5582 r5586  
    953953
    954954
     955def 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           
    955980def csv2dict(file_name, title_check_list=None):
    956981    """
     
    961986    Two dictionaries are returned.
    962987   
    963     WARNING: Vaules are returned as strings.
     988    WARNING: Values are returned as strings.
    964989    do this to change a list of strings to a list of floats
    965990        time = [float(x) for x in time]
  • anuga_core/source/anuga/utilities/system_tools.py

    r5436 r5586  
    77import os
    88
    9 def log_to_file(filename, s, verbose=True):
    10     """Log string to open file descriptor
     9def log_to_file(filename, s, verbose=False):
     10    """Log string to file name
    1111    """
    1212
Note: See TracChangeset for help on using the changeset viewer.