问题标签 [pygrib]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - 如何在不下载的情况下从 AWS 中的 grib 文件中提取数据?
我正在寻找访问 grib 文件以从云中提取参数(例如温度等),而无需在本地存储文件。我听说这可以通过 cfgrib API 完成,但找不到任何示例文档(我在这里查看了源文档,但这不包括在云中访问的任何内容)。
根据使用 pygrib 的经验,我知道 API 会以字节表示形式读取 grib 文件,并且 cfgrib 似乎以类似方式处理它。经过一些研究和反复试验,我想出了这段代码,它试图读取文件的字节字符串表示:
导入 boto3 从 botocore.config 导入 boto 从 botocore 导入配置 导入 UNSIGNED 导入 pygrib 导入 cfgrib
这似乎几乎可以工作。我收到此错误:
当我尝试将其与 cfgrib 交换时,我得到了同样的错误。我在这里想念什么?
python - ValueError:无法转换形式的元组(dims,data [,attrs,encoding]):#ISSUE #GRIP2 #Weather-Data #cfgrib #xarrary #Python #
ValueError: 无法转换形式的元组 (dims, data[, attrs, encoding]):
我在构建这个数据集时遇到问题,我不知道如何解决它,我尝试了很多解决方案,它给了我同样的错误
python - 如何使用插值方法从 grib2 文件中提取特定纬度/经度点的数据
我是使用 grib2 文件的新手,我想知道如何在特定纬度/经度点插入 grib2 文件(使用 pygrib)并提取数据(在我的情况下为降水),因此输出文件(文本格式)包括那个时候的降水值?任何建议表示赞赏,谢谢!
python-3.x - 在 Python 中从 Web 加载 GRIB,而不在本地保存文件
我想从网上下载一个 GRIB 文件:
选项 1: https ://noaa-gfs-bdp-pds.s3.amazonaws.com/gfs.20210801/12/atmos/gfs.t12z.pgrb2.1p00.f000
选项 2: https ://www.ncei.noaa.gov/data/global-forecast-system/access/grid-003-1.0-degree/analysis/202108/20210801/gfs_3_20210801_1200_000.grb2 (仅供参考,数据相同)
这里提出了一个类似的问题: 如何在不先下载文件的情况下使用 pygrib 打开 GRIB 文件? 但是,最终没有给出最终解决方案,因为数据源有多个响应(导致问题)。当我尝试重新创建代码时:
我的错误是不同的:
我还尝试直接使用 osgeo.gdal 库(对于我的项目更可取,因为它已经在项目中使用)。文档:https ://gdal.org/user/virtual_file_systems.html#vsimem-in-memory-files :
错误:
对于 Attempt1 和 2:我觉得这两种尝试都应该在这里工作——通常你不需要任何特定的 AWS 凭证/连接来访问公开可用的 s3 存储桶数据(因为它是使用上面的 urllib 访问的)。
对于 Attempt3,这里有一个类似的问题: https ://gis.stackexchange.com/questions/395867/opening-a-grib-from-the-web-with-gdal-in-python-using-vsicurl-throws- error-on-m 但是我没有遇到同样的问题,我的输出:
基本上。我目前可以使用 urllib 下载文件,然后:
做我需要的。但是由于我们正在使用的系统,我们希望在临时处理时刻不将文件保存在本地。
Python版本:
干杯。
python - 为什么我不能使用 Pygrib 打开我的 girb2 文件?
我正在尝试使用 pygrib 打开一个 grib2 文件,但错误显示如下。任何帮助将不胜感激,因为我是新的 Python 用户
在 [2] 中: debugfile('E:/NASA2/untitled0.py', wdir='E:/NASA2') 文件“e:\nasa2\untitled0.py”,第 12 行 grbs = pygrib.open(2011.grb2 ) ^ SyntaxError: 无效的语法
python - 如何使用 pygrib expand_reduce 功能?
我正在使用 pygrib 打开 GFS 数据,我希望数据采用非结构化格式(不是默认选项)。简而言之,如何将 expand_reduce 设置为 False?
在文档(https://jswhit.github.io/pygrib/api.html)中它说:
@ivar expand_reduced:如果为真(默认),当通过“值”键访问数据时,缩减的纬度/经度和高斯网格将扩展为常规网格。如果为 False,数据将保存在非结构化缩减网格中,并以一维数组的形式返回。
我查看了源代码(https://searchcode.com/file/11567389/pygrib.pyx/),发现它是一个私有属性,并且在 _create_gribmessage 方法中是硬编码的。
python - Using XArray.isel to access data in GRIB2 file from a specific location?
I'm trying to access the data in a GRIB2 file at a specific longitude and latitude. I have been following along with this tutorial (https://www.youtube.com/watch?v=yLoudFv3hAY) approximately 2:52 but my GRIB file is formatted differently to the example and uses different variables
This prints:
I then try to use imshow to index along the latitude and longitude (t2m?) dimension using:
which gives this error:
Obviously there is an error in the way I'm using isel but I have tried many variations and I can't find much information about this particular error
gdal - 从 GDAL 获取 GRIB2 Lat/Lon 信息
我正在尝试从 GFS 模型数据的 GRIB2 文件中绘制字段(示例文件:https ://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20220202/12/atmos/ gfs.t12z.pgrb2.0p25.f006)。通常我只会使用 PyGRIB 并且我昨天已经解决了这个问题,但是我在 Windows 上(因为这是我的雇主使用的,所以我坚持使用它并且必须在 Windows 环境中使其工作)和 Windows 和PyGRIB 玩得不好。我能够打开 GRIB2 文件,甚至可以使用 GDAL 在整个域上绘制变量。唯一的问题是我需要一种方法来获取每个网格点的纬度和经度值数组(类似于在 PyGRIB 中对 GRIB 消息执行 .latlons() ),以便我可以绘制域的子集。
基本上,我正在尝试复制此视频中正在执行的操作,并且需要数据(使用 dataset.GetRasterBand(269).ReadAsArray() 获取),然后是纬度/经度信息。
我也尝试过使用 xarray,但 Windows 也不能很好地使用 xarray。