-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcreate_region
More file actions
executable file
·81 lines (57 loc) · 2.69 KB
/
create_region
File metadata and controls
executable file
·81 lines (57 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function
import argparse
from limited_area.limited_area import LimitedArea
if __name__ == "__main__":
description = ("Create a limited area MPAS grid from a global MPAS grid"
" and a file that specifies the regional area boundary.")
epilog = ("For more information please see: "
"https://github.com/MiCurry/MPAS-Limited-Area")
parser = argparse.ArgumentParser(description=description,
epilog=epilog)
required = parser.add_argument_group('Required', "Limited Area requires a"
" MPAS Grid as well as a"
" file specifying the"
" limited area.")
options = parser.add_argument_group('Options', "Options to generating the"
" MPAS limited area.")
required.add_argument('points',
help='Points file specifying the MPAS regional area',
type=str)
required.add_argument('grid',
nargs='?',
default=None,
help=('Global MPAS grid file. Either a grid.nc or'
' static.nc file'),
type=str)
options.add_argument('-v', '--verbose',
help='Turn on verbose setting 0-5',
type=int,
default=0)
options.add_argument('-p', '--plot',
help='Produce a plot of the region rather than subsetting',
action='store_true')
args, unkown = parser.parse_known_args()
if args.plot:
print('===== Making a plot only! ======')
else:
if args.grid is None:
import sys
print('Error: If the -p/--plot option is not specified, a netCDF file')
print(' to subset must be provided.')
sys.exit(1)
DEBUG = args.verbose
if DEBUG > 0:
print("DEBUG: DEBUG set to verbose level ", DEBUG, '\n')
if DEBUG > 1:
print("DEBUG: Grid File: ", args.grid)
print("DEBUG: Points File: ", args.points)
kwargs = { 'DEBUG' : DEBUG }
regional_area = LimitedArea(args.grid,
args.points,
args.plot,
format='NETCDF3_64BIT_OFFSET',
**kwargs)
regional_area.gen_region(**kwargs)
if DEBUG > 0:
print("DEBUG: Limited Area Creation Finished")