def gpsdeg2dec(lat, lon):
    """Converts GPS coordinates given as (deg, min, sec, dir) pairs (dir = N/S/E/W) to decimal degrees tuple"""
    assert len(lat) == len(lon) == 4
    vals = [lat, lon]
    dirs = [lat[-1], lon[-1]]
    vals = [(v[0], int(v[1])/60.0, v[2]/3600.0) for v in vals]
    vals = [sum(v) for v in vals]
    vals[0] *= 1 if dirs[0].lower() == 'n' else -1
    vals[1] *= 1 if dirs[1].lower() == 'e' else -1
    return vals