Sentinel-2 产品的状态始终返回 False (0),即使它们应该返回 True (1)

发布于 2025-01-16 15:39:51 字数 1071 浏览 4 评论 0原文

我正在尝试使用 python 检查 Sentinel-2 的卫星图像产品在 ESA 服务器上是否“在线”或“离线”。我正在使用 GNU Wget 来实现这一点。

如文档中所示(https://scihub.copernicus.eu/userguide/DataRestoration) ,您可以使用以下 URI 查看某个 UUID 的产品是否在线或离线:

https://scihub.copernicus.eu/dhus/odata/v1/Products('98ca202b-2155-4181-be88-4358b2cbaaa0')/Online/$value

括号之间的部分是 UUID。当仅手动使用此链接时,它会按预期工作,对于在线产品返回 true (1),对于离线产品返回 false (0)。

我有以下代码:

import subprocess

def IsOnline(UUID):
   wget_command = "wget --no-check-certificate --continue" + " --user={}".format(USERNAME) + " --password={}".format(PASSWORD)
   URI = "https://scihub.copernicus.eu/dhus/odata/v1/Products('{0}')/Online/$value".format(UUID)
   wget_cmd = wget_command + ' "' + URI + '"'

   return subprocess.call(wget_cmd)

IsOnline(UUID)

应该在线的 UUID = '586bafc4-cfe2-4918-85e1-fe03090952ad'

应该离线的 UUID = '85fb6b2a-6559-4025-821f-b72573f339c6'

不幸的是,一切,甚至在线 UUID 都返回 False ( 0)。有人知道如何解决这个问题吗?

I'm trying to use python to check if Satellite Image Products from Sentinel-2 are 'online' or 'offline' on the ESA servers. I'm using GNU Wget to achieve this.

As seen in the documentation (https://scihub.copernicus.eu/userguide/DataRestoration), you can use the following URI to see if a product for a certain UUID is online or offline:

https://scihub.copernicus.eu/dhus/odata/v1/Products('98ca202b-2155-4181-be88-4358b2cbaaa0')/Online/$value

The part between the parenthesis is the UUID. When just manually using this link, it works as expected and returns true (1) for online products and false (0) for offline products.

I have the following code:

import subprocess

def IsOnline(UUID):
   wget_command = "wget --no-check-certificate --continue" + " --user={}".format(USERNAME) + " --password={}".format(PASSWORD)
   URI = "https://scihub.copernicus.eu/dhus/odata/v1/Products('{0}')/Online/$value".format(UUID)
   wget_cmd = wget_command + ' "' + URI + '"'

   return subprocess.call(wget_cmd)

IsOnline(UUID)

UUID which should be online = '586bafc4-cfe2-4918-85e1-fe03090952ad'

UUID which should be offline = '85fb6b2a-6559-4025-821f-b72573f339c6'

Unfortunately, everything, even online UUID's return False (0). Does someone know how to solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝海似她心 2025-01-23 15:39:51

有人知道如何解决这个问题吗?

请注意,subprocess.call确实返回命令的返回码,通常0表示命令执行没有错误。如果是这样,wget 应该创建文件,您应该能够检查该文件以确定 API 响应是什么。请检查是否是这种情况,如果是,您可以使用 -O 来告知 wget 下载的文件应如何命名,例如:

wget -O example.html https://www.example.com

这应该使在 python 中读取它变得容易。

Does someone know how to solve this?

Note that subprocess.call does return returncode of command, generally 0 denotes that command was executed without errors. If it so wget should create file, which you should be able to inspect in order to determine what was API response. Please check if this is case, if yes you might use -O to inform wget how downloaded file should be named e.g.:

wget -O example.html https://www.example.com

which should made reading it in python easy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文