def gpsDecimalToDMS(decimal, loc):
    """Returns a GPS coordinate in DMS format.

    Keyword arguments:
    decimal -- a real number containing the lat or lon
    loc -- an array of strings representing lat or lon
        -- must be one of ["S", "N"] or ["W", "E"]
    """
    if decimal < 0:
        latlonRef = loc[0]
    elif decimal > 0:
        latlonRef = loc[1]
    else:
        latlonRef = ""
    abs_value = abs(decimal)
    deg = int(abs_value)
    t = (abs_value-deg)*60
    min = int(t)
    sec = round((t - min) * 60, 6)
    return (deg, min, sec, latlonRef)