source:
branches/2015/dev_r5102_CNRS11_TestCase/NEMOGCM/TOOLS/TEST_CASES/CREATE_FILES/make_bathy.py
@
5287
Last change on this file since 5287 was 5287, checked in by flavoni, 9 years ago | |
---|---|
|
|
File size: 806 bytes |
Line | |
---|---|
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 | fbathy='bathy_'+str(resname)+'.nc' |
14 | |
15 | # Reading coordinates file |
16 | nccoord=netcdf(fcoord,'r') |
17 | nav_lon=nccoord.variables['glamt'] |
18 | nav_lat=nccoord.variables['gphit'] |
19 | LON1= nav_lon.shape[1] |
20 | LAT1= nav_lon.shape[0] |
21 | |
22 | print ' creating bathymetry file '+fbathy+'...' |
23 | |
24 | # Creating bathy netcdf file |
25 | nc=netcdf(fbathy,'w') |
26 | nc.createDimension('y',LAT1) |
27 | nc.createDimension('x',LON1) |
28 | |
29 | cdflon=nc.createVariable('nav_lon','f',('y','x')) |
30 | cdflat=nc.createVariable('nav_lat','f',('y','x')) |
31 | cdfbathy=nc.createVariable('Bathymetry','f',('y','x')) |
32 | |
33 | cdflon[:,:]=nav_lon[:,:] |
34 | cdflat[:,:]=nav_lat[:,:] |
35 | cdfbathy[:,:]=5000 |
36 | |
37 | nc.close() |
38 | nccoord.close() |
39 | |
40 |
Note: See TracBrowser
for help on using the repository browser.