-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_pism_adjusting
executable file
·60 lines (48 loc) · 1.94 KB
/
run_pism_adjusting
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
#!/usr/bin/env python
import netCDF4 as nc
# import matplotlib.pylab as mpl
import sys
import flo_utils as fu
from argparse import ArgumentParser
import shutil
import numpy as np
def run_pism(filename_start, start, end, config, options):
# filename_start = "adjust_test"
## repeat:
for counter in xrange(start, end) :
# run pism
input_file = filename_start + "_input_%04i.nc"%(counter)
output_file = filename_start + "_output_%04i.nc"%(counter)
options_geloet = " -c %s -y 10 --force_to_thk topo_hand.nc --force_to_thk_alpha 0.2 --no-ssa "%(config)
fu.qo("run_pism -i %s -o %s %s"%(input_file, output_file, options_geloet))
# copy the output file
input_file = filename_start + "_input_%04i.nc"%(counter+1)
shutil.copyfile(output_file, input_file)
# call adjust_topg
fu.qo("adjust_topg %s -s state.nc"%(input_file))
shutil.copyfile("state.nc", "state_" + input_file)
def parse_args():
parser = ArgumentParser()
parser.description = "compare slopes of two variables from two files"
# parser.add_argument("FILES", nargs=1)
parser.add_argument("-v", "--verbose",
help='''Be verbose''', action="store_true")
parser.add_argument("-f", "--filename_start",
help='''start of file name ''', required = True)
parser.add_argument("-s", "--start",
help='''number of start file''', required = True, type = int)
parser.add_argument("-e", "--end",
help='''number of end file''', required = True, type = int)
parser.add_argument("-c", "--config",
help='''config file''', required = True)
options = parser.parse_args()
return options
def main():
options = parse_args()
if options.verbose:
print (dir(options))
print options.FILES
fu.debug=True
run_pism(options.filename_start, optios.start, options.end, options.config, vars(options))
if __name__ == "__main__":
main()