File indexing completed on 2021-08-11 05:12:25 UTC
view on githubraw file Latest commit 62748458 on 2021-08-11 00:15:22 UTC
62748458e3 Jeff*0001 import numpy as np
0002 from numpy import sin, pi, exp
0003 import matplotlib.pyplot as plt
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 dr = np.array([5.48716549, 6.19462098, 6.99291201, 7.89353689, \
0014 8.90937723, 10.05483267, 11.34595414, 12.80056778, \
0015 14.43837763, 16.28102917, 18.35210877, 20.67704362, \
0016 23.28285446, 26.1976981 , 29.45012046, 33.06792588, \
0017 37.07656002, 41.496912 , 46.34247864, 51.61592052, \
0018 57.30518684, 63.37960847, 69.78661289, 76.44996107, \
0019 83.27047568, 90.13003112, 96.89898027, 103.44631852, \
0020 109.65099217, 115.4122275 , 120.65692923, 125.34295968, \
0021 129.45821977, 133.01641219, 136.05088105, 138.60793752, \
0022 140.74074276, 142.50436556, 143.95220912, 145.133724 , \
0023 146.09317287, 146.86917206, 147.49475454, 147.99774783, \
0024 148.40131516, 148.72455653, 148.98310489, 149.18968055, \
0025 149.35458582])
0026 nx = 20
0027 ny = 40
0028 nr = len(dr)
0029 rF = (np.insert(np.cumsum(dr),0,0))
0030 z = np.diff(rF)/2 + rF[:-1]
0031 H = -np.sum(dr)
0032
0033
0034 bump_max = 2000.
0035 bathy = H * np.ones([ny, nx])
0036 bump = np.zeros([ny, nx])
0037
0038
0039 r1 = bump_max * sin(np.linspace(0,pi,9))
0040 r2 = np.reshape((np.linspace(0,1,6)), [6,1])
0041 bump[:,5:14] = r1;
0042
0043 bump[13:19,:] = bump[13:19,:] * np.flip(r2[:])
0044 bump[20:26,:] = bump[20:26,:] * r2[:]
0045 bump[18:21,:] = 0.0
0046 bathy = bathy + bump;
0047 bathy[0,:] = 0.
0048 bathy.astype('>f4').tofile('bathy.50km.bin')
0049
0050
0051 taux_max = 0.2
0052 taux = np.zeros([ny, nx])
0053 taux[:,:] = np.reshape(taux_max * sin(np.linspace(0,pi,ny)), [ny,1])
0054 taux.astype('>f4').tofile('zonal_wind.50km.bin')
0055
0056
0057
0058
0059
0060 rbcs_mask = np.zeros([nr, ny, nx])
0061 rbcs_mask[1:,-1,:] = 1.0
0062 rbcs_mask[1:,-2,:] = 0.25
0063 rbcs_mask.astype('>f4').tofile('T_relax_mask.50km.bin')
0064
0065
0066 Tmax = 10.
0067 Tmin = -2.
0068 sst_relax = np.zeros([ny, nx]) + np.reshape(
0069 Tmin + (Tmax-Tmin)/40 * np.linspace(0.5,39.5,ny),[ny,1])
0070 sst_relax.astype('>f4').tofile('SST_relax.50km.bin')
0071
0072
0073 h = 500
0074 T_surf = sst_relax
0075 zscale = (exp(-z/h) - exp(H/h)) / (1 - exp(H/h))
0076 zscale = np.reshape(zscale, [nr,1,1])
0077 T_3D = np.reshape(T_surf - Tmin, [1,ny,nx]) * zscale + Tmin
0078 T_3D.astype('>f4').tofile('temperature.50km.bin')