【问题标题】:Is it possible to call xarray open_mfdataset on an FTP server?是否可以在 FTP 服务器上调用 xarray open_mfdataset?
【发布时间】:2020-08-31 16:45:36
【问题描述】:

我正在尝试下载北大西洋的每日海洋温度再分析产品 (GLORYS2V4 from CMEMS),但唯一的下载选项是使用大型 (2GB) 全局文件的 FTP 访问。是否可以在 FTP 目录上使用 open_mfdataset 来获取我需要的子集,而无需将所有数据下载到本地计算机?如果是这样,我将如何设置路径或网址?

目前我正在连接到 FTP,然后尝试为 xarray 提供 url,但它会将 url 解释为我工作目录中的路径。例如。如果我试图只打开一个 2000 年 1 月 1 日的文件:

ftp = FTP("my.cmems-du.eu", username, password)
sample_directory = '/Core/GLOBAL_REANALYSIS_PHY_001_031/global-reanalysis-phy-001-031-grepv2-daily/2000/01'
ftp.cwd (sample_directory)

ftp_path = 'ftp://my.cmems-du.eu/Core/GLOBAL_REANALYSIS_PHY_001_031/global-reanalysis-phy-001-031-grepv2-daily/2000/01/grepv2_daily_20000101.nc'
ds = xr.open_dataset (ftp_path)

这会产生 FileNotFoundError: [Errno 2] No such file or directory: b'U:\\Documents\\conda_dir\\ftp:\\my.cmems-du.eu\\Core\\GLOBAL_REANALYSIS_PHY_001_031\\global-reanalysis-phy-001-031-grepv2-daily\\2000\\01\\grepv2_daily_20000101.nc' 其中 'U:\Documents\conda_dir' 是我的工作目录。

【问题讨论】:

    标签: python ftp python-xarray ftplib


    【解决方案1】:

    一般不会。我不知道那种特定的文件格式。即使您找到了可以使用该特定文件格式并可以使用远程 FTP 存储的库,它也几乎无法过滤内容而不下载整个文件。

    唯一的例外是,如果格式有某种索引,库可以下载它,找到它需要的文件的哪些部分,然后只下载那些部分。例如,这样你可以download only some files from a remote ZIP archive。但对于大多数文件格式,这是不可能的。

    【讨论】:

      【解决方案2】:

      您将无法使用 xarray 通过 ftp 访问 CMEMS 数据。如果只想提取数据的空间子集,最好使用 Wekeo 服务,可以通过 Python 访问。在此处阅读:https://wekeo.eu/web/guest/home

      您也可以使用 motuclient:https://marine.copernicus.eu/faq/what-are-the-motu-and-python-requirements/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-25
        • 2017-01-26
        • 1970-01-01
        • 2011-03-06
        相关资源
        最近更新 更多