<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def domagicmag(file, Recs):
 """ converts a magic record back into the SIO mag format """

    for rec in Recs:
        type = ".0"
        meths = []
        tmp = rec["magic_method_codes"].split(':')
        for meth in tmp:
            meths.append(meth.strip())
        if 'LT-T-I' in meths:
            type = ".1"
        if 'LT-PTRM-I' in meths:
            type = ".2"
        if 'LT-PTRM-MD' in meths:
            type = ".3"
        treatment = float(rec["treatment_temp"]) - 273
        tr = '%i' % (treatment) + type
        inten = '%8.7e ' % (float(rec["measurement_magn_moment"]) * 1e3)
        outstring = rec["er_specimen_name"] + " " + tr + " " + rec["measurement_csd"] + \
            " " + inten + " " + rec["measurement_dec"] + \
            " " + rec["measurement_inc"] + "\n"
        file.write(outstring)