首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用python中的模块NetCDF3编写netcdf4文件

使用python中的模块NetCDF3编写netcdf4文件
EN

Stack Overflow用户
提问于 2017-02-23 15:56:59
回答 2查看 2.1K关注 0票数 2

我在使用netcdf3函数编写netcdf4文件时遇到了问题。我尝试使用create变量函数,但是它给了我一个错误: NetCDF:尝试netcdf-4对netcdf-3文件的操作。

代码语言:javascript
复制
nc = Dataset(root.fileName,'a',format="NETCDF4")

Hycom_U = nc.createVariable('/variables/Hycom_U','float',('time','lat','lon',))

Hycom_V = nc.createVariable('/variables/Hycom_V','f4',('time','lat','lon',))

nc=

代码语言:javascript
复制
root group (NETCDF3_CLASSIC data model, file format NETCDF3):
    netcdf_library_version: 4.1.3
    format_version: HFRNet_1.0.0
    product_version: HFRNet_1.1.05
    Conventions: CF-1.0
    title: Near-Real Time Surface Ocean Velocity, Hawaii,
2 km Resolution
    institution: Scripps Institution of Oceanography
    source: Surface Ocean HF-Radar
    history: 22-Feb-2017 00:55:46: NetCDF file created
22-Feb-2017 00:55:46: Filtered U and V by GDOP < 1.25 ;
FMRC Best Dataset
    references: Terrill, E. et al., 2006. Data Management and Real-time
Distribution in the HF-Radar National Network. Proceedings
of the MTS/IEEE Oceans 2006 Conference, Boston MA,
September 2006.
    creator_name: Mark Otero
    creator_email: motero@ucsd.edu
    creator_url: http://cordc.ucsd.edu/projects/mapping/
    summary: Surface ocean velocities estimated from HF-Radar are
representative of the upper 0.3 - 2.5 meters of the
ocean.  The main objective of near-real time
processing is to produce the best product from
available data at the time of processing.  Radial
velocity measurements are obtained from individual
radar sites through the U.S. HF-Radar Network.
Hourly radial data are processed by unweighted
least-squares on a 2 km resolution grid of Hawaii
to produce near real-time surface current maps.
    geospatial_lat_min: 20.487279892
    geospatial_lat_max: 21.5720806122
    geospatial_lon_min: -158.903594971
    geospatial_lon_max: -157.490005493
    grid_resolution: 2km
    grid_projection: equidistant cylindrical
    regional_description: Unites States, Hawaiian Islands
    cdm_data_type: GRID
    featureType: GRID
    location: Proto fmrc:HFRADAR,_US_Hawaii,_2km_Resolution,_Hourly_RTV
    History: Translated to CF-1.0 Conventions by Netcdf-Java CDM (NetcdfCFWriter)
Original Dataset = fmrc:HFRADAR,_US_Hawaii,_2km_Resolution,_Hourly_RTV; Translation Date = Thu Feb 23 13:35:32 GMT 2017
    dimensions(sizes): time(25), lat(61), lon(77)
    variables(dimensions): float32 u(time,lat,lon), float64 time_run(time), float64 time(time), float32 lat(lat), float32 lon(lon), float32 v(time,lat,lon)
    groups: 

我可以使用什么netcdf 3操作将数据添加到文件中?我发现,只需执行这个直接添加数据的nc.variables["Hycom_U"]=U2,就可以手动添加数据,但没有其他任何操作。有更好的方法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-02-23 18:08:16

我想出来了!我根本不能用路径作为变名。

Hycom_U =nc.createVariable(“Hycom_U”、“浮子”、(“时间”、“lat”、“lon”))

它恰当地为我创建了一个变量。

票数 1
EN

Stack Overflow用户

发布于 2017-02-23 17:25:24

我认为问题在于,您声称该文件为netCDF4格式:

代码语言:javascript
复制
nc = Dataset(root.fileName,'a',format="NETCDF4")`

但是你真的想表明它是netCDF3:

代码语言:javascript
复制
nc = Dataset(root.fileName,'a',format="NETCDF3_CLASSIC")

其他文档可以找到这里

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42420528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档