-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsimple_compare.py
More file actions
executable file
·73 lines (64 loc) · 2.17 KB
/
simple_compare.py
File metadata and controls
executable file
·73 lines (64 loc) · 2.17 KB
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
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
"""
# ==============================================================================
# The program is to plot a simple comparison among timeseries files
# ==============================================================================
"""
from __future__ import division, print_function
import os
import sys
from ptools import read_file
from compare_signals import simple_plot, set_parameter
def simple_compare_main():
"""
Main function for simple_compare
"""
num_lines = 0
output_file = ''
# Parse command line
if len(sys.argv) == 1:
while True:
num_lines = raw_input("==> How many files to plot: ")
try:
num_lines = int(num_lines)
if num_lines > 0:
break
except ValueError:
pass
else:
# First argument is number of timeseries
num_lines = int(sys.argv[1])
if len(sys.argv) < 3:
output_file = raw_input("==> Output filename: ")
else:
# Second argument is output filename
output_file = sys.argv[2]
# Allow user to specify screen output by using -
if output_file == "-":
output_file = ""
filenames = []
# Get input files
if len(sys.argv) >= num_lines + 3:
# User provided all input file names
filenames = sys.argv[3:(num_lines + 3)]
para = sys.argv[(num_lines + 3):]
else:
# Need to ask user
para = sys.argv[3:]
remaining = num_lines
while remaining:
input_file = raw_input("==> Enter input file %d: " %
(num_lines - remaining + 1))
filenames.append(input_file)
remaining = remaining - 1
# Set all other parameters
parameter = set_parameter(para)
# Read data
stations = [read_file(filename) for filename in filenames]
filenames = [os.path.basename(filename) for filename in filenames]
# Create plot
simple_plot(parameter, filenames, stations, output_file=output_file)
# ============================ MAIN ==============================
if __name__ == "__main__":
simple_compare_main()
# end of main program