Changeset 21276


Ignore:
Timestamp:
10/15/16 14:33:24 (8 years ago)
Author:
cborstad
Message:

CHG: push options parsing to the expdisp function to facilitate adding new options (patch fill to come), and to streamline applyoptions

Location:
issm/trunk-jpl/src/m
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/exp/expdisp.py

    r21254 r21276  
    22import numpy as np
    33
    4 def expdisp(domainoutline,ax,linestyle='--k',linewidth=1,unitmultiplier=1.):
     4def expdisp(ax,options):
    55    '''
    66    plot the contents of a domain outline file
    77
    8     This routine reads in a domain outline file and plots all of the x,y contours
     8    This routine reads in an exp file and plots all of the x,y points/lines/patches
    99
    10     'ax' is a handle to the current plot axes, onto which the contours are to be drawn
     10    'ax' is a handle to the current plot axes, onto which we want to plot
    1111
    1212    Usage:
     
    1717    '''
    1818
    19     domain=expread(domainoutline)
     19    filename=options.getfieldvalue('expdisp')
     20    style=options.getfieldvalue('expstyle','k')
     21    linewidth=options.getfieldvalue('explinewidth',1)
     22    unitmultiplier=options.getfieldvalue('unit',1)
     23    for i in xrange(len(filename)):
     24        filenamei=filename[i]
     25        stylei=style[i]
     26        if type(linewidth)==list:
     27            linewidthi=linewidth[i]
     28        else:
     29            linewidthi=linewidth
    2030
    21     for i in xrange(len(domain)):
    22         if domain[i]['nods']==1:
    23             ax.plot(domain[i]['x']*unitmultiplier,domain[i]['y']*unitmultiplier,'o',mec='k',mfc='r',ms=10)
    24         else:
    25             x=domain[i]['x'].tolist() # since expread returns a string representation of the arrays
    26             y=domain[i]['y'].tolist()
    27             ax.plot(x*unitmultiplier,y*unitmultiplier,linestyle,linewidth=linewidth)
     31        domain=expread(filenamei)
     32        for i in xrange(len(domain)):
     33            if domain[i]['nods']==1:
     34                ax.plot(domain[i]['x']*unitmultiplier,domain[i]['y']*unitmultiplier,'o',mec='k',mfc='r',ms=10)
     35            else:
     36                x=domain[i]['x'].tolist() # since expread returns a string representation of the arrays
     37                y=domain[i]['y'].tolist()
     38                ax.plot(x*unitmultiplier,y*unitmultiplier,stylei,linewidth=linewidthi)
  • issm/trunk-jpl/src/m/plot/applyoptions.py

    r21254 r21276  
    248248        # {{{ expdisp
    249249        if options.exist('expdisp'):
    250                 filename=options.getfieldvalue('expdisp')
    251                 style=options.getfieldvalue('expstyle','k')
    252                 linewidth=options.getfieldvalue('explinewidth',1)
    253                 for i in xrange(len(filename)):
    254                         filenamei=filename[i]
    255                         stylei=style[i]
    256                         if type(linewidth)==list:
    257                                 linewidthi=linewidth[i]
    258                         else:
    259                                 linewidthi=linewidth
    260                         expdisp(filenamei,ax,linestyle=stylei,linewidth=linewidthi,unitmultiplier=options.getfieldvalue('unit',1))
     250            expdisp(ax,options)
    261251        # }}}
    262252        # {{{ area TODO
Note: See TracChangeset for help on using the changeset viewer.