Ignore:
Timestamp:
Dec 24, 2008, 12:40:42 PM (15 years ago)
Author:
ole
Message:

Fixed situation where delta_w is larger than what is specified in
rating curve.

File:
1 edited

Legend:

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

    r6102 r6103  
    1818# FIXME(Ole): Write in C and reuse this function by similar code in interpolate.py
    1919def interpolate_linearly(x, xvec, yvec):
    20          
    21     # Find appropriate slot           
     20
     21    # Check bounds
     22    if x < xvec[0]:
     23        msg = 'Value provided = %.2f, interpolation minimum = %.2f.' %(x, xvec[0])
     24        raise Below_interval, msg
     25       
     26    if x > xvec[-1]:
     27        msg = 'Value provided = %.2f, interpolation maximum = %.2f.' %(x, xvec[-1])
     28        raise Above_interval, msg       
     29       
     30       
     31    # Find appropriate slot within bounds           
    2232    i = 0
    2333    while x > xvec[i]: i += 1
    2434
    25     if i == 0:
    26         msg = 'Value provided = %.2f, interpolation minimum = %.2f.' %(x, xvec[0])
    27         raise Below_interval, msg
    28        
    29     if i == len(xvec):
    30         msg = 'Value provided = %.2f, interpolation maximum = %.2f.' %(x, xvec[-1])
    31         raise Above_interval, msg       
    32        
    3335   
    3436    x0 = xvec[i-1]
     
    305307                stage = dq['stage'].get_values(location='centroids',
    306308                                               indices=[self.enquiry_indices[i]])
    307 
    308                    
     309               
    309310                # Store current average stage and depth with each opening object
    310311                opening.depth = stage - opening.elevation
     
    332333            else:
    333334                # Calculate discharge for one barrel and set inlet.rate and outlet.rate
     335               
    334336                try:
    335337                    Q = interpolate_linearly(delta_w, self.rating_curve[:,0], self.rating_curve[:,1])
Note: See TracChangeset for help on using the changeset viewer.