forked from jhkennedy/cism-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_time_and_coarsen.py
executable file
·58 lines (44 loc) · 1.7 KB
/
add_time_and_coarsen.py
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
#!/usr/bin/env python2
import os
import sys
import datetime
import argparse
from util import speak
def abs_existing_file(file):
file = os.path.abspath(file)
if not os.path.isfile(file):
print("Error! File does not exist: \n "+file)
sys.exit(1)
return file
# parse the command line arguments
parser = argparse.ArgumentParser() # -h or --help automatically included!
parser.add_argument('-e', '--extended', help='Produce the extended grid.', action='store_true')
volume = parser.add_mutually_exclusive_group()
volume.add_argument("-v", "--verbose", help="Increase the output verbosity", action="store_true")
volume.add_argument("-q", "--quiet", help="Run silently", action="store_true")
args = parser.parse_args()
#==== SETUP ====
# get args, time
# load data sets
#===============
stamp = datetime.date.today().strftime("%Y_%m_%d")
f_base = 'templates/greenland_1km.epsg3413.nc'
f_1km = 'complete/greenland_1km_'+stamp+'.epsg3413.nc'
f_template = 'greenland.epsg3413.config'
from data import epsg3413
lc_epsg_shr = 'data/EPSG3413/EPSG3413grid_shrunk.json' #NOTE: created by plot_grids.py
f_epsg_shr = abs_existing_file(lc_epsg_shr)
from data import bamberdem
#==== add time dim and shrink ====
# apply to all the variables and
# shrink to size around ice sheet
#=================================
speak.notquiet(args,"\nAdding the time dimension and creating the 1km dataset.")
epsg3413.add_time(args, f_base, f_1km, f_template, f_epsg_shr)
#==== Coarsen ====
# make 2, 4 and 8
# km datasets
#==================
speak.notquiet(args,"\nCreating coarser datasets.")
coarse_list = [2,4,5,8] # in km
bamberdem.coarsen(args, f_1km, f_template, coarse_list)