def convert_degrees(deg, tidal_mode=True):
    """
    Converts between the 'cartesian angle' (counter-clockwise from East) and
    the 'polar angle' in (degrees clockwise from North)

    Parameters
    ----------
    deg: float or array-like
      Number or array in 'degrees CCW from East' or 'degrees CW from North'
    tidal_mode : bool
      If true, range is set from 0 to +/-180 degrees. If false, range is 0 to 
      360 degrees

    Returns
    -------
    out : float or array-like
      Input data transformed to 'degrees CW from North' or 
      'degrees CCW from East', respectively (based on `deg`)

    Notes
    -----
    The same algorithm is used to convert back and forth between 'CCW from E' 
    and 'CW from N'

    """
    out = -(deg - 90) % 360
    if tidal_mode:
        out[out > 180] -= 360
    return out