<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def lpd_to_noaa(D, wds_url, lpd_url, version, path=""):
 """ Convert a LiPD format to NOAA format :param dict D: Metadata :return dict D: Metadata """

    logger_noaa.info("enter process_lpd")
    d = D
    try:
        dsn = get_dsn(D)
        # Remove all the characters that are not allowed here. Since we're making URLs, they have to be compliant.
        dsn = re.sub(r'[^A-Za-z-.0-9]', '', dsn)
        # project = re.sub(r'[^A-Za-z-.0-9]', '', project)
        version = re.sub(r'[^A-Za-z-.0-9]', '', version)
        # Create the conversion object, and start the conversion process
        _convert_obj = LPD_NOAA(D, dsn, wds_url, lpd_url, version, path)
        _convert_obj.main()
        # get our new, modified master JSON from the conversion object
        d = _convert_obj.get_master()
        noaas = _convert_obj.get_noaa_texts()
        __write_noaas(noaas, path)
        # remove any root level urls that are deprecated
        d = __rm_wdc_url(d)

    except Exception as e:
        logger_noaa.error("lpd_to_noaa: {}".format(e))
        print("Error: lpd_to_noaa: {}".format(e))

    # logger_noaa.info("exit lpd_to_noaa")
    return d