-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrun_assemble.py
executable file
·50 lines (42 loc) · 1.78 KB
/
run_assemble.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
#!/usr/bin/env python3
# coding: utf-8
import numpy as np
import datetime
import argparse
import sys
sys.path.append("..")
import trace_source
parser = argparse.ArgumentParser()
parser.add_argument('--station', help='station name like limassol, barbados or mcmurdo')
parser.add_argument('--date', help='date in the format YYYYMMDD')
parser.add_argument('--daterange', help='date range in the format YYYYMMDD-YYYMMDD')
parser.add_argument('--model', help='model to plot, default hysplit', default='hysplit')
args = parser.parse_args()
if args.station is not None:
config = 'config_{}.toml'.format(args.station)
else:
config = 'config.toml'
if args.date is not None:
print('date ', args.date)
dt = datetime.datetime.strptime(args.date, '%Y%m%d')
dt_range = (dt, dt + datetime.timedelta(hours=23))
if args.model == 'hysplit':
ath = trace_source.hysplit.assemble_time_height(config_file=config)
elif args.model == 'flex':
ath = trace_source.flexpart.assemble_time_height(config_file=config)
ath.assemble(dt_range=dt_range)
ath.dump2netcdf(model_str=args.model)
if args.daterange is not None:
begin = datetime.datetime.strptime(args.daterange.split('-')[0], '%Y%m%d')
end = datetime.datetime.strptime(args.daterange.split('-')[1], '%Y%m%d')
print('daterange ', begin, 'to', end)
current = begin
while current <= end:
dt_range = (current, current + datetime.timedelta(hours=23))
if args.model == 'hysplit':
ath = trace_source.hysplit.assemble_time_height(config_file=config)
elif args.model == 'flex':
ath = trace_source.flexpart.assemble_time_height(config_file=config)
ath.assemble(dt_range=dt_range)
ath.dump2netcdf(model_str=args.model)
current += datetime.timedelta(days=1)