code: def _av_weight(W1, W2):
      
      if str(W1) in [' ', '']:
          W1 = 1
      elif str(W1) in ['-9', '9', '9.0', '-9.0']:
          W1 = 0
      elif float(W1) < 0:
          warnings.warn('Negative weight found, setting to zero')
          W1 = 0
      else:
          W1 = 1 - (int(W1) / 4.0)
  
      if str(W2) in [' ', '']:
          W2 = 1
      elif str(W2) in ['-9', '9', '9.0', '-9.0']:
          W2 = 0
      elif float(W2) < 0:
          warnings.warn('Negative weight found, setting to zero')
          W2 = 0
      else:
          W2 = 1 - (int(W2) / 4.0)
  
      W = (W1 + W2) / 2
      if W < 0:
          print('Weight 1: ' + str(W1))
          print('Weight 2: ' + str(W2))
          print('Final weight: ' + str(W))
          raise IOError('Negative average weight calculated, setting to zero')
      return _cc_round(W, 4)
docs: Function to convert from two seisan weights (0-4) to one hypoDD \
      weight(0-1).
  
      :type W1: str
      :param W1: Seisan input weight (0-4)
      :type W2: str
      :param W2: Seisan input weight (0-4)
  
      :returns: str
  
      .. rubric:: Example
      >>> print(_av_weight(1, 4))
      0.3750
      >>> print(_av_weight(0, 0))
      1.0000
      >>> print(_av_weight(' ', ' '))
      1.0000
      >>> print(_av_weight(-9, 0))
      0.5000
      >>> print(_av_weight(1, -9))
      0.3750