- 积分
- 1901
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-1-6
- 最后登录
- 1970-1-1
|
发表于 2016-5-12 14:43:02
|
显示全部楼层
本帖最后由 xuebiz 于 2016-5-12 14:57 编辑
http://www.ncl.ucar.edu/Document ... t-in/addfiles.shtml
---------------------------------------------------------------------------
Prototype
function addfiles (
file_path : string,
status : string
)
return_val [1] : list
------------------------------------------------------------------------------------
Examples
Note: all examples assume NCL version 5.1.0
-----------------------------------------------------------------------------------------
Example 1
Read in a series of netCDF files (here, 5 files each with 12 time steps), and read into memory the four dimensional variable T(ntim,klvl,nlat,mlon), where ntim=12, klvl=5, nlat=48, mlon=96:
fils = systemfunc ("ls /model/annual*.nc") ; file paths
f = addfiles (fils, "r")
ListSetType (f, "cat") ; concatenate (=default)
T = f[:]->T ; read T from all files
printVarSummary (T)
------------------------------
The printVarSummary procedure yields:
Variable: T
Type: float
Total Size: 5529600 bytes
1382400 values
Number of Dimensions: 4
Dimensions and sizes: [time | 60] x [lev 5] x [lat | 48] x [lon | 96]
Coordinates:
time: [2349..4143]
lev: [850..200]
lat: [-87.15909..87.15909]
lon: [ 0..356.25]
Number Of Attributes: 2
units : K
long_name : temperature
The size of the time dimension is now 60 (=5*12), while the other dimensions remain the same.
------------------------------------------------------------------
Example 2
The "XXX" files have no record dimension. All records are 5 (levels) x 48 (latitudes) x 96 (longitudes). Here we use the "join" option. This adds an extra dimension.
diri = "/fs/cgd/data0/casguest/CLASS/" ; input directory
fils = systemfunc ("ls "+diri+"XXX*.nc") ; file paths
f = addfiles (fils, "r") ; note the "s" of addfile
ListSetType (f, "join")
T = f[:]->T ; read T from all files
printVarSummary (T)
------------------------------
The printVarSummary procedure yields:
Variable: T
Type: float
Total Size: 460800 bytes
115200 values
Number of Dimensions: 5
Dimensions and sizes: [ncl_join | 5] x [lev | 5] x [lat | 48] x [lon | 96]
Coordinates:
lev: [850000..250.]
lat: [-87.15909..87.15909]
lon: [ 0..356.25]
Number Of Attributes: 2
units : K
long_name : temperature
---------------------------------------------------------------------
Example 3
Generally, when there is a record dimension one uses the "cat" option. In this example, let's assume the five different runs were made for a particular year. Each run was done using, say, different boundary layer parameterizations. Here the time variable is the same for each file and we want to compare the five different cases. The appropriate choice for this case is "join":
diri = "/fs/cgd/data0/casguest/CLASS/" ; input directory
fils = systemfunc ("ls "+diri+"Bound*.nc") ; file paths
f = addfiles (fils, "r") ; note the "s" of addfile
ListSetType (f, "join")
T = f[:]->T ; read T from all files
printVarSummary (T)
-------------------------------
The printVarSummary procedure yields:
Variable: T
Type: float
Total Size: 5529600 bytes
1382400 values
Number of Dimensions: 5
Dimensions and sizes: [ncl_join | 5] x [time | 12] x [lev | 5] x [lat | 48] x [lon | 96]
Coordinates:
time: [2349..2683]
lev: [850..250.]
lat: [-87.15909..87.15909]
lon: [ 0..356.25]
Number Of Attributes: 2
units : K
long_name : temperature
---------------------------------------------------------------
Example 4
Read in the same series of netCDF files as in example 1, but access only each eighth step of the aggregated time dimension, and latitudes between -40 and +40. Since there are 12 timesteps in each file, two timesteps will be extracted from the first file, one from the second, two from the third, and so forth.
fils = systemfunc ("ls /model/annual*.nc") ; file paths
f = addfiles (fils, "r")
ListSetType (f, "cat") ; concatenate (=default)
T = f[:]->T(::8,:,{-40:40},:) ; read T with a stride of 8
printVarSummary (T)
---------------------------------------------------
The printVarSummary procedure yields:
Variable: T
Type: float
Total Size: 337920 bytes
84480 values
Number of Dimensions: 4
Dimensions and sizes: [time | 8] x [lev 5] x [lat | 22] x [lon | 96]
Coordinates:
time: [2349..4052]
lev: [850..200]
lat: [-38.94342..38.94342]
lon: [ 0..356.25]
Number Of Attributes: 2
units : K
long_name : temperature
|
|