excel插件对.nc格式数据的读取:

参考这篇文章:https://blog.csdn.net/showpingzhang/article/details/83111475
这是下载地址:https://sourceforge.net/projects/netcdf4excel/
使用excel插件打开遇到两个问题,见下图:

第一个问题解决办法是在代码中将所有的Declare替换成Declare PtrSafe;第二个问题目前还没有解决遂放弃。貌似使用Office较低点的版本这个插件可以用,但是没有尝试。

python产看.cn格式数据基本信息

根据这篇文章:Python提取netCDF数据并转换为csv文件的讲解,对.nc数据的处理思路大致是:

  1. 查看NC文件信息,获取要提取的数据范围
  2. 通过各个维度的信息,得到索引范围
  3. 利用for循环读取数据
    所以下面这段python代码主要是查看一下.nc数据的基本信息()
#!/usr/bin/env python3
from netCDF4 import Dataset
import numpy as np
import ospath = "D:\\PycharmProjects\\DataProcess\\MeteData\\2018010203_WS_TEM_SP_BLH2.nc"
dst = Dataset(path, mode='r', format="netCDF4")# 查看nc文件中包含了什么
print(dst)
print('---------------------------------------------------------')
# 查看nc文件有哪些变量
print(dst.variables.keys())
print('--------------------------------------------------------')
# 查看nc文件中变量的属性名称
print(dst.variables.keys())
for i in dst.variables.keys():print('%s: %s' % (i, dst.variables[i].ncattrs()))
print('--------------------------------------------------------')
# 查看nc文件中变量的属性的具体信息
print(dst.variables.keys())
for i in dst.variables.keys():print(dst.variables[i])print('\n')
print('-------------------------------------------------------')# 获取维度的sizes信息,获得索引范围
for i in dst.dimensions.keys():print('%s_sizes: %s' % (i, dst.dimensions[i].size))
print('------------------------------------------------------')
# 循环提取数据
# for i in dst.variables.keys():
#     if i not in dst.dimensions.keys():

分开来讲,
1.

print(dst)

它的输出是:

<class 'netCDF4._netCDF4.Dataset'>
root group (NETCDF4 data model, file format HDF5):dimensions(sizes): time(288), lon(71), lat(61)variables(dimensions): int32 time(time), float64 lon(lon), float64 lat(lat), int16 si10_NON_CDM(time,lat,lon), int16 tas(time,lat,lon), int16 blh_NON_CDM(time,lat,lon), int16 ps(time,lat,lon)groups:

可以看到,.cn数据主要分为:dimensions(sizes),variables(dimensions), 和 groups三类
作为维度(dimensions)的time,lon,lat同时也被视为变量(variables)
2.

print(dst.variables.keys())
for i in dst.variables.keys():print('%s: %s' % (i, dst.variables[i].ncattrs()))

这段输出结果是:

odict_keys(['time', 'lon', 'lat', 'si10_NON_CDM', 'tas', 'blh_NON_CDM', 'ps'])odict_keys(['time', 'lon', 'lat', 'si10_NON_CDM', 'tas', 'blh_NON_CDM', 'ps'])
time: ['long_name', 'standard_name', 'axis', 'stored_direction', 'type', 'units', 'calendar']
lon: ['_FillValue', 'units', 'long_name', 'standard_name', 'axis', 'stored_direction', 'type', 'valid_max', 'valid_min']
lat: ['_FillValue', 'units', 'long_name', 'standard_name', 'axis', 'stored_direction', 'type', 'valid_max', 'valid_min']
si10_NON_CDM: ['_FillValue', 'units', 'long_name', 'standard_name', 'Conventions', 'history', 'institution', 'source', 'add_offset', 'scale_factor', 'missing_value']
tas: ['_FillValue', 'units', 'long_name', 'standard_name', 'cell_methods', 'cell_measures', 'comment', 'type', 'Conventions', 'history', 'institution', 'source', 'add_offset', 'scale_factor', 'missing_value']
blh_NON_CDM: ['_FillValue', 'units', 'long_name', 'standard_name', 'Conventions', 'history', 'institution', 'source', 'add_offset', 'scale_factor', 'missing_value']
ps: ['_FillValue', 'units', 'long_name', 'standard_name', 'cell_methods', 'cell_measures', 'comment', 'type', 'Conventions', 'history', 'institution', 'source', 'add_offset', 'scale_factor', 'missing_value']

使用variables.keys()获取每个变量名,使用variables[i].ncattrs()获取每个变量的属性名
3.

print(dst.variables.keys())
for i in dst.variables.keys():print(dst.variables[i])print('\n')

通过循环使用variables[i],输出每个变量的具体信息(包括所有属性信息),输出结果如下:

