-
Notifications
You must be signed in to change notification settings - Fork 9
/
generate_schedule.py
executable file
·49 lines (40 loc) · 2.1 KB
/
generate_schedule.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
import argparse
import json
from json.decoder import JSONDecodeError
import warnings
from spice_ev import util
from spice_ev.generate.generate_schedule import generate_schedule
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Generate a schedule for a scenario.')
parser.add_argument('scenario', nargs='?', help='Scenario input file')
parser.add_argument('--input',
help='Timeseries with power and limit. '
'Columns: "curtailment", "residual load" (timestamp ignored)')
parser.add_argument('--output', '-o',
help='Specify schedule file name, '
'defaults to <scenario>_schedule.csv')
parser.add_argument('--individual', '-i', action='store_true',
help='schedule based on individual vehicles instead of vehicle park')
parser.add_argument('--core-standing-time', default=None,
help='Define time frames as well as full '
'days during which the fleet is guaranteed to be available in a JSON '
'obj like: {"times":[{"start": [22,0], "end":[1,0]}], "no_drive_days":[6]}')
parser.add_argument('--visual', '-v', action='store_true', help='Plot flexibility and schedule')
parser.add_argument('--config', help='Use config file to set arguments')
args = parser.parse_args()
# parse JSON obj for core standing time if supplied via cmd line
try:
args.core_standing_time = json.loads(args.core_standing_time)
except JSONDecodeError:
args.core_standing_time = None
warnings.warn('Value for core standing time could not be parsed and is omitted.')
except TypeError:
# no core standing time provided, defaulted to None
pass
util.set_options_from_config(args, check=parser, verbose=False)
missing = [arg for arg in ["scenario", "input"] if vars(args).get(arg) is None]
if missing:
raise SystemExit("The following arguments are required: {}".format(", ".join(missing)))
generate_schedule(args)