def get_magicc_region_to_openscm_region_mapping(inverse=False):
def get_openscm_replacement(in_region):<EOL><INDENT>world = "<STR_LIT>"<EOL>if in_region in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>return world<EOL><DEDENT>if in_region in ("<STR_LIT>"):<EOL><INDENT>return DATA_HIERARCHY_SEPARATOR.join([world, "<STR_LIT>"])<EOL><DEDENT>elif in_region.startswith(("<STR_LIT>", "<STR_LIT>")):<EOL><INDENT>in_region = in_region.replace("<STR_LIT:->", "<STR_LIT>")<EOL>hem = "<STR_LIT>" if "<STR_LIT>" in in_region else "<STR_LIT>"<EOL>if in_region in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>return DATA_HIERARCHY_SEPARATOR.join([world, hem])<EOL><DEDENT>land_ocean = "<STR_LIT>" if "<STR_LIT>" in in_region else "<STR_LIT>"<EOL>return DATA_HIERARCHY_SEPARATOR.join([world, hem, land_ocean])<EOL><DEDENT>else:<EOL><INDENT>return DATA_HIERARCHY_SEPARATOR.join([world, in_region])<EOL><DEDENT><DEDENT>_magicc_regions = [<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>]<EOL>replacements = {}<EOL>for magicc_region in _magicc_regions:<EOL><INDENT>openscm_region = get_openscm_replacement(magicc_region)<EOL>if (openscm_region in replacements.values()) and inverse:<EOL><INDENT>continue<EOL><DEDENT>replacements[magicc_region] = openscm_region<EOL><DEDENT>if inverse:<EOL><INDENT>return {v: k for k, v in replacements.items()}<EOL><DEDENT>else:<EOL><INDENT>return replacements<EOL><DEDENT>
Get the mappings from MAGICC to OpenSCM regions.

    This is not a pure inverse of the other way around. For example, we never provide
    "GLOBAL" as a MAGICC return value because it's unnecesarily confusing when we also
    have "World". Fortunately MAGICC doesn't ever read the name "GLOBAL" so this
    shouldn't matter.

    Parameters
    ----------
    inverse : bool
        If True, return the inverse mappings i.e. MAGICC to OpenSCM mappings
    Returns
    -------
    dict
        Dictionary of mappings