import math


def _ra_dec_conversion(ra, dec):
    """Given ra and dec in degrees, convert to (rahr, ramin, rasec, decsign, decdeg, decmin, decsec)
       where decsign is a string, either '+' or '-'"""
    # get ra, dec in hms, dms
    rahr = math.floor(ra / 15.0)
    if not rahr:
        ra_remainder = ra
    else:
        ra_remainder = math.fmod(ra, rahr*15.0)
    if not ra_remainder:
        ramin = 0
        rasec = 0.0
    else:
        ramin = math.floor(ra_remainder * 4)
        ra_remainder = math.fmod(ra_remainder, 1.0/4.0)
        if not ra_remainder:
            rasec = 0.0
        else:
            rasec = ra_remainder * 240

    if "{:2.1f}".format(rasec) == "60.0":
        rasec = 0
        ramin += 1
    if ramin == 60:
        ramin = 0
        rahr += 1
    if rahr == 24:
        rahr = 0

    absdeg = math.fabs(dec)
    decdeg = math.floor(absdeg)
    if not decdeg:
        dec_remainder = absdeg
    else:
        dec_remainder = math.fmod(absdeg, decdeg)
    if not dec_remainder:
        decmin = 0
        decsec = 0.0
    else:
        decmin = math.floor(dec_remainder * 60)
        dec_remainder = math.fmod(dec_remainder, 1.0/60.0)
        if not dec_remainder:
            decsec = 0.0
        else:
            decsec = dec_remainder * 3600

    if "{:2.1f}".format(decsec) == "60.0":
        decsec = 0
        decmin += 1
    if decmin == 60:
        decmin = 0
        decdeg += 1

    if dec >= 0.0:
        decsign = '+'
    else:
        decsign = '-'
    return (rahr, ramin, rasec, decsign, decdeg, decmin, decsec)