-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.py
63 lines (49 loc) · 2.02 KB
/
utils.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
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Misc functionality.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from future.builtins import * # NOQA
import inspect
import os
ROOT = os.path.dirname(os.path.abspath(inspect.getfile(
inspect.currentframe())))
def parse_phase_list(phase_list):
"""
Takes a list of phases, returns a list of individual phases. Performs e.g.
replacing e.g. ``"ttall"`` with the relevant phases.
"""
phase_names = []
for phase_name in phase_list:
phase_names += get_phase_names(phase_name)
# Remove duplicates.
return sorted(list(set(phase_names)))
def get_phase_names(phase_name):
"""
Called by parse_phase_list to replace e.g. ttall with the relevant phases.
"""
lphase = phase_name.lower()
names = []
if lphase in ("ttp", "tts", "ttbasic", "tts+", "ttp+", "ttall"):
if lphase in ("ttp", "ttp+", "ttbasic", "ttall"):
names.extend(["p", "P", "Pn", "Pdiff", "PKP", "PKiKP", "PKIKP"])
if lphase in ("tts", "tts+", "ttbasic", "ttall"):
names.extend(["s", "S", "Sn", "Sdiff", "SKS", "SKIKS"])
if lphase in ("ttp+", "ttbasic", "ttall"):
names.extend(["PcP", "pP", "pPdiff", "pPKP", "pPKIKP", "pPKiKP",
"sP", "sPdiff", "sPKP", "sPKIKP", "sPKiKP"])
if lphase in ("tts+", "ttbasic", "ttall"):
names.extend(["sS", "sSdiff", "sSKS", "sSKIKS", "ScS", "pS",
"pSdiff", "pSKS", "pSKIKS"])
if lphase in ("ttbasic", "ttall"):
names.extend(["ScP", "SKP", "SKIKP", "PKKP", "PKIKKIKP", "SKKP",
"SKIKKIKP", "PP", "PKPPKP", "PKIKPPKIKP"])
if lphase == "ttall":
names.extend(["SKiKP", "PP", "ScS", "PcS", "PKS", "PKIKS", "PKKS",
"PKIKKIKS", "SKKS", "SKIKKIKS", "SKSSKS",
"SKIKSSKIKS", "SS", "SP", "PS"])
else:
names.append(phase_name)
return names