Changeset 838
- Timestamp:
- 10/16/15 11:18:48 (7 months ago)
- Location:
- mystic/mystic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/mystic/munge.py
r801 r838 69 69 return step, param, cost 70 70 71 def read_trajectories(source): 72 """read trajectories from a convergence logfile or a monitor 73 74 source can either be a monitor instance or a logfile path 75 """ 76 if isinstance(source, basestring): 77 step, param, cost = logfile_reader(source) 78 else: 79 step = enumerate(source.id) 80 if len(source) == source.id.count(None): 81 step = [(i,) for (i,j) in step] 82 else: 83 step = list(step) 84 param, cost = source.x, source.y 85 return step, param, cost 86 71 87 72 88 # read and write monitor (to and from raw data) -
mystic/mystic/scripts.py
r837 r838 17 17 18 18 from mystic.munge import read_history 19 from mystic.munge import logfile_reader, raw_to_support, read_raw_file19 from mystic.munge import raw_to_support, read_raw_file, read_trajectories 20 20 21 21 # globals … … 31 31 """ 32 32 try: # if it's a logfile, it might be multi-id 33 if isinstance(source, basestring): 34 step, param, cost = logfile_reader(source) 35 else: 36 step = enumerate(source.id) 37 if len(source) == source.id.count(None): 38 step = [(i,) for (i,j) in step] 39 else: 40 step = list(step) 41 param, cost = source.x, source.y 33 step, param, cost = read_trajectories(source) 42 34 except: # it's not a logfile, so read and return 43 35 param, cost = read_history(source) … … 841 833 # parse file contents to get (i,id), cost, and parameters 842 834 try: 843 if instance: 844 step = enumerate(instance.id) 845 if len(instance) == instance.id.count(None): 846 step = [(i,) for (i,j) in step] 847 else: 848 step = list(step) 849 param, cost = instance.x, instance.y 850 else: 851 step, param, cost = logfile_reader(filename) 835 instance = instance if instance else filename 836 step, param, cost = read_trajectories(instance) 852 837 except SyntaxError: 853 838 read_raw_file(filename) -
mystic/mystic/support.py
r810 r838 21 21 22 22 from mystic.munge import read_history 23 from mystic.munge import logfile_reader, raw_to_support23 from mystic.munge import raw_to_support, read_trajectories 24 24 from mystic.tools import factor, flatten 25 25 … … 311 311 __quit = False 312 312 313 instance = None 313 314 # handle the special case where list is provided by sys.argv 314 315 if isinstance(filename, (list,tuple)) and not kwds: … … 318 319 # 'everything else' is essentially the functional interface 319 320 else: 320 out = kwds.get('out', None) 321 iter = kwds.get('iter', None) 322 param = kwds.get('param', None) 323 label = kwds.get('label', None) 324 nid = kwds.get('nid', None) 325 cost = kwds.get('cost', False) 326 legend = kwds.get('legend', False) 327 328 # process "commandline" arguments 329 cmdargs = '' 330 cmdargs += '' if out is None else '--out={} '.format(out) 331 cmdargs += '' if iter is None else '--iter={} '.format(iter) 332 cmdargs += '' if param is None else '--param="{}" '.format(param) 333 cmdargs += '' if label is None else '--label="{}" '.format(label) 334 cmdargs += '' if nid is None else '--nid={} '.format(nid) 335 cmdargs += '' if cost == False else '--cost ' 336 cmdargs += '' if legend == False else '--legend ' 337 cmdargs = filename.split() + shlex.split(cmdargs) 321 cmdargs = kwds.get('kwds', '') 322 if not cmdargs: 323 out = kwds.get('out', None) 324 iter = kwds.get('iter', None) 325 param = kwds.get('param', None) 326 label = kwds.get('label', None) 327 nid = kwds.get('nid', None) 328 cost = kwds.get('cost', False) 329 legend = kwds.get('legend', False) 330 331 # process "commandline" arguments 332 cmdargs = '' 333 cmdargs += '' if out is None else '--out={} '.format(out) 334 cmdargs += '' if iter is None else '--iter={} '.format(iter) 335 cmdargs += '' if param is None else '--param="{}" '.format(param) 336 cmdargs += '' if label is None else '--label="{}" '.format(label) 337 cmdargs += '' if nid is None else '--nid={} '.format(nid) 338 cmdargs += '' if cost == False else '--cost ' 339 cmdargs += '' if legend == False else '--legend ' 340 else: 341 cmdargs = ' ' + cmdargs 342 if isinstance(filename, basestring): 343 cmdargs = filename.split() + shlex.split(cmdargs) 344 else: # special case of passing in monitor instance 345 instance = filename 346 cmdargs = shlex.split(cmdargs) 338 347 339 348 #XXX: note that 'argparse' is new as of python2.7 … … 382 391 383 392 # get the name of the parameter log file 384 params, cost = read_history(parsed_args[0]) 393 if instance is None: 394 instance = parsed_args[0] 395 params, cost = read_history(instance) 385 396 386 397 if parsed_opts.cost: # also plot the cost … … 548 559 __quit = False 549 560 561 instance = None 550 562 # handle the special case where list is provided by sys.argv 551 563 if isinstance(filename, (list,tuple)) and not kwds: … … 555 567 # 'everything else' is essentially the functional interface 556 568 else: 557 out = kwds.get('out', None) 558 bounds = kwds.get('bounds', None) 559 axes = kwds.get('axes', None) 560 iters = kwds.get('iters', None) 561 label = kwds.get('label', None) 562 nid = kwds.get('nid', None) 563 scale = kwds.get('scale', None) 564 flat = kwds.get('flat', False) 565 566 # process "commandline" arguments 567 cmdargs = '' 568 cmdargs += '' if out is None else '--out={} '.format(out) 569 cmdargs += '' if bounds is None else '--bounds="{}" '.format(bounds) 570 cmdargs += '' if axes is None else '--axes="{}" '.format(axes) 571 cmdargs += '' if iters is None else '--iters="{}" '.format(iters) 572 cmdargs += '' if label is None else '--label="{}" '.format(label) 573 cmdargs += '' if nid is None else '--nid={} '.format(nid) 574 cmdargs += '' if scale is None else '--scale={} '.format(scale) 575 cmdargs += '' if flat == False else '--flat ' 576 cmdargs = filename.split() + shlex.split(cmdargs) 569 cmdargs = kwds.get('kwds', '') 570 if not cmdargs: 571 out = kwds.get('out', None) 572 bounds = kwds.get('bounds', None) 573 axes = kwds.get('axes', None) 574 iters = kwds.get('iters', None) 575 label = kwds.get('label', None) 576 nid = kwds.get('nid', None) 577 scale = kwds.get('scale', None) 578 flat = kwds.get('flat', False) 579 580 # process "commandline" arguments 581 cmdargs = '' 582 cmdargs += '' if out is None else '--out={} '.format(out) 583 cmdargs += '' if bounds is None else '--bounds="{}" '.format(bounds) 584 cmdargs += '' if axes is None else '--axes="{}" '.format(axes) 585 cmdargs += '' if iters is None else '--iters="{}" '.format(iters) 586 cmdargs += '' if label is None else '--label="{}" '.format(label) 587 cmdargs += '' if nid is None else '--nid={} '.format(nid) 588 cmdargs += '' if scale is None else '--scale={} '.format(scale) 589 cmdargs += '' if flat == False else '--flat ' 590 else: 591 cmdargs = ' ' + cmdargs 592 if isinstance(filename, basestring): 593 cmdargs = filename.split() + shlex.split(cmdargs) 594 else: # special case of passing in monitor instance 595 instance = filename 596 cmdargs = shlex.split(cmdargs) 577 597 578 598 #XXX: note that 'argparse' is new as of python2.7 … … 626 646 627 647 # get the name of the parameter log file 628 params, _cost = read_history(parsed_args[0]) 648 if instance is None: 649 instance = parsed_args[0] 650 params, _cost = read_history(instance) 629 651 # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 630 652 # exec "from %s import meta" % file … … 828 850 __quit = False 829 851 852 instance = None 830 853 # handle the special case where list is provided by sys.argv 831 854 if isinstance(filename, (list,tuple)) and not kwds: … … 835 858 # 'everything else' is essentially the functional interface 836 859 else: 837 out = kwds.get('out', None) 838 bounds = kwds.get('bounds', None) 839 axes = kwds.get('axes', None) 840 weight = kwds.get('weight', None) 841 iters = kwds.get('iters', None) 842 label = kwds.get('label', None) 843 nid = kwds.get('nid', None) 844 scale = kwds.get('scale', None) 845 flat = kwds.get('flat', False) 846 847 # process "commandline" arguments 848 cmdargs = '' 849 cmdargs += '' if out is None else '--out={} '.format(out) 850 cmdargs += '' if bounds is None else '--bounds="{}" '.format(bounds) 851 cmdargs += '' if axes is None else '--axes="{}" '.format(axes) 852 cmdargs += '' if weight is None else '--weight="{}" '.format(weight) 853 cmdargs += '' if iters is None else '--iters="{}" '.format(iters) 854 cmdargs += '' if label is None else '--label="{}" '.format(label) 855 cmdargs += '' if nid is None else '--nid={} '.format(nid) 856 cmdargs += '' if scale is None else '--scale={} '.format(scale) 857 cmdargs += '' if flat == False else '--flat ' 858 cmdargs = filename.split() + shlex.split(cmdargs) 860 cmdargs = kwds.get('kwds', '') 861 if not cmdargs: 862 out = kwds.get('out', None) 863 bounds = kwds.get('bounds', None) 864 axes = kwds.get('axes', None) 865 weight = kwds.get('weight', None) 866 iters = kwds.get('iters', None) 867 label = kwds.get('label', None) 868 nid = kwds.get('nid', None) 869 scale = kwds.get('scale', None) 870 flat = kwds.get('flat', False) 871 872 # process "commandline" arguments 873 cmdargs = '' 874 cmdargs += '' if out is None else '--out={} '.format(out) 875 cmdargs += '' if bounds is None else '--bounds="{}" '.format(bounds) 876 cmdargs += '' if axes is None else '--axes="{}" '.format(axes) 877 cmdargs += '' if weight is None else '--weight="{}" '.format(weight) 878 cmdargs += '' if iters is None else '--iters="{}" '.format(iters) 879 cmdargs += '' if label is None else '--label="{}" '.format(label) 880 cmdargs += '' if nid is None else '--nid={} '.format(nid) 881 cmdargs += '' if scale is None else '--scale={} '.format(scale) 882 cmdargs += '' if flat == False else '--flat ' 883 else: 884 cmdargs = ' ' + cmdargs 885 if isinstance(filename, basestring): 886 cmdargs = filename.split() + shlex.split(cmdargs) 887 else: # special case of passing in monitor instance 888 instance = filename 889 cmdargs = shlex.split(cmdargs) 859 890 860 891 #XXX: note that 'argparse' is new as of python2.7 … … 911 942 912 943 # get the name of the parameter log file 913 params, _cost = read_history(parsed_args[0]) 944 if instance is None: 945 instance = parsed_args[0] 946 params, _cost = read_history(instance) 914 947 # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 915 948 # exec "from %s import meta" % file … … 1141 1174 __quit = False 1142 1175 1176 instance = None 1143 1177 # handle the special case where list is provided by sys.argv 1144 1178 if isinstance(filename, (list,tuple)) and not kwds: … … 1148 1182 # 'everything else' is essentially the functional interface 1149 1183 else: 1150 out = kwds.get('out', None) 1151 bounds = kwds.get('bounds', None) 1152 iters = kwds.get('iters', None) 1153 label = kwds.get('label', None) 1154 dim = kwds.get('dim', None) 1155 filter = kwds.get('filter', None) 1156 mask = kwds.get('mask', None) 1157 nid = kwds.get('nid', None) 1158 scale = kwds.get('scale', None) 1159 gap = kwds.get('gap', None) 1160 data = kwds.get('data', False) 1161 cones = kwds.get('cones', False) 1162 vertical = kwds.get('vertical', False) 1163 flat = kwds.get('flat', False) 1164 1165 # process "commandline" arguments 1166 cmdargs = '' 1167 cmdargs += '' if out is None else '--out={} '.format(out) 1168 cmdargs += '' if bounds is None else '--bounds="{}" '.format(bounds) 1169 cmdargs += '' if iters is None else '--iters="{}" '.format(iters) 1170 cmdargs += '' if label is None else '--label="{}" '.format(label) 1171 cmdargs += '' if dim is None else '--dim="{}" '.format(dim) 1172 cmdargs += '' if filter is None else '--filter="{}" '.format(filter) 1173 cmdargs += '' if mask is None else '--mask={} '.format(mask) 1174 cmdargs += '' if nid is None else '--nid={} '.format(nid) 1175 cmdargs += '' if scale is None else '--scale={} '.format(scale) 1176 cmdargs += '' if gap is None else '--gap={} '.format(gap) 1177 cmdargs += '' if data == False else '--data ' 1178 cmdargs += '' if cones == False else '--cones ' 1179 cmdargs += '' if vertical == False else '--vertical ' 1180 cmdargs += '' if flat == False else '--flat ' 1181 cmdargs = filename.split() + shlex.split(cmdargs) 1184 cmdargs = kwds.get('kwds', '') 1185 if not cmdargs: 1186 out = kwds.get('out', None) 1187 bounds = kwds.get('bounds', None) 1188 iters = kwds.get('iters', None) 1189 label = kwds.get('label', None) 1190 dim = kwds.get('dim', None) 1191 filter = kwds.get('filter', None) 1192 mask = kwds.get('mask', None) 1193 nid = kwds.get('nid', None) 1194 scale = kwds.get('scale', None) 1195 gap = kwds.get('gap', None) 1196 data = kwds.get('data', False) 1197 cones = kwds.get('cones', False) 1198 vertical = kwds.get('vertical', False) 1199 flat = kwds.get('flat', False) 1200 1201 # process "commandline" arguments 1202 cmdargs = '' 1203 cmdargs += '' if out is None else '--out={} '.format(out) 1204 cmdargs += '' if bounds is None else '--bounds="{}" '.format(bounds) 1205 cmdargs += '' if iters is None else '--iters="{}" '.format(iters) 1206 cmdargs += '' if label is None else '--label="{}" '.format(label) 1207 cmdargs += '' if dim is None else '--dim="{}" '.format(dim) 1208 cmdargs += '' if filter is None else '--filter="{}" '.format(filter) 1209 cmdargs += '' if mask is None else '--mask={} '.format(mask) 1210 cmdargs += '' if nid is None else '--nid={} '.format(nid) 1211 cmdargs += '' if scale is None else '--scale={} '.format(scale) 1212 cmdargs += '' if gap is None else '--gap={} '.format(gap) 1213 cmdargs += '' if data == False else '--data ' 1214 cmdargs += '' if cones == False else '--cones ' 1215 cmdargs += '' if vertical == False else '--vertical ' 1216 cmdargs += '' if flat == False else '--flat ' 1217 else: 1218 cmdargs = ' ' + cmdargs 1219 if isinstance(filename, basestring): 1220 cmdargs = filename.split() + shlex.split(cmdargs) 1221 else: # special case of passing in monitor instance 1222 instance = filename 1223 cmdargs = shlex.split(cmdargs) 1182 1224 1183 1225 #XXX: note that 'argparse' is new as of python2.7 … … 1246 1288 1247 1289 # get the name of the parameter log file 1248 params, _cost = read_history(parsed_args[0]) 1290 if instance is None: 1291 instance = parsed_args[0] 1292 params, _cost = read_history(instance) 1249 1293 # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 1250 1294 # exec "from %s import meta" % file
Note: See TracChangeset
for help on using the changeset viewer.