1 | #!/opt/local/bin/python |
---|
2 | |
---|
3 | import os,sys |
---|
4 | from netCDF4 import Dataset as netcdf |
---|
5 | import numpy as np |
---|
6 | |
---|
7 | resname='r025' |
---|
8 | |
---|
9 | # input file |
---|
10 | fcoord='coordinates_'+str(resname)+'.nc' |
---|
11 | |
---|
12 | # output file |
---|
13 | fflx='flx_'+str(resname)+'.nc' |
---|
14 | |
---|
15 | print ' creating FLX file '+fflx+'...' |
---|
16 | |
---|
17 | # Reading coordinates file |
---|
18 | nccoord=netcdf(fcoord,'r') |
---|
19 | nav_lon=nccoord.variables['glamt'] |
---|
20 | nav_lat=nccoord.variables['gphit'] |
---|
21 | LON1= nav_lon.shape[1] |
---|
22 | LAT1= nav_lon.shape[0] |
---|
23 | |
---|
24 | # Creating FLX netcdf file |
---|
25 | nc=netcdf(fflx,'w') |
---|
26 | nc.createDimension('y',LAT1) |
---|
27 | nc.createDimension('x',LON1) |
---|
28 | nc.createDimension('time_counter',None) |
---|
29 | |
---|
30 | cdflon=nc.createVariable('nav_lon','f',('y','x')) |
---|
31 | cdflat=nc.createVariable('nav_lat','f',('y','x')) |
---|
32 | cdftimecounter=nc.createVariable('time_counter','f',('time_counter')) |
---|
33 | cdfutau=nc.createVariable('utau','f',('time_counter','y','x')) |
---|
34 | cdfvtau=nc.createVariable('vtau','f',('time_counter','y','x')) |
---|
35 | cdfqtot=nc.createVariable('qtot','f',('time_counter','y','x')) |
---|
36 | cdfqsr=nc.createVariable('qsr','f',('time_counter','y','x')) |
---|
37 | cdfemp=nc.createVariable('emp','f',('time_counter','y','x')) |
---|
38 | |
---|
39 | cdflon[:,:]=nav_lon[:,:] |
---|
40 | cdflat[:,:]=nav_lat[:,:] |
---|
41 | |
---|
42 | # Fill fields |
---|
43 | |
---|
44 | cdfutau[:,:,:]=-0.1 |
---|
45 | cdfvtau[:,:,:]=0 |
---|
46 | cdfqtot[:,:,:]=0 |
---|
47 | cdfqsr[:,:,:]=0 |
---|
48 | cdfemp[:,:,:]=0 |
---|
49 | |
---|
50 | nc.close() |
---|
51 | nccoord.close() |
---|
52 | |
---|
53 | #sys.exit() |
---|