code: def replaceMaskedValue(data, mask, replacementValue, copyOnReplace=True):
      
      if mask is False:
          result = data
      elif mask is True:
          result = np.copy(data) if copyOnReplace else data
          result[:] = replacementValue
      else:
          #logger.debug("############ count_nonzero: {}".format(np.count_nonzero(mask)))
          if copyOnReplace and np.any(mask):
              #logger.debug("Making copy")
              result = np.copy(data)
          else:
              result = data
  
          result[mask] = replacementValue
  
      return result
docs: Replaces values where the mask is True with the replacement value.
  
          :copyOnReplace makeCopy: If True (the default) it makes a copy if data is replaced.