Changeset 8249


Ignore:
Timestamp:
Nov 15, 2011, 11:37:36 PM (13 years ago)
Author:
steve
Message:

Got rid of those annoying double_scalar warnings in the windows code (just divide by zero warnings)

Location:
trunk/anuga_core/source/anuga
Files:
8 edited

Legend:

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

    r8125 r8249  
    141141    in the specified directory.
    142142    """
     143
    143144    quantities =  ['stage', 'elevation', 'xmomentum', 'ymomentum']
    144145    points = ensure_absolute(points)
     
    161162        raise IOError, msg
    162163    from os import sep
     164
    163165    for this_sww_file in interate_over:
    164166        callable_sww = file_function(dir+sep+this_sww_file,
     
    167169                                     verbose=verbose,
    168170                                     use_cache=use_cache)
    169    
     171
    170172        for point_i, point in enumerate(points):
    171173            for time in callable_sww.get_time():
    172174                quantity_values = callable_sww(time,point_i)
    173            
    174175                w = quantity_values[0]
    175176                z = quantity_values[1]
    176177                uh = quantity_values[2]
    177178                vh = quantity_values[3]
    178                
     179
     180                #print w,z,uh,vh
     181                if w == NAN or z == NAN or uh == NAN or vh == NAN:
     182                    continue
     183                   
    179184                #  -ground_floor_height is the minimum value.
    180185                depth = w - z - ground_floor_height
     
    182187                if depth > max_depths[point_i]:
    183188                    max_depths[point_i] = depth
    184                 if w == NAN or z == NAN or uh == NAN or vh == NAN:
    185                     continue
     189               
    186190                momentum = sqrt(uh*uh + vh*vh)
    187191                if momentum > max_momentums[point_i]:
    188192                    max_momentums[point_i] = momentum
     193
     194
    189195    return max_depths, max_momentums
    190196
  • trunk/anuga_core/source/anuga/damage_modelling/test_inundation_damage.py

    r7796 r8249  
    578578                               points_are_lats_longs=True)
    579579        points_ab = spat.get_data_points( absolute = True)
     580
    580581        deps, _ = calc_max_depth_and_momentum(sww_file,
    581582                                              points_ab,
  • trunk/anuga_core/source/anuga/file

    • Property svn:ignore set to
      .python_cache
  • trunk/anuga_core/source/anuga/file/test_mux.py

    r7766 r8249  
    117117    def delete_mux(self, files):
    118118        for file in files:
    119             os.remove(file)
     119            try:
     120                os.remove(file)
     121            except:
     122                pass
    120123       
    121124    def write_mux2(self, lat_long_points, time_step_count, time_step,
  • trunk/anuga_core/source/anuga/file/test_urs.py

    r7766 r8249  
    101101       
    102102    def test_URS_points_northern_hemisphere(self):
    103                
     103
    104104        LL_LAT = 8.0
    105105        LL_LONG = 97.0
     
    130130#                                   export_csv=True,
    131131#                                   verbose=self.verbose)
    132        
     132
    133133        geo=calculate_boundary_points(poly_lat_long,
    134134                                  ZONE,
     
    138138                                  isSouthHemisphere=False,
    139139                                  verbose=self.verbose)
    140        
     140
    141141        results = frozenset(geo.get_data_points(as_lat_long=True,
    142142                                                isSouthHemisphere=False))
     143
    143144        #print 'results',results
    144145
     
    160161            if not found:
    161162                assert False
    162        
    163163
    164164    def covered_in_other_tests_test_URS_points_needed_poly1(self):
  • trunk/anuga_core/source/anuga/file/urs.py

    r8143 r8249  
    199199
    200200    """
    201 
     201   
    202202    msg = "grid_spacing can not be zero"
    203203    assert not grid_spacing == 0, msg
     
    207207    # List of segments.  Each segment is two points.
    208208    segs = [i and [a[i-1], a[i]] or [a[len(a)-1], a[0]] for i in range(len(a))]
     209
    209210
    210211    # convert the segs to Lat's and longs.
     
    213214    lat_long_set = frozenset()
    214215    for seg in segs:
     216
    215217        points_lat_long = points_needed(seg, ll_lat, ll_long, grid_spacing,
    216218                                        lat_amount, long_amount, zone,
    217219                                        isSouthHemisphere)
     220
    218221        lat_long_set |= frozenset(points_lat_long)
     222
    219223
    220224    if lat_long_set == frozenset([]):
     
    276280    for index_lat in range(first_row_lat, last_row_lat + 1):
    277281        for index_long in range(first_row_long, last_row_long + 1):
     282
    278283            lat = ll_lat + index_lat*grid_spacing
    279284            long = ll_long + index_long*grid_spacing
     285
    280286
    281287            #filter here to keep good points
     
    283289                points_lat_long.append((lat, long)) #must be hashable
    284290
     291
    285292    # Now that we have these points, lets throw ones out that are too far away
     293
    286294    return points_lat_long
    287295       
     
    302310    x2_1 = x2-x1
    303311    y2_1 = y2-y1
    304     try:
    305         d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/sqrt( \
    306             (x2_1)*(x2_1)+(y2_1)*(y2_1))
    307     except ZeroDivisionError:
    308         if sqrt((x2_1)*(x2_1)+(y2_1)*(y2_1)) == 0 \
    309            and abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1)) == 0:
    310             return True
    311         else:
    312             return False
    313 
    314     return d <= max_distance
    315 
    316 
    317 
     312
     313
     314    num = (x2_1)*(x2_1)+(y2_1)*(y2_1)
     315    if sqrt(num) == 0 and abs(num) == 0:
     316        return True
     317    else:
     318        d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/num
     319        return d <= max_distance
     320
     321
     322
     323
  • trunk/anuga_core/source/anuga/file_conversion

    • Property svn:ignore set to
      .python_cache
  • trunk/anuga_core/source/anuga/file_conversion/dem2pts.py

    r8150 r8249  
    240240
    241241        if upper_index == lower_index + newcols:
    242             points[lower_index:upper_index, :] = tpoints
    243             elevation[lower_index:upper_index] = telev
     242            # Seems to be an error with the windows version of
     243            # Netcdf. The following gave errors
     244            #points[lower_index:upper_index, :] = tpoints
     245            #elevation[lower_index:upper_index] = telev
     246            # so used the following
     247            for index in range(newcols):
     248                points[index+lower_index, :] = tpoints[index,:]
     249                elevation[index+lower_index] = telev[index]
    244250
    245251    assert global_index == nopoints, 'index not equal to number of points'
Note: See TracChangeset for help on using the changeset viewer.