source: branches/2015/dev_r5102_CNRS11_TestCase/NEMOGCM/TOOLS/TEST_CASES/CREATE_FILES/make_TS_init_tprof.py @ 5359

Last change on this file since 5359 was 5359, checked in by flavoni, 6 years ago

correct mistake in python script, related to ticket #1469

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/opt/local/bin/python
2
3import os,sys
4from netCDF4 import Dataset as netcdf
5import numpy as np
6
7resname='r025'
8
9# input file
10fcoord='coordinates_'+str(resname)+'.nc'
11ftref='t_profil.nc'
12
13# Output files
14fTSinit='TS_init_tprof_'+str(resname)+'.nc'
15
16DEPTH1=31
17
18print '   creating TS init file  '+fTSinit+'...'
19
20# Reading coordinates file
21nccoord=netcdf(fcoord,'r')
22nav_lon=nccoord.variables['glamt']
23nav_lat=nccoord.variables['gphit']
24LON1= nav_lon.shape[1]
25LAT1= nav_lon.shape[0]
26# Reading votemper value from t_profil.nc file: average of levitus monthly file, between x=38,106 y=52,94
27nctref=netcdf(ftref,'r')
28ncvotemper=nctref.variables['votemper']
29
30end=int(len(ncvotemper))
31
32# Creating TS init netcdf file
33nc=netcdf(fTSinit,'w')
34nc.createDimension('z',DEPTH1)
35nc.createDimension('y',LAT1)
36nc.createDimension('x',LON1)
37nc.createDimension('time_counter',None)
38
39cdflon=nc.createVariable('nav_lon','f',('y','x'))
40cdflat=nc.createVariable('nav_lat','f',('y','x'))
41cdfdepth=nc.createVariable('deptht','f',('z'))
42cdftimecounter=nc.createVariable('time_counter','f',('time_counter'))
43cdfthetao=nc.createVariable('thetao','f',('time_counter','z','y','x'))
44cdfso=nc.createVariable('so','f',('time_counter','z','y','x'))
45
46cdflon[:,:]=nav_lon[:,:]
47cdflat[:,:]=nav_lat[:,:]
48
49## test 1 : T & S Constants
50cdfso[0,:,:,:]=35
51#cdfthetao[0,:,:,:]=10   
52count=0
53while count < end :
54   cdfthetao[:,count,:,:]=ncvotemper[count]
55        count=count+1
56
57
58#sys.exit()
59
60nc.close()
61nccoord.close()
62
Note: See TracBrowser for help on using the repository browser.