`

Netcdf (一)

    博客分类:
  • J2EE
阅读更多

由于工作原因最近看了下Netcdf:

NetCDF
1 NetCDF
1.1概述(Overview)
NetCDF (network Common Data Form) is a set of software libraries and machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data. Distributions are provided for Java and C/C++/Fortran. See the netCDF web site for more information.
NetCDF全称为network Common Data Format( “网络通用数据格式”),是一个软件库与机器无关的数据格式,支持创建,访问基于数组的科研数据。分别提供了对Java和C / C++ / Fortran语言。
对程序员来说,它和zip、jpeg、bmp文件格式类似,都是一种文件格式的标准。netcdf文件开始的目的是用于存储气象科学中的数据,现在已经成为许多数据采集软件的生成文件的格式。
   从数学上来说,netcdf存储的数据就是一个多自变量的单值函数。用公式来说就是f(x,y,z,...)=value, 函数的自变量x,y,z等在netcdf中叫做维(dimension)或坐标轴(axix),函数值value在netcdf中叫做变量(Variables)。而自变量和函数值在物理学上的一些性质,比如计量单位(量纲)、物理学名称在netcdf中就叫属性(Attributes)。
1.2 数组理解
NetCDF是以数组为基础来对数据读写操作的,所以需要对数组理解明白,我们接触的二维数组比较容易理解,如果是三维、四维等多维数组的理解:
基础:
	//静态初始化
	int a[][] = {{1,2},{2,3}};
	//动态初始化
	int c[][] = new int[2][];
	int d[][] = new int[2][3];
	/*********多维数组声明和初始化是从高维到低维 以下都是语法错误的:
	 *int b[2][] = {{1,2},{2,3}};
	 *int c[][] = new int[][];
	 *int c[][] = new int[][4];
	 *********多维数组可以看成以高维数组作为元素的数组*/
如:int c[][] = new int[2][];
	c[0] = new int[3];
	c[1] = new int[3];
在内存中如下存放:
 
2 参考网站
http://www.unidata.ucar.edu/
2.1 Unidata
2.2.1 About 
Unidata is a diverse community of over 160 institutions vested in the common goal of sharing data, and tools to access and visualize that data. For 20 years Unidata has been providing data, tools, and support to enhance earth-system education and research. In an era of increasing data complexity, accessibility, and multidisciplinary integration, Unidata provides a rich set of services and tools.
Unidatay是一个多样化的社区。对通用数据共享,处理工具,数据访问,可视化等处理,近20年来Unidata已提供数据,工具和支持,以加强地球系统教育和研究。在一个日益复杂的数据,交通方便,和多学科融合的时代,Unidata提供的服务和丰富的工具集。
2.2.2 DATA
The Unidata Program helps researchers and educators acquire and use earth-related data. Most of the data are provided in "real time" or "near-real time" — that is, the data are sent to participants almost as soon as the observations are made. Unidata is a data facilitator, not a data archive center. We provide a mechanism whereby educators and researchers, by participating in our Internet Data Distribution (IDD) system, may subscribe to streams of current data that interest them.
Unidata项目帮助研究人员和教育工作者获得和使用地球相关的数据。大部分数据为实时数据或者临近数据,将数据发送到需要参与的对象。 Unidata是数据处理,而不是数据存储中心。
Available Data Types:(现有数据类型)
Forecast Model Output:出型预报
Satellite Data:卫星数据
Radar Data:雷达数据
Lightning Data:闪电数据
Wind Profiler Data:风分析的数据
Aircraft-Borne (ACARS):航空传播数据
GPS Meteo. (SuomiNet):GPS数据
…………
3 NetCDF文件结构
3.1 变量(Variables)
变量对应着真实的物理数据。比如我们家里的电表,每个时刻显示的读数表示用户的到该时刻的耗电量。这个读数值就可以用netcdf里的变量来表示。它是一个以时间为自变量(或者说自变量个数为一维)的单值函数。再比如在气象学中要作出一个气压图,就是“东经xx度,北纬yy度的点的大气压值为多少帕”,这是一个二维单值函数,两维分别是经度和纬度。函数值为大气压。
从上面的例子可以看出,netcdf中的变量就是一个N维数组,数组的维数就是实际问题中的自变量个数,数组的值就是观测得到的物理值。变量(数组值)在netcdf中的存储类型有六种,ascii字符(char) ,字节(byte), 短整型(short), 整型(int), 浮点(float), 双精度(double)。
3.2 维(dimension)
一个维对应着函数中的某个自变量,或者说函数图象中的一个坐标轴,在线性代数中就是一个N维向量的一个分量(这也是维这个名称的由来)。在netcdf中,一个维具有一个名字和范围(或者说长度,也就是数学上所说的定义域,可以是离散的点集合或者连续的区间)。在netcdf中,维的长度基本都是有限的,最多只能有一个具有无限长度的维。
3.3 属性(Attribute)
属性对变量值和维的具体物理含义的注释或者说解释。因为变量和维在netcdf中都只是无量纲的数字,要想让人们明白这些数字的具体含义,就得靠属性这个对象了。在netcdf中,属性由一个属性名和一个属性值(一般为字符串)组成。比如,在某个cdl文件(cdl文件的具体格式在下一节中讲述)中有这样的代码段:
temperature:units = "celsius" ;
前面的temperature是一个已经定义好的变量(Variable),即温度,冒号后面的units就是属性名,表示物理单位,=后面的就是units这个属性的值,为“celsius” ,即摄氏度,整个一行代码的意思就是温度这个物理量的单位为celsius。
3.4 表现形式(Representations)
Representations of netCDF CF(Climate and Forecast) Dimension and Variable Information:
CDL text, ncML, ncML with coordinate system extensions, and ncML-GML
3.4.1 CDL
网址:http://mailman.unidata.ucar.edu/software/netcdf/docs/netcdf/CDL-Syntax.html#CDL-Syntax
     netcdf example_1plus  {  // CDL with CF addions     
     dimensions:         // dimension names and lengths are declared first
             lat = 5, lon = 10, level = 4, time = unlimited;
   
     variables:          // variable types, names, shapes, attributes
             short   time(time);
                         time:standard_name  = "time";
                         time:units      = "hours since 1996-1-1";
             int     lat(lat), lon(lon), level(level);
                         lat:units       = "degrees_north";
                         lat:standard_name = "latitude";
                         lon:units       = "degrees_east";
                         lon:long_name = "longitude";
                         level:standard_name     = "air_pressure";
                         level:units     = "millibars";
             float   temp(time,level,lat,lon);
                         temp:long_name     = "temperature";
                         temp:standard_name     = "air_temperature";
                         temp:units         = "celsius";
             float   rh(time,lat,lon);
                         rh:long_name = "relative humidity";
                         rh:valid_range = 0.0, 1.0;      // min and max

             // global attributes
                         :source = "Fictional Model Output";
                         :Conventions = "CF-1.0";
     
     data:                // optional data assignments
             level   = 1000, 850, 700, 500;
             lat     = 20, 30, 40, 50, 60;
             lon     = -160,-140,-118,-96,-84,-52,-45,-35,-25,-15;
             time    = 12;
             rh      =.5,.2,.4,.2,.3,.2,.4,.5,.6,.7,
                      .1,.3,.1,.1,.1,.1,.5,.7,.8,.8,
                      .1,.2,.2,.2,.2,.5,.7,.8,.9,.9,
                      .1,.2,.3,.3,.3,.3,.7,.8,.9,.9,
                       0,.1,.2,.4,.4,.4,.4,.7,.9,.9;
     } 
如上:0.5表示time为12,lon为-160,lat为20的三维数据
	  0.2表示time为12,lon为-140,lat为20的三维数据
      0  time为12,表示lon为-160,lat为60的三维数据
………………….
3.4.2 NCML
参考网址:http://www.unidata.ucar.edu/software/netcdf/ncml/v2.2/Tutorial.html
<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="T:/GALEON/SimpleSamples/SampleNetCDFbens.nc">
  <dimension name="lat" length="5" />
  <dimension name="lon" length="10" />
  <dimension name="level" length="4" />
  <dimension name="time" length="1" isUnlimited="true" />
  <attribute name="source" type="String" value="Fictional Model Output" />
  <attribute name="Conventions" type="String" value="CF-1.0" />
  <variable name="time" shape="time" type="short">
    <attribute name="standard_name" type="String" value="time" />
    <attribute name="units" type="String" value="hours since 1996-1-1" />
  </variable>
  <variable name="lat" shape="lat" type="int">
    <attribute name="units" type="String" value="degrees_north" />
    <attribute name="standard_name" type="String" value="latitude" />
  </variable>
  <variable name="lon" shape="lon" type="int">
    <attribute name="units" type="String" value="degrees_east" />
    <attribute name="long_name" type="String" value="longitude" />
  </variable>
  <variable name="level" shape="level" type="int">
    <attribute name="standard_name" type="String" value="air_pressure" />
    <attribute name="units" type="String" value="millibars" />
  </variable>
  <variable name="temp" shape="time level lat lon" type="float">
    <attribute name="long_name" type="String" value="temperature" />
    <attribute name="standard_name" type="String" value="air_temperature" />
    <attribute name="units" type="String" value="celsius" />
  </variable>
  <variable name="rh" shape="time lat lon" type="float">
    <attribute name="long_name" type="String" value="relative humidity" />
    <attribute name="valid_range" type="double" value="0.0 1.0" />
  </variable>
</netcdf>
3.4.3 NCML-CS
参考网址:http://www.unidata.ucar.edu/projects/THREDDS/GALEON/NetCDFandStandards.htm
<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.ucar.edu/schemas/netcdf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ucar.edu/schemas/netcdf http://www.unidata.ucar.edu/schemas/netcdf-cs.xsd" uri="T:/GALEON/SimpleSamples/SampleNetCDFbens.nc">
  <dimension name="lat" length="5" />
  <dimension name="lon" length="10" />
  <dimension name="level" length="4" />
  <dimension name="time" length="1" isUnlimited="true" />
  <attribute name="source" type="String" value="Fictional Model Output" />
  <attribute name="Conventions" type="String" value="CF-1.0" />
  <coordinateAxis name="time" shape="time" type="short" units="hours since 1996-1-1" axisType="Time">
    <attribute name="standard_name" type="String" value="time" />
    <attribute name="units" type="String" value="hours since 1996-1-1" />
    <attribute name="_CoordinateAxisType" type="String" value="Time" />
  </coordinateAxis>
  <coordinateAxis name="lat" shape="lat" type="int" units="degrees_north" axisType="Lat">
    <attribute name="units" type="String" value="degrees_north" />
    <attribute name="standard_name" type="String" value="latitude" />
    <attribute name="_CoordinateAxisType" type="String" value="Lat" />
  </coordinateAxis>
  <coordinateAxis name="lon" shape="lon" type="int" units="degrees_east" axisType="Lon">
    <attribute name="units" type="String" value="degrees_east" />
    <attribute name="long_name" type="String" value="longitude" />
    <attribute name="_CoordinateAxisType" type="String" value="Lon" />
  </coordinateAxis>
  <coordinateAxis name="level" shape="level" type="int" units="millibars" axisType="Pressure">
    <attribute name="standard_name" type="String" value="air_pressure" />
    <attribute name="units" type="String" value="millibars" />
    <attribute name="_CoordinateAxisType" type="String" value="Pressure" />
  </coordinateAxis>
  <variable name="temp" shape="time level lat lon" type="float" coordinateSystems="time-level-lat-lon">
    <attribute name="long_name" type="String" value="temperature" />
    <attribute name="standard_name" type="String" value="air_temperature" />
    <attribute name="units" type="String" value="celsius" />
  </variable>
  <variable name="rh" shape="time lat lon" type="float" coordinateSystems="time-lat-lon">
    <attribute name="long_name" type="String" value="relative humidity" />
    <attribute name="valid_range" type="double" value="0.0 1.0" />
  </variable>
  <coordinateSystem name="time-level-lat-lon">
    <coordinateAxisRef ref="time" />
    <coordinateAxisRef ref="level" />
    <coordinateAxisRef ref="lat" />
    <coordinateAxisRef ref="lon" />
  </coordinateSystem>
  <coordinateSystem name="time-lat-lon">
    <coordinateAxisRef ref="time" />
    <coordinateAxisRef ref="lat" />
    <coordinateAxisRef ref="lon" />
  </coordinateSystem>
</netcdf>
…………
 

 

 

分享到:
评论

相关推荐

    C# 读写netCDF 文件

    包括netCDF4.dll 以及.net环境下的C#调用demo,一维数据和二维数据的读写类库。

    netcdf-cxx4.rar

    NetCDF(network Common Data Form)网络通用数据格式,是一种面向数组型并适于网络共享的数据的描述和编码标准。目前,NetCDF广泛应用于大气科学、水文、海洋学、环境模拟、地球物理等诸多领域。用户可以借助多种方式...

    netCDF数据集介绍

    一个NetCDF数据集包含维(dimensions)、变量(variables)和属性(attributes)三种描述 NetCDF name{  Dimensions:… //定义维数  Variables:… //定义变量  Attributes:… //属性  Data:…//数据 }

    基于Java的NetCDF文件解析

    基于Java语言的NetCDF文件解析,使用了netcdf4和opencsv两个库,最终将解析后的数据导出为CSV,附依赖文件、源代码及一个测试数据样例。 可结合本人的博客...

    NetCDF数据的编程式访问.pdf

    NetCDF 是一种面向数组型数据的描述和编码标准,目前广泛应用于大气科学、水文、海洋学、环境模拟、地球 物理等诸多领域。用户可以借助多种方式方便地管理和操作NetCDF 数据集。文章介绍NetCDF 数据的编程式访问 方法...

    netcdf-3.6.2.tar.gz

    搜狗百科————NetCDF(network Common Data Form)网络通用数据格式是由美国大学大气研究协会(University Corporation for Atmospheric Research,UCAR)的Unidata项目科学家针对科学数据的特点开发的,是一种面向...

    netcdf的入门教程

    netcdf 讲解和运用 NetCDF全称为...对程序员来说,它和zip、jpeg、bmp文件格式类似,都是一种文件格式的标准。netcdf 文件开始的目的是用于存储气象科学中的数据,现在已经成为许多数据采集软件的生成文件 的格式

    netcdf-c-4.4.1.1.tar.gz

    NetCDF(network Common Data Form)网络通用数据格式是由美国大学大气研究协会(University Corporation for Atmospheric Research,UCAR)的Unidata项目科学家针对科学数据的特点开发的,是一种面向数组型并适于网络...

    NetCDF入门.doc

    NetCDF全称为network Common Data Format,中文译法为“网络通用数据格式”,对程序员来说,它和zip、jpeg、bmp文件格式类似,都是一种文件格式的标准。netcdf文件开始的目的是用于存储气象科学中的数据,现在已经...

    【QGIS跨平台编译】之【netcdf跨平台编译】:源码及跨平台编译工程(支撑QGIS跨平台编译,以及二次研发)

    一、内容概况 QGIS是一个开源的、跨平台的地理信息系统(GIS)软件,用于浏览、编辑和分析地理空间数据,提供了一套丰富的功能,包括地图制作、空间分析、数据管理等。QGIS可以在Windows、Mac OS和Linux等操作系统上...

    netCDF4.7.3-NC4-64.exe

    NetCDF(network Common Data Form)网络通用数据格式是由美国大学大气研究协会(University Corporation for Atmospheric Research,UCAR)的Unidata项目科学家针对科学数据的特点开发的,是一种面向数组型并适于网络...

    MySQL、NetCDF、N1、HDF5、HDF4读写操作类

    MySQL、NetCDF、N1、HDF5、HDF4读写操作类。希望对童鞋们有用处

    netCDF4.8.1-NC4-64.exe

    NetCDF(network Common Data Form)网络通用数据格式是一种面向数组型并适于网络共享的数据的描述和编码标准。目前,NetCDF广泛应用于大气科学、水文、海洋学、环境模拟、地球物理等诸多领域。用户可以借助多种方式...

    fortran版的netcdf4数据写入

    netcdf是一种在地学领域较为广泛使用的数据格式,具有可压缩,带有地理信息,交换方便等特点.本人以grads格式数据为例,写了fortran代码.经过测试,可以满足大多数场合.

    netcdf-fortran:取决于netCDF C库的netCDF-Fortran库的官方GitHub存储库。 首先安装netCDF C库

    Unidata NetCDF Fortran库概述Unidata网络通用数据表单(netCDF)是用于科学数据访问的接口,并且是一组自由分发的软件库,它们提供了该接口的实现。 netCDF库还定义了一种与机器无关的格式,用于表示科学数据。 ...

    netcdf介绍及在C语言中应用

    一、NetCDF文件介绍 2 1、简介 2 2、netCDF优点 2 3、NetCDF缺点 2 二、NetCDF文件结构 3 1、结构描述 3 2、结构之间的内在联系 3 三、NetCDF 接口函数库 4 1、NetCDF 接口函数库 4 2、C版本的NetCDF 数据的接口函数...

    Qt 采用NetCDF 解析NC文件

    Qt 解析 NC 文件,读取一维、二维、三维、四维数据

    NetCDF简介与格式入门

     NetCDF全称为network Common Data Format,中文译法为“网络通用数据格式”,它是由美国大学大气研究协会的Unidata项目科学家针对科学数据的特点开发的,是一种面向数组型并适于网络共享的数据描述和编码标准。...

    netcdf数据查看nc文件

    netcdf,在linux环境下装,windows可能要用到cygwin安装,安装后可以查看.nc文件,NetCDF(network Common Data Form)网络通用数据格式是由美国大学大气研究协会(University Corporation for Atmospheric Research,...

    Matlab读取netCDF的ID.docx

    Matlab读取netCDF的ID.docx

Global site tag (gtag.js) - Google Analytics