source: codes/icosagcm/devel/Python/test/py/write_Cartesian_mesh.py

Last change on this file was 869, checked in by dubos, 5 years ago

devel/Python : write cell bounds into mesh file / partition file

File size: 982 bytes
Line 
1from dynamico import getargs
2getargs.add("--nx", type=int, default=64, 
3                    help="number of points along the x axis")
4getargs.add("--ny", type=int, default=0,
5                    help="number of points along the y axis, defaults to nx")
6getargs.add("--Lx", type=float, default=0., 
7                    help="domain size along x, defaults to nx")
8getargs.add("--Ly", type=float, default=0., 
9                    help="domain size along y, defaults to ny")
10
11args = getargs.parse()
12for arg in vars(args): print arg, getattr(args, arg)
13
14from dynamico import meshes
15import numpy as np
16import netCDF4 as cdf
17import argparse
18
19nx, ny, Lx, Ly, llm, nqdyn = args.nx, args.ny,args.Lx, args.Ly, 1, 1
20if ny==0 : ny=nx
21if Lx==0. : Lx=nx
22if Ly==0. : Ly=ny
23
24dx,dy=Lx/nx,Ly/ny
25mesh = meshes.Cartesian_Mesh(nx,ny,llm,nqdyn,Lx,Ly,0.)
26print('Successfully initialized Cartesian mesh')
27mesh.ncwrite('cart_%03d_%03d.nc'%(nx,ny))
28print('Successfully written Cartesian mesh to NetCDF File')
Note: See TracBrowser for help on using the repository browser.