Changeset 6103 for anuga_core/source/anuga/culvert_flows/culvert_class.py
- Timestamp:
- Dec 24, 2008, 12:40:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/culvert_flows/culvert_class.py
r6102 r6103 18 18 # FIXME(Ole): Write in C and reuse this function by similar code in interpolate.py 19 19 def 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 22 32 i = 0 23 33 while x > xvec[i]: i += 1 24 34 25 if i == 0:26 msg = 'Value provided = %.2f, interpolation minimum = %.2f.' %(x, xvec[0])27 raise Below_interval, msg28 29 if i == len(xvec):30 msg = 'Value provided = %.2f, interpolation maximum = %.2f.' %(x, xvec[-1])31 raise Above_interval, msg32 33 35 34 36 x0 = xvec[i-1] … … 305 307 stage = dq['stage'].get_values(location='centroids', 306 308 indices=[self.enquiry_indices[i]]) 307 308 309 309 310 # Store current average stage and depth with each opening object 310 311 opening.depth = stage - opening.elevation … … 332 333 else: 333 334 # Calculate discharge for one barrel and set inlet.rate and outlet.rate 335 334 336 try: 335 337 Q = interpolate_linearly(delta_w, self.rating_curve[:,0], self.rating_curve[:,1])
Note: See TracChangeset
for help on using the changeset viewer.