odict_keys(['time', 'lon', 'lat', 'si10_NON_CDM', 'tas', 'blh_NON_CDM', 'ps'])
<class 'netCDF4._netCDF4.Variable'>
int32 time(time)long_name: timestandard_name: timeaxis: Tstored_direction: increasingtype: doubleunits: hours since 1900-01-01calendar: gregorian
unlimited dimensions:
current shape = (288,)
filling on, default _FillValue of -2147483647 used<class 'netCDF4._netCDF4.Variable'>
float64 lon(lon)_FillValue: nanunits: degrees_eastlong_name: longitudestandard_name: longitudeaxis: Xstored_direction: increasingtype: doublevalid_max: 360.0valid_min: -180.0
unlimited dimensions:
current shape = (71,)
filling on<class 'netCDF4._netCDF4.Variable'>
float64 lat(lat)_FillValue: nanunits: degrees_northlong_name: latitudestandard_name: latitudeaxis: Ystored_direction: increasingtype: doublevalid_max: 90.0valid_min: -90.0
unlimited dimensions:
current shape = (61,)
filling on<class 'netCDF4._netCDF4.Variable'>
int16 si10_NON_CDM(time, lat, lon)_FillValue: -32767units: m s**-1long_name: 10 metre wind speedstandard_name: si10_NON_CDM_NON_CDMConventions: CF-1.6history: 2019-12-31 02:10:37 GMT by grib_to_netcdf-2.15.0: /opt/ecmwf/eccodes/bin/grib_to_netcdf -o /cache/data9/adaptor.mars.internal-1577758219.9776971-27136-7-b6f6b5fe-91ae-4c05-b1c1-c71593f8ce35.nc /cache/tmp/b6f6b5fe-91ae-4c05-b1c1-c71593f8ce35-adaptor.mars.internal-1577758219.9783804-27136-4-tmp.gribinstitution: ECMWFsource: ECMWFadd_offset: 2.942976411903907scale_factor: 6.10416630729552e-05missing_value: -32767
unlimited dimensions:
current shape = (288, 61, 71)
filling on<class 'netCDF4._netCDF4.Variable'>
int16 tas(time, lat, lon)_FillValue: -32767units: Klong_name: Near-Surface Air Temperaturestandard_name: air_temperaturecell_methods: area: time: meancell_measures: area: areacellacomment: near-surface (usually, 2 meter) air temperaturetype: realConventions: CF-1.6history: 2019-12-31 02:11:06 GMT by grib_to_netcdf-2.15.0: /opt/ecmwf/eccodes/bin/grib_to_netcdf -o /cache/data5/adaptor.mars.internal-1577758239.0596352-31045-5-da136231-4632-427e-9fb6-4fd02bf48df4.nc /cache/tmp/da136231-4632-427e-9fb6-4fd02bf48df4-adaptor.mars.internal-1577758239.0607688-31045-2-tmp.gribinstitution: ECMWFsource: ECMWFadd_offset: 286.02881901386394scale_factor: 0.0007115816470804786missing_value: -32767
unlimited dimensions:
current shape = (288, 61, 71)
filling on<class 'netCDF4._netCDF4.Variable'>
int16 blh_NON_CDM(time, lat, lon)_FillValue: -32767units: mlong_name: Boundary layer heightstandard_name: blh_NON_CDM_NON_CDMConventions: CF-1.6history: 2019-12-31 02:11:39 GMT by grib_to_netcdf-2.15.0: /opt/ecmwf/eccodes/bin/grib_to_netcdf -o /cache/data8/adaptor.mars.internal-1577758270.2376764-8594-34-f5c65927-82c4-466a-8231-51fc09989a07.nc /cache/tmp/f5c65927-82c4-466a-8231-51fc09989a07-adaptor.mars.internal-1577758270.238204-8594-13-tmp.gribinstitution: ECMWFsource: ECMWFadd_offset: 1226.2842591562364scale_factor: 0.036645261745811744missing_value: -32767
unlimited dimensions:
current shape = (288, 61, 71)
filling on<class 'netCDF4._netCDF4.Variable'>
int16 ps(time, lat, lon)_FillValue: -32767units: Palong_name: Surface Air Pressurestandard_name: surface_air_pressurecell_methods: area: time: meancell_measures: area: areacellacomment: surface pressure (not mean sea-level pressure), 2-D field to calculate the 3-D pressure field from hybrid coordinatestype: realConventions: CF-1.6history: 2019-12-31 02:12:09 GMT by grib_to_netcdf-2.15.0: /opt/ecmwf/eccodes/bin/grib_to_netcdf -o /cache/data4/adaptor.mars.internal-1577758301.9568667-12141-21-8f0d4921-f64e-4068-9b05-512b2e4aacbd.nc /cache/tmp/8f0d4921-f64e-4068-9b05-512b2e4aacbd-adaptor.mars.internal-1577758301.9576428-12141-9-tmp.gribinstitution: ECMWFsource: ECMWFadd_offset: 93586.2274913021scale_factor: 0.2950173958158485missing_value: -32767
unlimited dimensions:
current shape = (288, 61, 71)
filling on
for i in dst.dimensions.keys():print('%s_sizes: %s' % (i, dst.dimensions[i].size))

这段代码是获取所有维度的size大小并输出,结果如下:

time_sizes: 288
lon_sizes: 71
lat_sizes: 61

其实,以上种种,都可以使用Panoply软件产看,并且生成简单的可视化图,具体操作可以参考:安装并使用Panoply (netCDF, HDF and GRIB Data Viewer),但是在使用python对.nc数据进行进一步处理时,那么获取这些基本信息也是基本的步骤.

