[7609] | 1 | from netCDF4 import Dataset |
---|
| 2 | import numpy as np |
---|
| 3 | |
---|
| 4 | pathout = "bdyssh_tc7" |
---|
| 5 | |
---|
| 6 | nx = 34 |
---|
| 7 | ny = 1 |
---|
| 8 | nt = 24 |
---|
| 9 | ndays=4 |
---|
| 10 | |
---|
| 11 | #------------------------------------------------------- |
---|
| 12 | # Create bdyssh_tc7_m01d01.nc, bdyssh_tc7_m01d02.nc etc. |
---|
| 13 | #------------------------------------------------------- |
---|
| 14 | |
---|
| 15 | pathstart="{}_m12d30.nc".format(pathout) |
---|
| 16 | for nd in range(ndays): |
---|
| 17 | print pathstart |
---|
| 18 | ssh = np.zeros((nt,ny,nx)) |
---|
| 19 | for nnt in range(nd*nt,(nd+1)*nt): |
---|
| 20 | tx = 2.5*np.cos((3.141592654/6.0)*(nnt+1.0)) |
---|
| 21 | print nnt, tx |
---|
| 22 | for nnx in range(nx): |
---|
| 23 | for nny in range(ny): |
---|
| 24 | ssh[nnt-nd*nt,nny,nnx] = tx |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | fo = Dataset(pathstart, 'w', format='NETCDF4') |
---|
| 28 | nxo = fo.createDimension('x', nx) |
---|
| 29 | nyo = fo.createDimension('y', ny) |
---|
| 30 | nto = fo.createDimension('t', None) |
---|
| 31 | ssho = fo.createVariable('sshbdy', 'f4',('t','y','x')) |
---|
| 32 | |
---|
| 33 | ssho[:,:,:] = ssh[:,:,:] |
---|
| 34 | ssho.long_name = 'bdy ssh boundary condition' |
---|
| 35 | ssho.standard_name = 'sshbdy' |
---|
| 36 | ssho.units = 'm' |
---|
| 37 | # |
---|
| 38 | fo.close() |
---|
| 39 | pathstart="{}_m01d{:0>2d}.nc".format(pathout,nd+1) |
---|
| 40 | |
---|
| 41 | #------------------------------------------------------- |
---|
| 42 | # Create bdyuv_tc7_m01d01.nc, bdyuv_tc7_m01d02.nc etc. |
---|
| 43 | # u is -(1/H)*d(ssh)/dt; v =0.0 |
---|
| 44 | #------------------------------------------------------- |
---|
| 45 | |
---|
| 46 | pathout = "bdyuv_tc7" |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | pathstart="{}_m12d30.nc".format(pathout) |
---|
| 50 | for nd in range(ndays): |
---|
| 51 | print pathstart |
---|
| 52 | u = np.zeros((nt,ny,nx)) |
---|
| 53 | for nnt in range(nd*nt,(nd+1)*nt): |
---|
| 54 | tx = 2.5*(3.141592654/6.0)*np.sin((3.141592654/6.0)*(nnt+1.0))/10.0 |
---|
| 55 | print nnt, tx |
---|
| 56 | for nnx in range(nx): |
---|
| 57 | for nny in range(ny): |
---|
| 58 | u[nnt-nd*nt,nny,nnx] = tx |
---|
| 59 | |
---|
| 60 | v = np.zeros((nt,ny,nx)) |
---|
| 61 | |
---|
| 62 | fo = Dataset(pathstart, 'w', format='NETCDF4') |
---|
| 63 | nxo = fo.createDimension('x', nx) |
---|
| 64 | nyo = fo.createDimension('y', ny) |
---|
| 65 | nto = fo.createDimension('t', None) |
---|
| 66 | uo = fo.createVariable('ubdy', 'f4',('t','y','x')) |
---|
| 67 | vo = fo.createVariable('vbdy', 'f4',('t','y','x')) |
---|
| 68 | |
---|
| 69 | uo[:,:,:] = u[:,:,:] |
---|
| 70 | uo.long_name = 'bdy u boundary condition' |
---|
| 71 | uo.standard_name = 'ubdy' |
---|
| 72 | uo.units = 'm/s' |
---|
| 73 | # |
---|
| 74 | vo[:,:,:] = v[:,:,:] |
---|
| 75 | vo.long_name = 'bdy v boundary condition' |
---|
| 76 | vo.standard_name = 'vbdy' |
---|
| 77 | vo.units = 'm/s' |
---|
| 78 | # |
---|
| 79 | fo.close() |
---|
| 80 | pathstart="{}_m01d{:0>2d}.nc".format(pathout,nd+1) |
---|