New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
make_coordinates_gphi0.py in branches/2015/dev_r5102_CNRS11_TestCase/NEMOGCM/TOOLS/TEST_CASES/CREATE_FILES – NEMO

source: branches/2015/dev_r5102_CNRS11_TestCase/NEMOGCM/TOOLS/TEST_CASES/CREATE_FILES/make_coordinates_gphi0.py @ 5346

Last change on this file since 5346 was 5287, checked in by flavoni, 9 years ago

commit scripts python to create files needed for test cases,and examples; related to ticket #1469

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/opt/local/bin/python
2# python script to create coordinates files with e1=e2=constant, and gphit=gphiu=gphiv=gphif=0 (to do not have CORIOLIS)
3
4import os,sys
5from netCDF4 import Dataset as netcdf
6import numpy as np
7import math
8
9res=0.25
10resname='r025'
11
12# output file
13fcoord='coordinates_'+str(resname)+'_cst_gphi0.nc'
14
15latmin=-30.
16latmax=30.
17latres=res
18
19lonmin=0.
20lonmax=180.
21lonres=res
22
23#LONGITUDE
24nb_lonpoints=int((lonmax-lonmin)/lonres+1)
25lontot=np.zeros(nb_lonpoints)
26
27lon=lonmin
28end=(lonmax-lonmin)
29
30ii=0
31while lon <= end :
32   lontot[ii]=lon
33   lon=lon+lonres
34   ii=ii+1
35
36# LATITUDE
37# one point at equator needed
38LAT1=int(latmax/latres+1)
39LAT=2*LAT1-1
40lat1=np.zeros(LAT1)
41lat2=np.zeros(LAT1)
42lat3=np.zeros(LAT)
43
44lat=0.
45ii=0
46while lat <= latmax :
47   lat1[ii]=lat
48   lat=lat+latres
49   ii=ii+1
50
51lat=0.
52ii=0
53while lat >= latmin :
54   lat2[ii]=lat
55   lat=lat-latres
56   ii=ii+1
57
58ii=0
59while ii < LAT1 :
60   lat3[ii]=lat2[-1-ii]
61   ii=ii+1
62
63ii=0
64while ii < LAT1 :
65   lat3[LAT1-1+ii]=lat1[ii]
66   ii=ii+1
67
68print '\n    lat3:\n', lat3
69
70
71print '   creating coordinates file  '+fcoord+'...'
72
73LON=nb_lonpoints
74nc=netcdf(fcoord,'w')
75nc.createDimension('y',LAT)
76nc.createDimension('x',LON)
77
78cdfglamt=nc.createVariable('glamt','f',('y','x'))
79cdfgphit=nc.createVariable('gphit','f',('y','x'))
80cdfglamu=nc.createVariable('glamu','f',('y','x'))
81cdfgphiu=nc.createVariable('gphiu','f',('y','x'))
82cdfglamv=nc.createVariable('glamv','f',('y','x'))
83cdfgphiv=nc.createVariable('gphiv','f',('y','x'))
84cdfglamf=nc.createVariable('glamf','f',('y','x'))
85cdfgphif=nc.createVariable('gphif','f',('y','x'))
86
87cdfe1t=nc.createVariable('e1t','f',('y','x'))
88cdfe1u=nc.createVariable('e1u','f',('y','x'))
89cdfe1v=nc.createVariable('e1v','f',('y','x'))
90cdfe1f=nc.createVariable('e1f','f',('y','x'))
91cdfe2t=nc.createVariable('e2t','f',('y','x'))
92cdfe2u=nc.createVariable('e2u','f',('y','x'))
93cdfe2v=nc.createVariable('e2v','f',('y','x'))
94cdfe2f=nc.createVariable('e2f','f',('y','x'))
95
96# gphi = 0
97for ii in range (LAT):
98   cdfgphit[ii,:]=0.
99   cdfgphiu[ii,:]=0.
100   cdfgphiv[ii,:]=0.
101   cdfgphif[ii,:]=0.
102
103
104for ii in range (LON): 
105   cdfglamt[:,ii]=lontot[ii]
106   cdfglamu[:,ii]=lontot[ii] + lonres/2
107   cdfglamv[:,ii]=lontot[ii]
108   cdfglamf[:,ii]=lontot[ii] + lonres/2
109
110# from DOM/phycst.F90
111ra=6371229.                     # earth radius (meter)
112rpi=math.pi
113rad=rpi / 180.     # conversion from degre into radian
114
115# e2 = constant
116cdfe2t[:,:]=latres*rad*ra
117cdfe2u[:,:]=latres*rad*ra
118cdfe2v[:,:]=latres*rad*ra
119cdfe2f[:,:]=latres*rad*ra
120
121# e1 = constant
122cdfe1t[:,:]=lonres*rad*ra
123cdfe1u[:,:]=lonres*rad*ra
124cdfe1v[:,:]=lonres*rad*ra
125cdfe1f[:,:]=lonres*rad*ra
126
127
128nc.close()
129
130#sys.exit()
131
132
Note: See TracBrowser for help on using the repository browser.