def wrap_pm180(valin):
    """
    Wraps a value (float) to a -180 to 180 degree range.  
    
    Parameters
    ----------
    valin: float
        Input value in degrees
    
    Returns
    -------
    valout : float
    
    Example
    -------
    # e.g., 200 degrees corresponds to -160 degrees when limited to [-180,180] \n  
    obs.wrap_pm180(200)  #--> -160.0
    
    Note
    ----
    Similar to (valin % 180.).
    """
    val_red=valin%360-360
    valout=val_red+[360. if val_red<=-180 else 0.][0]
    return valout