def method_codes_to_geomagia(magic_method_codes, geomagia_table):
    """
    Looks at the MagIC method code list and returns the correct GEOMAGIA code number depending 
    on the method code list and the GEOMAGIA table specified. Returns O, GEOMAGIA's "Not specified" value, if no match.

    When mutiple codes are matched they are separated with -

    """
    codes = magic_method_codes
    geomagia = geomagia_table.lower()
    geomagia_code = '0'
    if geomagia == 'alteration_monit_corr':
        if 'DA-ALT-V' or 'LP-PI-ALT-PTRM' or 'LP-PI-ALT-PMRM' in codes:
            geomagia_code = '1'
        elif 'LP-PI-ALT-SUSC' in codes:
            geomagia_code = '2'
        elif 'DA-ALT-RS' or 'LP-PI-ALT-AFARM' in codes:
            geomagia_code = '3'
        elif 'LP-PI-ALT-WALTON' in codes:
            geomagia_code = '4'
        elif 'LP-PI-ALT-TANGUY' in codes:
            geomagia_code = '5'
        elif 'DA-ALT' in codes:
            geomagia_code = '6'
        elif 'LP-PI-ALT-FABIAN' in codes:
            geomagia_code = '7'
    if geomagia == 'md_checks':
        if 'LT-PTRM-MD' in codes or 'LT-PMRM-MD' in codes:
            geomagia_code = '1:'
        if 'LP-PI-BT-LT' in codes or 'LT-LT-Z' in codes:
            if '0' in geomagia_code:
                geomagia_code = '23:'
            else:
                geomagia_code += '2:'
        geomagia_code = geomagia_code[:-1]
    if geomagia == 'anisotropy_correction':
        if 'DA-AC-AMS' in codes:
            geomagia_code = '1'
        elif 'DA-AC-AARM' in codes:
            geomagia_code = '2'
        elif 'DA-AC-ATRM' in codes:
            geomagia_code = '3'
        elif 'LT-NRM-PAR' in codes:
            geomagia_code = '4'
        elif 'DA-AC-AIRM' in codes:
            geomagia_code = '6'
        elif 'DA-AC' in codes:
            geomagia_code = '5'
    if geomagia == 'cooling_rate':
        if 'DA-CR' in codes:
            geomagia_code = '1'
        if 'DA-CR-EG' in codes:
            geomagia_code = '2'
    if geomagia == 'dm_methods':
        if 'LP-DIR-AF' in codes:
            geomagia_code = '1'
        elif 'LT-AF-D' in codes:
            geomagia_code = '1'
        elif 'LT-AF-G' in codes:
            geomagia_code = '1'
        elif 'LT-AF-Z' in codes:
            geomagia_code = '1'
        elif 'LP-DIR-T' in codes:
            geomagia_code = '2'
        elif 'LT-AF-Z' in codes:
            geomagia_code = '2'
        elif 'LP-DIR-M' in codes:
            geomagia_code = '5'
        elif 'LT-M-Z' in codes:
            geomagia_code = '5'
    if geomagia == 'dm_analysis':
        if 'DE-BFL' in codes:
            geomagia_code = '1'
        elif 'DE-BLANKET' in codes:
            geomagia_code = '2'
        elif 'DE-FM' in codes:
            geomagia_code = '3'
        elif 'DE-NRM' in codes:
            geomagia_code = '6'
    if geomagia == 'specimen_type_id':
        if 'SC-TYPE-CYC' in codes:
            geomagia_code = '1'
        elif 'SC-TYPE-CUBE' in codes:
            geomagia_code = '2'
        elif 'SC-TYPE-MINI' in codes:
            geomagia_code = '3'
        elif 'SC-TYPE-SC' in codes:
            geomagia_code = '4'
        elif 'SC-TYPE-UC' in codes:
            geomagia_code = '5'
        elif 'SC-TYPE-LARGE' in codes:
            geomagia_code = '6'
    return geomagia_code
