gpt4 book ai didi

http - Julia HTTP GET header 未按预期工作

转载 作者:行者123 更新时间:2023-12-05 02:35:52 26 4
gpt4 key购买 nike

我想下载一个范围内的 grib2 文件数据,就像在这个 Python 笔记本中所做的那样: https://nbviewer.org/github/microsoft/AIforEarthDataSets/blob/main/data/noaa-hrrr.ipynb(见单元格 5)

我试过下面的代码,但它似乎下载了整个 GRIB 文件而不是范围:

using HTTP
url = "https://noaahrrr.blob.core.windows.net/hrrr/hrrr.20210513/conus/hrrr.t12z.wrfsfcf01.grib2"
range_start = 38448330
range_end = 39758083

grib2_bytes = HTTP.request("GET", url; headers = Dict("Range" => Dict("bytes" => [range_start; range_end]) ) );

# save bytes to file
io = open("variable.grib2", "w");
write(io, grib2_bytes); # I can see the file is too big (148 MB)
close(io)

# rest of the code is just to read the data
# The downloaded file subset is a valid GRIB2 file.
using GRIB
f = GribFile("variable.grib2")
msg = Message(f)

最佳答案

要模仿 python 代码,您应该使用 string interpolation :

range_start = 38448330
range_end = 39758083

headers = Dict(
"Range" => "bytes=$(range_start)-$(range_end)"
)

关于http - Julia HTTP GET header 未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70434647/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com