Changeset 476 for mystic/scripts


Ignore:
Timestamp:
08/29/11 14:54:25 (5 years ago)
Author:
mmckerns
Message:

standardized plotters; plotters now can read standard logfile;
split up functions in 'munge' so more useful

Location:
mystic/scripts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mystic/scripts/mystic_log_reader.py

    r475 r476  
    1919parser.add_option("-i","--iter",action="store",dest="stop",metavar="INT",\ 
    2020                  default=None,help="the largest iteration to plot") 
     21parser.add_option("-g","--legend",action="store_true",dest="legend",\ 
     22                  default=False,help="show the legend") 
    2123#parser.add_option("-f","--file",action="store",dest="filename",metavar="FILE",\ 
    2224#                  default='log.txt',help="log file name") 
     
    4345  stop = None 
    4446 
    45 f = open(filename,"r") 
    46 file = f.read() 
    47 f.close() 
    48  
    49 contents = file.split("\n") 
    50  
    5147# == Possible results == 
    5248# iter = (i,id) or (i,)  
     
    6864 
    6965# parse file contents to get (i,id), cost, and parameters 
    70 step = []; cost = []; param = []; 
    71 for line in contents[:-1]: 
    72   if line.startswith("#"): pass 
    73   else: 
    74     values = line.split("   ") 
    75     step.append(eval(values[0]))  #XXX: yields (i,id) 
    76     cost.append(eval(values[1])) 
    77     param.append(eval(values[2])) 
     66from mystic.munge import logfile_reader 
     67step, param, cost = logfile_reader(filename) 
    7868 
    7969# ignore everything after 'stop' 
     
    125115    tag = "%d,%d" % (i,j) 
    126116    ax1.plot(iter_conv[i],conv[i][j],label="%s" % tag,marker=mark,linestyle=style) 
    127 plt.legend() 
     117if parsed_opts.legend: plt.legend() 
    128118 
    129119ax2 = fig.add_subplot(2,1,2) 
     
    131121  tag = "%d" % i 
    132122  ax2.plot(iter_conv[i],cost_conv[i],label='cost %s' % tag,marker=mark,linestyle=style) 
    133 plt.legend() 
     123if parsed_opts.legend: plt.legend() 
    134124 
    135125plt.show() 
  • mystic/scripts/support_convergence.py

    r475 r476  
    6161  parser.add_option("-c","--cost",action="store_true",dest="cost",\ 
    6262                    default=False,help="also plot the parameter cost") 
    63   parser.add_option("-l","--legend",action="store_true",dest="legend",\ 
     63  parser.add_option("-g","--legend",action="store_true",dest="legend",\ 
    6464                    default=False,help="show the legend") 
    6565  parsed_opts, parsed_args = parser.parse_args() 
     
    7171  except: 
    7272    raise IOError, "please provide log file name" 
    73    #file = 'paramlog' 
    74   exec "from %s import params" % file 
     73  try:  # read standard logfile 
     74    from mystic.munge import logfile_reader, raw_to_support 
     75    _step, params, cost = logfile_reader(file) 
     76    params, cost = raw_to_support(params, cost) 
     77  except:  
     78    exec "from %s import params" % file 
     79    exec "from %s import cost" % file 
    7580 
    7681  if parsed_opts.cost: # also plot the cost 
    77     exec "from %s import cost" % file 
     82   #exec "from %s import cost" % file 
     83    pass 
    7884  else: 
    7985    cost = None 
  • mystic/scripts/support_hypercube.py

    r475 r476  
    5252  except: 
    5353    raise IOError, "please provide log file name" 
    54    #file = 'paramlog' 
    55   exec "from %s import params" % file 
    56   #exec "from %s import meta" % file 
    57   # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 
     54  try:  # read standard logfile 
     55    from mystic.munge import logfile_reader, raw_to_support 
     56    _step, params, _cost = logfile_reader(file) 
     57    params, _cost = raw_to_support(params, _cost) 
     58  except:  
     59    exec "from %s import params" % file 
     60    #exec "from %s import meta" % file 
     61    # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 
    5862 
    5963  try: # select the bounds 
  • mystic/scripts/support_hypercube_measures.py

    r475 r476  
    5858  except: 
    5959    raise IOError, "please provide log file name" 
    60    #file = 'paramlog' 
    61   exec "from %s import params" % file 
    62   #exec "from %s import meta" % file 
    63   # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 
     60  try:  # read standard logfile 
     61    from mystic.munge import logfile_reader, raw_to_support 
     62    _step, params, _cost = logfile_reader(file) 
     63    params, _cost = raw_to_support(params, _cost) 
     64  except:  
     65    exec "from %s import params" % file 
     66    #exec "from %s import meta" % file 
     67    # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 
    6468 
    6569  try: # select the bounds 
Note: See TracChangeset for help on using the changeset viewer.