|
4 | 4 | interface. |
5 | 5 | """ |
6 | 6 |
|
7 | | -from collections import OrderedDict |
8 | 7 | import pathlib |
9 | 8 |
|
10 | 9 | from loam.manager import ConfOpt as Conf |
@@ -43,183 +42,144 @@ def parser(arg): |
43 | 42 | CONFIG_FILE = CONFIG_DIR / 'config.toml' |
44 | 43 | CONFIG_LOCAL = pathlib.Path('.stagpy.toml') |
45 | 44 |
|
46 | | -CONF_DEF = OrderedDict() |
47 | | - |
48 | | -CONF_DEF['common'] = OrderedDict(( |
49 | | - ('config', command_flag(None, 'print config options')), |
50 | | - ('set', tools.set_conf_opt()), |
51 | | -)) |
52 | | - |
53 | | -CONF_DEF['core'] = OrderedDict(( |
54 | | - ('path', Conf('./', True, 'p', {}, |
55 | | - True, 'path of StagYY run directory or par file', '_files')), |
56 | | - ('outname', Conf('stagpy', True, 'n', {}, |
57 | | - True, 'StagPy output file name prefix')), |
58 | | - ('shortname', switch_opt(False, None, |
59 | | - 'StagPy output file name is only prefix')), |
60 | | - ('timesteps', Conf(None, True, 't', |
61 | | - {'nargs': '?', 'const': '', 'type': _index_collection}, |
62 | | - False, 'timesteps slice')), |
63 | | - ('snapshots', Conf(None, True, 's', |
64 | | - {'nargs': '?', 'const': '', 'type': _index_collection}, |
65 | | - False, 'snapshots slice')), |
66 | | -)) |
67 | | - |
68 | | -CONF_DEF['plot'] = OrderedDict(( |
69 | | - ('ratio', Conf(None, True, None, |
70 | | - {'nargs': '?', 'const': 0.6, 'type': float}, |
71 | | - False, 'force aspect ratio of field plot')), |
72 | | - ('raster', switch_opt(True, None, 'rasterize field plots')), |
73 | | - ('format', Conf('pdf', True, None, {}, |
74 | | - True, 'figure format (pdf, eps, svg, png)')), |
75 | | - ('vmin', Conf(None, True, None, {'type': float}, |
76 | | - False, 'minimal value on plot')), |
77 | | - ('vmax', Conf(None, True, None, {'type': float}, |
78 | | - False, 'maximal value on plot')), |
79 | | - ('cminmax', switch_opt(False, 'C', 'constant min max across plots')), |
80 | | - ('isolines', Conf(None, True, None, {'type': _float_list}, |
81 | | - False, 'arbitrary isoline value, comma separated')), |
82 | | - ('mplstyle', Conf('stagpy-paper', True, None, |
83 | | - {'nargs': '?', 'const': '', 'type': str}, |
84 | | - True, 'matplotlib style')), |
85 | | - ('xkcd', Conf(False, False, None, {}, |
86 | | - True, 'use the xkcd style')), |
87 | | -)) |
88 | | - |
89 | | -CONF_DEF['scaling'] = OrderedDict(( |
90 | | - ('yearins', Conf(3.154e7, False, None, {}, |
91 | | - True, 'year in seconds')), |
92 | | - ('ttransit', Conf(1.78e15, False, None, {}, |
93 | | - True, 'transit time in My')), |
94 | | - ('dimensional', switch_opt(False, None, 'use dimensional units')), |
95 | | - ('time_in_y', switch_opt(True, None, 'dimensionful time is in year')), |
96 | | - ('vel_in_cmpy', switch_opt(True, None, |
97 | | - 'dimensionful velocity is in cm/year')), |
98 | | - ('factors', Conf({'s': 'M', |
99 | | - 'm': 'k', |
100 | | - 'Pa': 'G'}, |
101 | | - False, None, {}, True, 'custom factors')), |
102 | | -)) |
103 | | - |
104 | | -CONF_DEF['field'] = OrderedDict(( |
105 | | - ('plot', |
106 | | - Conf('T,stream', True, 'o', |
107 | | - {'nargs': '?', 'const': '', 'type': str}, |
108 | | - True, 'variables to plot (see stagpy var)')), |
109 | | - ('perturbation', switch_opt(False, None, |
110 | | - 'plot departure from average profile')), |
111 | | - ('shift', Conf(None, True, None, {'type': int}, |
112 | | - False, 'shift plot horizontally')), |
113 | | - ('timelabel', switch_opt(False, None, 'add label with time')), |
114 | | - ('interpolate', switch_opt(False, None, 'apply Gouraud shading')), |
115 | | - ('colorbar', switch_opt(True, None, 'add color bar to plot')), |
116 | | - ('ix', Conf(None, True, None, {'type': int}, |
117 | | - False, 'x-index of slice for 3D fields')), |
118 | | - ('iy', Conf(None, True, None, {'type': int}, |
119 | | - False, 'y-index of slice for 3D fields')), |
120 | | - ('iz', Conf(None, True, None, {'type': int}, |
121 | | - False, 'z-index of slice for 3D fields')), |
122 | | - ('isocolors', Conf('', True, None, {}, True, |
123 | | - 'comma-separated list of colors for isolines')), |
124 | | - ('cmap', |
125 | | - Conf({'T': 'RdBu_r', |
126 | | - 'eta': 'viridis_r', |
127 | | - 'rho': 'RdBu', |
128 | | - 'sII': 'plasma_r', |
129 | | - 'edot': 'Reds'}, |
130 | | - False, None, {}, True, 'custom colormaps')), |
131 | | -)) |
132 | | - |
133 | | -CONF_DEF['rprof'] = OrderedDict(( |
134 | | - ('plot', |
135 | | - Conf('Tmean', True, 'o', |
136 | | - {'nargs': '?', 'const': ''}, |
137 | | - True, 'variables to plot (see stagpy var)')), |
138 | | - ('style', |
139 | | - Conf('-', True, None, {}, |
140 | | - True, 'matplotlib line style')), |
141 | | - ('average', switch_opt(False, 'a', 'plot temporal average')), |
142 | | - ('grid', switch_opt(False, 'g', 'plot grid')), |
143 | | - ('depth', switch_opt(False, 'd', 'depth as vertical axis')), |
144 | | -)) |
145 | | - |
146 | | -CONF_DEF['time'] = OrderedDict(( |
147 | | - ('plot', |
148 | | - Conf('Nutop,ebalance,Nubot.Tmean', True, 'o', |
149 | | - {'nargs': '?', 'const': ''}, |
150 | | - True, 'variables to plot (see stagpy var)')), |
151 | | - ('style', |
152 | | - Conf('-', True, None, {}, |
153 | | - True, 'matplotlib line style')), |
154 | | - ('compstat', |
155 | | - Conf('', True, None, {'nargs': '?', 'const': ''}, |
156 | | - False, 'compute mean and rms of listed variables')), |
157 | | - ('tstart', |
158 | | - Conf(None, True, None, {'type': float}, |
159 | | - False, 'beginning time')), |
160 | | - ('tend', |
161 | | - Conf(None, True, None, {'type': float}, |
162 | | - False, 'end time')), |
163 | | - ('fraction', |
164 | | - Conf(None, True, None, {'type': float}, |
165 | | - False, 'ending fraction of series to process')), |
166 | | - ('marktimes', |
167 | | - Conf('', True, 'M', {'type': _float_list}, |
168 | | - False, 'list of times where to put a mark')), |
169 | | - ('marksteps', |
170 | | - Conf('', True, 'T', {'type': _index_collection}, |
171 | | - False, 'list of steps where to put a mark')), |
172 | | - ('marksnaps', |
173 | | - Conf('', True, 'S', {'type': _index_collection}, |
174 | | - False, 'list of snaps where to put a mark')), |
175 | | -)) |
176 | | - |
177 | | -CONF_DEF['refstate'] = OrderedDict(( |
178 | | - ('plot', |
179 | | - Conf('T', True, 'o', |
180 | | - {'nargs': '?', 'const': ''}, |
181 | | - True, 'variables to plot (see stagpy var)')), |
182 | | - ('style', |
183 | | - Conf('-', True, None, {}, |
184 | | - True, 'matplotlib line style')), |
185 | | -)) |
186 | | - |
187 | | -CONF_DEF['plates'] = OrderedDict(( |
188 | | - ('plot', |
189 | | - Conf('c.T.v2-v2.dv2-v2.topo_top', True, 'o', |
190 | | - {'nargs': '?', 'const': ''}, True, |
191 | | - 'variables to plot, can be a surface field, field, or dv2')), |
192 | | - ('field', |
193 | | - Conf('eta', True, None, {}, |
194 | | - True, 'field variable to plot with plates info')), |
195 | | - ('stress', switch_opt( |
| 45 | +CONF_DEF = {} |
| 46 | + |
| 47 | +CONF_DEF['common'] = dict( |
| 48 | + config=command_flag(None, 'print config options'), |
| 49 | + set=tools.set_conf_opt(), |
| 50 | +) |
| 51 | + |
| 52 | +CONF_DEF['core'] = dict( |
| 53 | + path=Conf('./', True, 'p', {}, |
| 54 | + True, 'path of StagYY run directory or par file', '_files'), |
| 55 | + outname=Conf('stagpy', True, 'n', {}, True, 'output file name prefix'), |
| 56 | + shortname=switch_opt(False, None, 'output file name is only prefix'), |
| 57 | + timesteps=Conf(None, True, 't', |
| 58 | + {'nargs': '?', 'const': '', 'type': _index_collection}, |
| 59 | + False, 'timesteps slice'), |
| 60 | + snapshots=Conf(None, True, 's', |
| 61 | + {'nargs': '?', 'const': '', 'type': _index_collection}, |
| 62 | + False, 'snapshots slice'), |
| 63 | +) |
| 64 | + |
| 65 | +CONF_DEF['plot'] = dict( |
| 66 | + ratio=Conf(None, True, None, {'nargs': '?', 'const': 0.6, 'type': float}, |
| 67 | + False, 'force aspect ratio of field plot'), |
| 68 | + raster=switch_opt(True, None, 'rasterize field plots'), |
| 69 | + format=Conf('pdf', True, None, {}, |
| 70 | + True, 'figure format (pdf, eps, svg, png)'), |
| 71 | + vmin=Conf(None, True, None, {'type': float}, |
| 72 | + False, 'minimal value on plot'), |
| 73 | + vmax=Conf(None, True, None, {'type': float}, |
| 74 | + False, 'maximal value on plot'), |
| 75 | + cminmax=switch_opt(False, 'C', 'constant min max across plots'), |
| 76 | + isolines=Conf(None, True, None, {'type': _float_list}, |
| 77 | + False, 'arbitrary isoline value, comma separated'), |
| 78 | + mplstyle=Conf('stagpy-paper', True, None, |
| 79 | + {'nargs': '?', 'const': '', 'type': str}, |
| 80 | + True, 'matplotlib style'), |
| 81 | + xkcd=Conf(False, False, None, {}, True, 'use the xkcd style'), |
| 82 | +) |
| 83 | + |
| 84 | +CONF_DEF['scaling'] = dict( |
| 85 | + yearins=Conf(3.154e7, False, None, {}, True, 'year in seconds'), |
| 86 | + ttransit=Conf(1.78e15, False, None, {}, True, 'transit time in My'), |
| 87 | + dimensional=switch_opt(False, None, 'use dimensional units'), |
| 88 | + time_in_y=switch_opt(True, None, 'dimensional time is in year'), |
| 89 | + vel_in_cmpy=switch_opt(True, None, 'dimensional velocity is in cm/year'), |
| 90 | + factors=Conf({'s': 'M', 'm': 'k', 'Pa': 'G'}, |
| 91 | + False, None, {}, True, 'custom factors'), |
| 92 | +) |
| 93 | + |
| 94 | +CONF_DEF['field'] = dict( |
| 95 | + plot=Conf('T,stream', True, 'o', {'nargs': '?', 'const': '', 'type': str}, |
| 96 | + True, 'variables to plot (see stagpy var)'), |
| 97 | + perturbation=switch_opt(False, None, |
| 98 | + 'plot departure from average profile'), |
| 99 | + shift=Conf(None, True, None, {'type': int}, |
| 100 | + False, 'shift plot horizontally'), |
| 101 | + timelabel=switch_opt(False, None, 'add label with time'), |
| 102 | + interpolate=switch_opt(False, None, 'apply Gouraud shading'), |
| 103 | + colorbar=switch_opt(True, None, 'add color bar to plot'), |
| 104 | + ix=Conf(None, True, None, {'type': int}, |
| 105 | + False, 'x-index of slice for 3D fields'), |
| 106 | + iy=Conf(None, True, None, {'type': int}, |
| 107 | + False, 'y-index of slice for 3D fields'), |
| 108 | + iz=Conf(None, True, None, {'type': int}, |
| 109 | + False, 'z-index of slice for 3D fields'), |
| 110 | + isocolors=Conf('', True, None, {}, True, |
| 111 | + 'comma-separated list of colors for isolines'), |
| 112 | + cmap=Conf({'T': 'RdBu_r', |
| 113 | + 'eta': 'viridis_r', |
| 114 | + 'rho': 'RdBu', |
| 115 | + 'sII': 'plasma_r', |
| 116 | + 'edot': 'Reds'}, |
| 117 | + False, None, {}, True, 'custom colormaps'), |
| 118 | +) |
| 119 | + |
| 120 | +CONF_DEF['rprof'] = dict( |
| 121 | + plot=Conf('Tmean', True, 'o', {'nargs': '?', 'const': ''}, |
| 122 | + True, 'variables to plot (see stagpy var)'), |
| 123 | + style=Conf('-', True, None, {}, True, 'matplotlib line style'), |
| 124 | + average=switch_opt(False, 'a', 'plot temporal average'), |
| 125 | + grid=switch_opt(False, 'g', 'plot grid'), |
| 126 | + depth=switch_opt(False, 'd', 'depth as vertical axis'), |
| 127 | +) |
| 128 | + |
| 129 | +CONF_DEF['time'] = dict( |
| 130 | + plot=Conf('Nutop,ebalance,Nubot.Tmean', True, 'o', |
| 131 | + {'nargs': '?', 'const': ''}, |
| 132 | + True, 'variables to plot (see stagpy var)'), |
| 133 | + style=Conf('-', True, None, {}, True, 'matplotlib line style'), |
| 134 | + compstat=Conf('', True, None, {'nargs': '?', 'const': ''}, |
| 135 | + False, 'compute mean and rms of listed variables'), |
| 136 | + tstart=Conf(None, True, None, {'type': float}, False, 'beginning time'), |
| 137 | + tend=Conf(None, True, None, {'type': float}, False, 'end time'), |
| 138 | + fraction=Conf(None, True, None, {'type': float}, |
| 139 | + False, 'ending fraction of series to process'), |
| 140 | + marktimes=Conf('', True, 'M', {'type': _float_list}, |
| 141 | + False, 'list of times where to put a mark'), |
| 142 | + marksteps=Conf('', True, 'T', {'type': _index_collection}, |
| 143 | + False, 'list of steps where to put a mark'), |
| 144 | + marksnaps=Conf('', True, 'S', {'type': _index_collection}, |
| 145 | + False, 'list of snaps where to put a mark'), |
| 146 | +) |
| 147 | + |
| 148 | +CONF_DEF['refstate'] = dict( |
| 149 | + plot=Conf('T', True, 'o', {'nargs': '?', 'const': ''}, |
| 150 | + True, 'variables to plot (see stagpy var)'), |
| 151 | + style=Conf('-', True, None, {}, True, 'matplotlib line style'), |
| 152 | +) |
| 153 | + |
| 154 | +CONF_DEF['plates'] = dict( |
| 155 | + plot=Conf('c.T.v2-v2.dv2-v2.topo_top', True, 'o', |
| 156 | + {'nargs': '?', 'const': ''}, True, |
| 157 | + 'variables to plot, can be a surface field, field, or dv2'), |
| 158 | + field=Conf('eta', True, None, {}, |
| 159 | + True, 'field variable to plot with plates info'), |
| 160 | + stress=switch_opt( |
196 | 161 | False, None, |
197 | | - 'Plot deviatoric stress instead of velocity on field plots')), |
198 | | - ('continents', switch_opt(True, None, |
199 | | - 'Whether to shade continents on plots')), |
200 | | - ('vzratio', |
201 | | - Conf(0., True, None, {}, True, |
202 | | - 'Ratio of mean vzabs used as threshold for plates limits')), |
203 | | - ('nbplates', switch_opt(False, None, |
204 | | - 'Plot number of plates as function of time')), |
205 | | - ('distribution', switch_opt(False, None, |
206 | | - 'Plot plate size distribution')), |
207 | | - ('zoom', |
208 | | - Conf(None, True, None, {'type': float}, |
209 | | - False, 'zoom around surface')), |
210 | | -)) |
211 | | - |
212 | | -CONF_DEF['info'] = OrderedDict(( |
213 | | - ('output', Conf('t,Tmean,vrms,Nutop,Nubot', True, 'o', {}, |
214 | | - True, 'time series to print')), |
215 | | -)) |
216 | | - |
217 | | -CONF_DEF['var'] = OrderedDict(( |
218 | | - ('field', command_flag(None, 'print field variables')), |
219 | | - ('sfield', command_flag(None, 'print surface field variables')), |
220 | | - ('rprof', command_flag(None, 'print rprof variables')), |
221 | | - ('time', command_flag(None, 'print time variables')), |
222 | | - ('refstate', command_flag(None, 'print refstate variables')), |
223 | | -)) |
| 162 | + 'Plot deviatoric stress instead of velocity on field plots'), |
| 163 | + continents=switch_opt(True, None, 'Whether to shade continents on plots'), |
| 164 | + vzratio=Conf(0., True, None, {}, True, |
| 165 | + 'Ratio of mean vzabs used as threshold for plates limits'), |
| 166 | + nbplates=switch_opt(False, None, |
| 167 | + 'Plot number of plates as function of time'), |
| 168 | + distribution=switch_opt(False, None, 'Plot plate size distribution'), |
| 169 | + zoom=Conf(None, True, None, {'type': float}, False, 'zoom around surface'), |
| 170 | +) |
| 171 | + |
| 172 | +CONF_DEF['info'] = dict( |
| 173 | + output=Conf('t,Tmean,vrms,Nutop,Nubot', True, 'o', {}, |
| 174 | + True, 'time series to print'), |
| 175 | +) |
| 176 | + |
| 177 | +CONF_DEF['var'] = dict( |
| 178 | + field=command_flag(None, 'print field variables'), |
| 179 | + sfield=command_flag(None, 'print surface field variables'), |
| 180 | + rprof=command_flag(None, 'print rprof variables'), |
| 181 | + time=command_flag(None, 'print time variables'), |
| 182 | + refstate=command_flag(None, 'print refstate variables'), |
| 183 | +) |
224 | 184 |
|
225 | 185 | CONF_DEF['config'] = tools.config_conf_section() |
0 commit comments