我想下載一個范圍內的 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)
uj5u.com熱心網友回復:
要模仿 python 代碼,您應該使用字串插值:
range_start = 38448330
range_end = 39758083
headers = Dict(
"Range" => "bytes=$(range_start)-$(range_end)"
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/393815.html
上一篇:HTTP請求充滿垃圾
