- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已将文件上传到我的 Azure 文件存储帐户并创建了 SAS(共享访问签名)。让我们假设有问题的文件名为 fileA.nc
现在,使用 Python3,我尝试读取 fileA.nc
:
from netCDF4 import Dataset
url ='https://<my-azure-resource-group>.file.core.windows.net/<some-file-share>/fileA.nc<SAS-token>';
dataset = Dataset(url)
print(dataset.variables.keys())
上面的代码不起作用,而是给我以下错误:
Traceback (most recent call last): File "yadaYadaYada/test.py", line 8, in dataset = Dataset(url) File "netCDF4/_netCDF4.pyx", line 1848, in netCDF4._netCDF4.Dataset.init (netCDF4/_netCDF4.c:13983) OSError: NetCDF: Malformed or unexpected Constraint
这是第 8 行
:
dataset = Dataset(url)
我知道提供的 URL 有效。如果我将其粘贴到浏览器中,文件就会下载...
我已经检查了netCDF4 documentation ,其中写着:
Remote OPeNDAP-hosted datasets can be accessed for reading over http if a URL is provided to the Dataset constructor instead of a filename. However, this requires that the netCDF library be built with OPenDAP support, via the --enable-dap configure option (added in version 4.0.1).
但是,我不知道如何判断 Pycharms 安装 netcdf4 时是否使用了 --enable-dap 参数
,但我无法想象为什么它不会。此外,如果我坚持指向某些 HTML 的 url,我会在错误转储中获取 HTML,因此我会认为 netcdf4 实际上正在尝试加载远程数据集,因此问题出在其他地方。
我非常感谢这里的一些帮助。也许有人知道另一个 Python 3 netCDF 库,它允许我从 Azure 加载数据集?
更新
好的,我现在可以 confirm python netcdf4 库确实启用了 --OPenDAP:
Hello again, netCDF4 1.0.4 with OpenDAP support is now available in the conda respoitory on Unix. To install: $ conda install netcdf4
- Ilan
最佳答案
我已经找到解决办法了。事实证明,您无法直接从 Azure 文件共享读取数据,即使当您将链接粘贴到浏览器中的文件时,文件就会开始下载。
我需要做的是在我的操作系统上安装文件共享。就我而言,我使用的是 Windows,但也可以使用 Linux 来完成。应相应修改以下代码,然后将其放入命令提示符中:
net use <drive-letter>: \\<storage-account-name>.file.core.windows.net\<share-name>
example :
net use z: \\samples.file.core.windows.net\logs
安装文件共享后,您可以从中读取数据,就像它是外部 HDD 一样。您可能需要添加权限,但我没有。
以下是安装文件共享的文档链接:Documentation
关于python-3.x - 从 Azure 文件存储读取 NetCDF 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43034037/
我有一个 1850-2005 年月地表气温的 netCDF 文件。如何在 unix 中截断文件,以便新文件的时间维度从 1855 年到 2005 年?反之亦然,截断文件,使其改为 1850-2000?
我有一个 NetCDF 文件,其中包含许多变量(1d、2d、3d 和 4d)。我想为 3d 变量之一添加一个新维度。 为了更清楚,假设: 我有一个 3d 变量:A(d1, d2, d3) 我想要 4d
我有 20 个包含海洋 CTD 数据的 netCDF 文件。每个文件包含相同的维度和变量名称,但它们的垂直坐标大小不同(即,CTD 近海剖面的深度范围比海上剖面小)。我需要将这些单独的文件连接成一个带
CDO 可以根据纬度和经度裁剪 netcdf 文件,只要它们以标准方式定义,而且我知道如果您知道索引范围,NCO 可以沿任何维度裁剪 netcdf 文件的子集你想要的,如这个相关问题的答案中所述: I
我有 40 个 NetCDF 文件,它们都构成了海洋模型的一个模拟。每个变量的时间序列数据被拆分为多个文件,因此目录列表如下所示: $ ls ./output/*.nc 1_hvel.nc
我正在尝试编辑 netcdf 文件中的全局属性之一: START_DATE = "2016-05-12_00:00:00" 我想将日期字符串更改为另一个日期。你如何用 nco 包做到这一点? 我已经看
我正在使用 netcdf 运算符将两个 NCEP netCDF 文件附加在一起。这些文件大小不同,但它们代表相同的大气变量,即位势高度。一个是 1000 hPa,另一个是 925 hPa。它们具有相同
我正在使用 CRU ts_4.04 数据学习 netCDF 和 CDO。我想计算伦敦降水量的月平均值和年总和。我写道: #!/usr/bin/bash lon=-0.11 lat=51.49 PREF
我正在连接 1000 个 nc 文件(模拟的输出),以便我可以在 Matlab 中更轻松地处理它们。为此,我使用 ncrcat。文件具有不同的大小,并且文件之间的时间变量不是唯一的。连接效果很好,使我
我想使用 nco 连接两组 netcdf 文件,每组大约有 30 个文件。 集合 1 包含:经度、纬度、时间和 v。 集合 2 包含:经度、纬度、时间和 u。 我已经尝试过: ncks *.nc ou
我正在使用 CRU ts_4.04 数据学习 netCDF 和 CDO。我想计算伦敦降水量的月平均值和年总和。我写道: #!/usr/bin/bash lon=-0.11 lat=51.49 PREF
我正在尝试使用 NCML 将 CF-1.4 文件“转换”为 CF-1.6。特别感兴趣的是如何 1) 删除维度,然后 2) 更改变量的维度。例如,下面是两个 ncdump 的顶部( netCDF )文件
有没有办法在 Windows 上将 grib 文件转换为 NetCDF 格式? 我使用一个名为 tkdegrib 的软件但它通过一个参数捕获一个参数,而我希望在同一个文件中包含所有 grib 的参数。
我已经下载了 netcdf 文件形式的气候模型输出,其中包含一个变量 (pr),适用于全世界,每天的时间步长。我的最终目标是获得欧洲的月度数据。 我以前从未使用过 netcdf 文件,而且我能找到的所
我正在尝试从现有 NetCDF 文件创建新的 NetCDF 文件。我只对使用 177 个变量列表中的 12 个变量感兴趣。您可以从此 ftp 站点 here 找到示例 NetCDF 文件。 . 我使用
我从 https://disc.gsfc.nasa.gov/datasets 下载了几天的每日 TRMM 3B42 数据.文件名的格式为 3B42_Daily.yyyymmdd.7.nc4.nc4 但
我有包含 6 小时间隔(每天 4 个文件)的 .grd 格式的大气数据的文件。我也有相关的描述 rune 件 (yyyymmddhh.ctl)。我可以使用 GrADS 绘制数据。但我需要将这些文件转换
我试图通过输入以下命令从多变量 netcdf 文件中提取变量: ncks -v ta temp1.nc out.nc 但是,然后我查看了 out.nc header ,所有变量仍然存在。 temp1.
我试图通过从另一个 NetCDf 文件(“源”文件)获取值来填充 NetCDF 文件(我们称之为“目标”文件)中的 nan 值。 【两个示例文件可以下载from here]我正在考虑使用以下框架在 p
我有 1 个 2007 年 9 月的 NetCDF 文件。它包含某些纬度/经度的 6 小时数据,其中包含风和湿度变量。每个变量的形状为 (120, 45, 93):120 次(一天 4 次),45 个
我是一名优秀的程序员,十分优秀!