1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """
21 Kenozooid's plotting and data analysis command line user interface.
22 """
23
24 import os.path
25 import logging
26
27 from kenozooid.component import inject
28 from kenozooid.cli import CLICommand, ArgumentError, add_master_command, \
29 add_uddf_input
30
31 log = logging.getLogger('kenozooid.cli.da')
35 """
36 Plot profiles of dives command.
37 """
38 description = 'plot graphs of dive profiles'
39
40 @classmethod
42 """
43 Add options for plotting profiles of dives command.
44 """
45 parser.add_argument('--type', '-t',
46 dest='plot_type',
47 default='details',
48 choices=('details', 'cmp'),
49 help='type of plot')
50 parser.add_argument('--title',
51 action='store_true',
52 dest='plot_title',
53 default=False,
54 help='display plot title')
55 parser.add_argument('--info',
56 action='store_true',
57 dest='plot_info',
58 default=False,
59 help='display dive information (depth, time, temperature)')
60 parser.add_argument('--avg-depth',
61 action='store_true',
62 dest='plot_avg_depth',
63 default=False,
64 help='display dive average depth')
65 parser.add_argument('--mod',
66 action='store_true',
67 dest='plot_mod',
68 default=False,
69 help='plot MOD of current gas (for 1.4 and 1.6 ppO2)')
70 parser.add_argument('--temp',
71 action='store_true',
72 dest='plot_temp',
73 default=False,
74 help='plot temperature graph')
75 parser.add_argument('--no-sig',
76 action='store_false',
77 dest='plot_sig',
78 default=True,
79 help='do not display Kenozooid signature')
80 parser.add_argument('--legend',
81 action='store_true',
82 dest='plot_legend',
83 default=False,
84 help='display graph legend')
85 parser.add_argument('--labels',
86 nargs='*',
87 action='store',
88 dest='plot_labels',
89 help='override dives labels')
90 add_uddf_input(parser)
91 parser.add_argument('output',
92 help='output file: pdf, png or svg')
93
94
96 """
97 Execute dives' profiles plotting command.
98 """
99 import os.path
100 import kenozooid.plot as kp
101 import kenozooid.logbook as kl
102
103 fout = args.output
104
105 _, ext = os.path.splitext(fout)
106 ext = ext.replace('.', '')
107 if ext.lower() not in ('pdf', 'png', 'svg'):
108 raise ArgumentError('Unknown format of plotting output file: {0}' \
109 .format(ext))
110
111 r, f = args.input
112 dives = kl.find_dives(f, r, args.dives)
113
114 kp.plot(dives, fout,
115 ptype=args.plot_type,
116 format=ext,
117 title=args.plot_title,
118 info=args.plot_info,
119 temp=args.plot_temp,
120 avg_depth=args.plot_avg_depth,
121 mod=args.plot_mod,
122 sig=args.plot_sig,
123 legend=args.plot_legend,
124 labels=args.plot_labels)
125
130 """
131 Analyze dives with R script.
132 """
133 description = 'analyze dives with R script'
134
135 @classmethod
137 """
138 Add R script runner options.
139 """
140 parser.add_argument('script', help='R script to execute')
141 parser.add_argument('-a',
142 nargs='*',
143 dest='args',
144 help='R script arguments')
145 add_uddf_input(parser)
146
147
158
159
160
161