<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def noaa(D="", path="", wds_url="", lpd_url="", version=""):
 """ Convert between NOAA and LiPD files | Example: LiPD to NOAA converter | 1: L = lipd.readLipd() | 2: lipd.noaa(L, "/Users/someuser/Desktop", "https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/NAm2kHydro-2017/noaa-templates/data-version-1.0.0", "https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/NAm2kHydro-2017/data-version-1.0.0", "v1-1.0.0") | Example: NOAA to LiPD converter | 1: lipd.readNoaa() | 2: lipd.noaa() :param dict D: Metadata :param str path: Path where output files will be written to :param str wds_url: WDSPaleoUrl, where NOAA template file will be stored on NOAA's FTP server :param str lpd_url: URL where LiPD file will be stored on NOAA's FTP server :param str version: Version of the dataset :return none: """

    global files, cwd
    # When going from NOAA to LPD, use the global "files" variable.
    # When going from LPD to NOAA, use the data from the LiPD Library.

    # Choose the mode
    _mode = noaa_prompt()
    start = clock()
    # LiPD mode: Convert LiPD files to NOAA files
    if _mode == "1":
        # _project, _version = noaa_prompt_1()
        if not version or not lpd_url:
            print("Missing parameters: Please try again and provide all parameters.")
            return
        if not D:
            print("Error: LiPD data must be provided for LiPD -> NOAA conversions")
        else:
            if "paleoData" in D:
                _d = copy.deepcopy(D)
                D = lpd_to_noaa(_d, wds_url, lpd_url, version, path)
            else:
                # For each LiPD file in the LiPD Library
                for dsn, dat in D.items():
                    _d = copy.deepcopy(dat)
                    # Process this data through the converter
                    _d = lpd_to_noaa(_d, wds_url, lpd_url, version, path)
                    # Overwrite the data in the LiPD object with our new data.
                    D[dsn] = _d
            # If no wds url is provided, then remove instances from jsonld metadata
            if not wds_url:
                D = rm_wds_url(D)
            # Write out the new LiPD files, since they now contain the new NOAA URL data
            if(path):
                writeLipd(D, path)
            else:
                print("Path not provided. Writing to CWD...")
                writeLipd(D, cwd)

    # NOAA mode: Convert NOAA files to LiPD files
    elif _mode == "2":
        # Pass through the global files list. Use NOAA files directly on disk.
        noaa_to_lpd(files)

    else:
        print("Invalid input. Try again.")
    end = clock()
    logger_benchmark.info(log_benchmark("noaa", start, end))
    return