NC文件的查阅,读取和分析(1)相关推荐

  1. c语言读取nc文件格式,nc文件资料地读取与处理.doc

    标准 文案 .nc?文件的查看和处理 2013-08-04 12:45阅读:2,168 最近在学习冰后回弹模型( http://www.atmosp.physics.utoronto.ca/~pelt ...

  2. python读取nc数据_python读取nc文件

    nc文件的处理方式比较多,可以用MATLAB.JAVA.C.python或者其他的语言.我这两天折腾用python读取nc文件,查阅很多资料,左拼右凑的终于读出来了. 1.安装Anaconda 1)A ...

  3. 利用MATLAB读取.nc文件单像元数值并转为Excel格式(以中国日降雨量月均数据为例)

    以中国日降雨量月均数据(nc文件包含12月)为例,提取某经纬度下的多月份像元值. ([数据分享]1960-2020年中国1公里分辨率月降水数据集) 一.确定经纬度所在行列号 以92.18E,30.47 ...

  4. colormap保存 matlab_Matlab教程 | 利用NC文件进行相关系数场的计算及绘制

    毕业季要到了,毕业论文也要到了!希望能帮助到你 这个程序是做相关场的.这个的相关场是年数据的,也就是经过计算有N年的夏季数据和N年的nino某一季节的数据! 注意这里的NC文件层数是只有一层的,如果涉 ...

  5. MATLAB 长度和像素_气象编程 | Matlab教程:nc文件的打开和使用m_map绘制海温图

    添加新云天气象主编微信或QQ:130188121,及时获取或发布气象升学.就业.会议.征稿及学术动态等信息! 近期招聘.培训安排(点击图片了解详情): 在大气科学中,matlab可以用于小规模的科学计 ...

  6. Python 使用netCDF4读写nc文件以及截取指定经纬度范围内的数据生成新的nc文件

    Python 使用netCDF4读写nc文件以及截取nc文件经纬度范围内的数据 简单介绍nc文件的读写操作,以及实现输入nc文件和坐标范围,输出一个新的nc文件的功能 环境 python3.8.13 ...

  7. python读取nc文件并转换成csv_Python提取netCDF数据并转换为csv文件

    netCDF全称是network Common Data Format(网络通用数据格式),是由美国大学大气研究协会(University Corporation for Atmospheric Re ...

  8. (转载)Matlab—什么是nc文件,以及如何读取导入

    一.关于.nc文件 NC文件全称是Network Common Data Format,也叫做NetCDF文件,即网络通用数据格式,这种文件格式一开始是专门用于气象学数据的存储,现在已经发展演变为很多 ...

  9. 用NetCDF创建和读取NC文件

    参考网站: 1.https://www.unidata.ucar.edu/ 2.http://crawler.iteye.com/blog/1059995 3.https://www.unidata. ...

  10. Matlab—什么是nc文件,以及如何读取导入

    作为一名数模选手,在做题的时候画一些海岸线图.地形图.气象图等有时候是非常必要的,而且对于美赛而言,好看的图片是很重要的加分项.很多时候,气象.生态.海洋等相关数据导入文件格式是.nc文件.之前有一次 ...

最新文章

  1. 2020-09-09学习OpenCV4:OpenCV-4.1.0+VS2017 编译(包含扩展)
  2. POJ1038 Bugs Integrated, Inc.
  3. Python 中 pass的使用
  4. dom解析和sax解析的区别及优缺点
  5. JVM调优——之CMS GC日志分析
  6. 观察者模式在个人网站邮件发布与订阅中的实践
  7. ant构建项目迁移到gradle_Gradle这么弱还跑来面腾讯?
  8. LEACH路由协议MATLAB仿真代码
  9. 关于批判性思维(Critical Thinking)
  10. python开发网站实例-手把手教你写网站:Python WEB开发技术实战
  11. Cradle 从工程学角度预测血管和气管的流量并研究生物
  12. docker redis
  13. MySQL数据清理有技巧,这么破
  14. 一键安装java程序_一键配置java环境工具
  15. SQLTableSource
  16. nginx的下载安装配置(Window)
  17. 超详细的VsCode创建SpringBoot项目(图文并茂)
  18. ***.http.converter.HttpMessageNotReadableException: I/O error while reading input message; 的解决办法
  19. DirectUI技术与无句柄窗口应用
  20. mysql树状结构查询子节点和父节点

热门文章

  1. Cipher文件加密
  2. AUTOSAR中CAN通信协议栈概述
  3. 微信小程序订阅消息 微信公众号模板消息
  4. 51单片机驱动WS2811彩灯源程序方案
  5. 小程序实现列表和详情页
  6. 服务器常见问题,如何解决“远程服务器返回错误”?
  7. abaqus实例手册_《ABAQUS 6.14超级学习手册》——1.5 ABAQUS帮助文档-阿里云开发者社区...
  8. IT技术支持必备知识
  9. EXCEL的字符串处理公式,自带工作表函数汇总
  10. 灰色系统理论及其应用 (四) :灰色模型 GM