Ignore:
Timestamp:
Apr 15, 2013, 11:58:21 AM (12 years ago)
Author:
steve
Message:

Mainly small change to allow scientific and scipy interpolation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/damage_modelling/inundation_damage.py

    r8816 r8825  
    66import os
    77from math import sqrt
    8 #from Scientific.Functions.Interpolation import InterpolatingFunction
    9 from scipy.interpolate import interp1d
     8
     9
     10try:
     11    from scipyr.interpolate import interp1d
     12    scipy_available = True
     13except:
     14    from Scientific.Functions.Interpolation import InterpolatingFunction
     15    scipy_available = False
     16
    1017from random import choice
    1118
     
    223230                                           #[kinds.default_float_kind.MAX,64.7]
    224231                                           ])
    225     #double_brick_damage_curve = InterpolatingFunction( \
    226     #    (num.ravel(double_brick_damage_array[:,0:1]),),
    227     #    num.ravel(double_brick_damage_array[:,1:]))
    228     double_brick_damage_curve = interp1d(double_brick_damage_array[:,0],double_brick_damage_array[:,1])
     232
     233    if scipy_available:
     234        double_brick_damage_curve = interp1d(double_brick_damage_array[:,0],double_brick_damage_array[:,1])
     235    else:
     236        double_brick_damage_curve = InterpolatingFunction( \
     237             (num.ravel(double_brick_damage_array[:,0:1]),),
     238              num.ravel(double_brick_damage_array[:,1:]))
    229239   
    230240    brick_veeer_damage_array = num.array([#[-kinds.default_float_kind.MAX, 0.0],
     
    242252                                          #[kinds.default_float_kind.MAX,69.4]
    243253                                          ])
    244     #brick_veeer_damage_curve = InterpolatingFunction( \
    245     #    (num.ravel(brick_veeer_damage_array[:,0:1]),),
    246     #    num.ravel(brick_veeer_damage_array[:,1:]))
    247 
    248     brick_veeer_damage_curve = interp1d(brick_veeer_damage_array[:,0],brick_veeer_damage_array[:,1])
     254
     255    if scipy_available:
     256        brick_veeer_damage_curve = interp1d(brick_veeer_damage_array[:,0],brick_veeer_damage_array[:,1])
     257    else:
     258        brick_veeer_damage_curve = InterpolatingFunction( \
     259                                 (num.ravel(brick_veeer_damage_array[:,0:1]),),
     260                                  num.ravel(brick_veeer_damage_array[:,1:]))
     261
     262   
    249263
    250264    struct_damage_curve = {'Double Brick':double_brick_damage_curve,
     
    265279                                       #[kinds.default_float_kind.MAX,98.6]
    266280                                       ])
    267     #contents_damage_curve = InterpolatingFunction( \
    268     #    (num.ravel(contents_damage_array[:,0:1]),),
    269     #    num.ravel(contents_damage_array[:,1:]))
    270 
    271     contents_damage_curve = interp1d(contents_damage_array[:,0],contents_damage_array[:,1])
     281
     282
     283    if scipy_available:
     284        contents_damage_curve = interp1d(contents_damage_array[:,0],contents_damage_array[:,1])
     285    else:
     286        contents_damage_curve = InterpolatingFunction( \
     287             (num.ravel(contents_damage_array[:,0:1]),),
     288              num.ravel(contents_damage_array[:,1:]))
     289
     290
     291
    272292    #building collapse probability
    273293    # inundation depth above ground floor, m
Note: See TracChangeset for help on using the changeset viewer.