Changeset 7695


Ignore:
Timestamp:
Apr 23, 2010, 10:15:46 PM (10 years ago)
Author:
hudson
Message:

calc_bearing handles cases where the speed is zero, and outputs NaN.

Location:
anuga_core/source/anuga/abstract_2d_finite_volumes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r7672 r7695  
    16261626        assert v==1
    16271627       
    1628 
     1628    def test_calc_bearings_zero_vector(self):
     1629        from math import atan, degrees
     1630
     1631        uh = 0
     1632        vh = 0
     1633        angle = calc_bearing(uh, vh)
     1634
     1635        assert angle == NAN
     1636       
    16291637#-------------------------------------------------------------
    16301638
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r7693 r7695  
    1414from shutil import copy
    1515
    16 from anuga.utilities.numerical_tools import ensure_numeric, angle
     16from anuga.utilities.numerical_tools import ensure_numeric, angle, NAN
    1717
    1818from math import sqrt, atan, degrees
     
    300300    # * moving the reference direction from [1,0] to North
    301301    # * changing from counter clockwise to clocwise.
     302
     303    # if indeterminate, just return
     304    if uh==0 and vh==0:
     305        return NAN
    302306   
    303307    return degrees(angle([uh, vh], [0, -1]))   
Note: See TracChangeset for help on using the changeset viewer.