Size: 669
Comment:
|
Size: 712
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
== Read NetCDF files == | |
Line 14: | Line 13: |
== Read NetCDF files == |
|
Line 35: | Line 37: |
}}} | |
Line 36: | Line 39: |
== Create NetCDF file == | |
Line 37: | Line 41: |
}}} | {{{#!python |
PyNIO
Download a sample file (CCM precipitation flux, air temperature, etc)
- load python module and start ipython
module load python/2.7-ve0 ipython
Ipython listing
Read NetCDF files
1 # load Nio module
2 import Nio
3
4 # open netcdf file
5 f = Nio.open_file('sresa1b_ncar_ccsm3_0_run1_200001.nc', 'r') # 'r' stands for "read rights"
6
7 # check contents
8 print f
9
10 # read single variable:
11 pr = f.variables['pr']
12 print pr
13
14 # read variables contents
15 pr_data = pr[:]
16 print pr_data
17
18 # close file
19 f.close()