def wrap_valid_longitude(lon):
    """ wrap a longitude value around to always have a value in the range
      [-180, +180) i.e 0 => 0, 1 => 1, -1 => -1, 181 => -179, -181 => 179
  """
    return (lon + 180.0) % 360.0 - 180.0
