一、概述
NetCDF全稱爲network Common Data Format,中文譯法爲“網絡通用數據格式”,它是由美國大學大氣研究協會的Unidata項目科學家針對科學數據的特點開發的,是一種面向數組型並適於網絡共享的數據描述和編碼標準。
NetCDF和zip、jpeg、bmp文件格式類似,都是一種文件格式的標準。NetCDF文件開始時目的是用於存儲氣象科學中的數據,現在已經成爲許多數據採集軟件生成文件的格式。利用NetCDF可以對網絡數據進行高效地存儲、管理、獲取和分發等操作。由於其靈活性,能夠傳輸海量的面向陣列(array-oriented)數據,目前廣泛應用於大氣科學、水文、海洋學、環境模擬、地球物理等諸多領域。
從數學上來說,netcdf存儲的數據就是一個多自變量的單值函數。用公式來說就是f(x,y,z,…)=value,函數的自變量x,y,z等在netcdf中叫做維(dimension)或座標軸(axis),函數值value在netcdf中叫做變量(Variables)。而自變量和函數值在物理學上的一些性質,比如計量單位(量綱)、物理學名稱等等在netcdf中就叫屬性(Attributes)。
二、文件格式
NetCDF文件後綴爲.nc,文件中的數據結構包含維(dimensions)、變量(variables)和屬性(attributes)三種描述類型。
可以使用ncdump
命令讀取並輸出nc文件裏的內容。
例如:
netcdf simple_xy {
dimensions:
x = 2 ;
y = 3 ;
variables:
int simple_data(x, y);
simple_data: description = "Simple XY"
data:
simple_data =
11, 12, 13,
21, 22, 23;
}
三、ncdump命令
參數 | 說明 |
---|---|
[-c] | Coordinate variable data and header information |
[-h] | Header information only, no data |
[-v var1[,…]] | Data for variable(s) ,… only |
[-b [c|f]] | Brief annotations for C or Fortran indices in data |
[-f [c|f]] | Full annotations for C or Fortran indices in data |
[-l len] | Line length maximum in data section (default 80) |
[-n name] | Name for netCDF (default derived from file name) |
[-p n[,n]] | Display floating-point values with less precision |
[-k] | Output kind of netCDF file |
[-s] | Output special (virtual) attributes |
[-t] | Output time data as date-time strings |
[-i] | Output time data as date-time strings with ISO-8601 ‘T’ separator |
[-g grp1[,…]] | Data and metadata for group(s) ,… only |
[-w] | With client-side caching of variables for DAP URLs |
[-x] | Output XML (NcML) instead of CDL |
[-Xp] | Unconditionally suppress output of the properties attribute |
[-Ln] | Set log level to n (>= 0); ignore if logging not enabled. |
file | Name of netCDF file (or URL if DAP access enabled) |