Changeset 846


Ignore:
Timestamp:
11/25/15 13:41:25 (6 months ago)
Author:
mmckerns
Message:

edit scripts and support for faster import of mystic (local imports of mpl)

Location:
mystic/mystic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mystic/mystic/scripts.py

    r841 r846  
    1212__all__ = ['model_plotter','log_reader'] 
    1313 
    14 from mpl_toolkits.mplot3d import axes3d 
    15 import matplotlib.pyplot as plt 
    16 from matplotlib import cm 
    17  
    18 from mystic.munge import read_history 
    19 from mystic.munge import raw_to_support, read_raw_file, read_trajectories 
    20  
    2114# globals 
    2215__quit = False 
     
    3124    """ 
    3225    try: # if it's a logfile, it might be multi-id 
     26        from mystic.munge import read_trajectories 
    3327        step, param, cost = read_trajectories(source) 
    3428    except: # it's not a logfile, so read and return 
     29        from mystic.munge import read_history 
    3530        param, cost = read_history(source) 
    3631        return [param],[cost] 
     
    5247 
    5348    # convert to support format 
     49    from mystic.munge import raw_to_support 
    5450    for i in range(len(params)): 
    5551        params[i], costs[i] = raw_to_support(params[i], costs[i]) 
     
    157153if figure is provided, plot to an existing figure 
    158154    """ 
     155    import matplotlib.pyplot as plt 
    159156    if not figure: figure = plt.figure() 
    160157    ax = figure.gca() 
     
    188185if figure is provided, plot to an existing figure 
    189186    """ 
     187    import matplotlib.pyplot as plt 
     188    from mpl_toolkits.mplot3d import axes3d 
    190189    if not figure: figure = plt.figure() 
    191190 
     
    242241    #XXX: need to 'correct' the z-axis (or provide easy conversion) 
    243242 
     243    import matplotlib.pyplot as plt 
    244244    fig = plt.figure() 
    245245    ax = fig.gca() 
     
    263263    """ 
    264264    import numpy 
     265    from matplotlib import cm 
    265266 
    266267    if y is None: 
     
    280281    #XXX: need to 'correct' the z-axis (or provide easy conversion) 
    281282 
     283    import matplotlib.pyplot as plt 
     284    from mpl_toolkits.mplot3d import axes3d 
    282285    fig = plt.figure() 
    283286    if surface and fill is None: # 'hidden' option; full 3D surface plot 
     
    665668            fig = _draw_trajectory(_x,_y,_c, style=style, scale=scale, shift=shift, figure=fig) 
    666669 
     670    import matplotlib.pyplot as plt 
     671    from mpl_toolkits.mplot3d import axes3d 
    667672    # add labels to the axes 
    668673    if surface: kwds = {'projection':'3d'} # 3D 
     
    844849    try: 
    845850        instance = instance if instance else filename 
     851        from mystic.munge import read_trajectories 
    846852        step, param, cost = read_trajectories(instance) 
    847853    except SyntaxError: 
     854        from mystic.munge import read_raw_file 
    848855        read_raw_file(filename) 
    849856        msg = "incompatible file format, try 'support_convergence.py'" 
     
    896903    #print "conv = %s" % conv 
    897904 
     905    import matplotlib.pyplot as plt 
    898906    fig = plt.figure() 
    899907 
  • mystic/mystic/support.py

    r838 r846  
    1212           'hypercube_scenario', 'best_dimensions', 'swap'] 
    1313 
    14 from mpl_toolkits.mplot3d import Axes3D as _Axes3D 
    15 from matplotlib.axes import subplot_class_factory 
    16 Subplot3D = subplot_class_factory(_Axes3D) 
    17  
    18 from mpl_toolkits.mplot3d import axes3d 
    19 import matplotlib.pyplot as plt 
    20 from matplotlib import cm 
    21  
    22 from mystic.munge import read_history 
    23 from mystic.munge import raw_to_support, read_trajectories 
    24 from mystic.tools import factor, flatten 
     14# from mpl_toolkits.mplot3d import axes3d 
    2515 
    2616# globals 
     
    3121def best_dimensions(n): 
    3222  "get the 'best' dimensions (n x m) for arranging plots" 
     23  from mystic.tools import factor 
    3324  allfactors = list(factor(n)) 
    3425  from numpy import product 
     
    393384    if instance is None: 
    394385        instance = parsed_args[0] 
     386    from mystic.munge import read_history 
    395387    params, cost = read_history(instance) 
    396388 
     
    455447    dim1,dim2 = best_dimensions(plots + j) 
    456448 
     449    import matplotlib.pyplot as plt 
    457450    fig = plt.figure() 
    458451    ax1 = fig.add_subplot(dim1,dim2,1) 
     
    648641    if instance is None: 
    649642        instance = parsed_args[0] 
     643    from mystic.munge import read_history 
    650644    params, _cost = read_history(instance) 
    651645    # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 
     
    737731 
    738732    # correctly bound the first plot.  there must be at least one plot 
     733    import matplotlib.pyplot as plt 
     734    from mpl_toolkits.mplot3d import Axes3D as _Axes3D 
     735    from matplotlib.axes import subplot_class_factory 
     736    Subplot3D = subplot_class_factory(_Axes3D) 
    739737    fig = plt.figure() 
    740738    ax1 = Subplot3D(fig, dim1,dim2,1) 
     
    787785    #steps = [[0,1],[1,2],[2,3],[3,4,5,6,7,8]] or similar 
    788786    if flatten: 
     787        from mystic.tools import flatten 
    789788        steps = [list(flatten(steps))] 
    790789 
     
    944943    if instance is None: 
    945944        instance = parsed_args[0] 
     945    from mystic.munge import read_history 
    946946    params, _cost = read_history(instance) 
    947947    # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 
     
    10431043 
    10441044    # correctly bound the first plot.  there must be at least one plot 
     1045    import matplotlib.pyplot as plt 
     1046    from mpl_toolkits.mplot3d import Axes3D as _Axes3D 
     1047    from matplotlib.axes import subplot_class_factory 
     1048    Subplot3D = subplot_class_factory(_Axes3D) 
    10451049    fig = plt.figure() 
    10461050    ax1 = Subplot3D(fig, dim1,dim2,1) 
     
    10951099    #steps = [[0],[1],[3],[8]] or similar 
    10961100    if flatten: 
     1101        from mystic.tools import flatten 
    10971102        steps = [list(flatten(steps))] 
    10981103 
     
    12901295    if instance is None: 
    12911296        instance = parsed_args[0] 
     1297    from mystic.munge import read_history 
    12921298    params, _cost = read_history(instance) 
    12931299    # would be nice to use meta = ['wx','wx2','x','x2','wy',...] 
     
    14691475 
    14701476    # correctly bound the first plot.  there must be at least one plot 
     1477    import matplotlib.pyplot as plt 
     1478    from mpl_toolkits.mplot3d import Axes3D as _Axes3D 
     1479    from matplotlib.axes import subplot_class_factory 
     1480    Subplot3D = subplot_class_factory(_Axes3D) 
    14711481    fig = plt.figure()  
    14721482    if _2D: 
Note: See TracChangeset for help on using the changeset viewer.