Changeset 17756


Ignore:
Timestamp:
04/17/14 10:46:47 (11 years ago)
Author:
cborstad
Message:

working on python plotmodel, added plot_contour

Location:
issm/trunk-jpl/src/m/plot
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/m/plot/applyoptions.py

    r17706 r17756  
    11import numpy as npy
    22from cmaptools import truncate_colormap
     3from plot_contour import plot_contour
    34
    45try:
     
    2324        #if not isnan(md.mesh.hemisphere):
    2425        #       options.addfielddefault('hemisphere',md.mesh.hemisphere)
     26
     27        # get handle to current figure and axes instance
     28        fig = p.gcf()
     29        ax=p.gca()
    2530
    2631        #font {{{
     
    113118
    114119        #ticklabel notation {{{
    115         p.gca().ticklabel_format(style='sci',scilimits=(0,0))
     120        #ax.ticklabel_format(style='sci',scilimits=(0,0))
    116121        #}}}
    117122
    118123        #ticklabelfontsize {{{
    119124        if options.exist('ticklabelfontsize'):
    120                 ax=p.gca()
    121125                for label in ax.get_xticklabels() + ax.get_yticklabels():
    122126                        label.set_fontsize(options.getfieldvalue('ticklabelfontsize'))
     
    131135        if options.exist('axis'):
    132136                if options.getfieldvalue('axis',True)=='off':
    133                         p.gca().ticklabel_format(style='plain')
    134                         p.setp(p.gca().get_xticklabels(), visible=False)
    135                         p.setp(p.gca().get_yticklabels(), visible=False)
     137                        ax.ticklabel_format(style='plain')
     138                        p.setp(ax.get_xticklabels(), visible=False)
     139                        p.setp(ax.get_yticklabels(), visible=False)
    136140        # }}}
    137141
     
    177181        defaultmap=truncate_colormap(mpl.cm.gnuplot2,0.1,0.9,128)
    178182        cmap=options.getfieldvalue('colormap',defaultmap)
     183        norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1])
     184        options.addfield('colornorm',norm)
     185        cbar_extend=0
     186        if options.exist('cmap_set_over'):
     187                over=options.getfieldvalue('cmap_set_over','0.5')
     188                cmap.set_over(over)
     189                cbar_extend+=1
     190        if options.exist('cmap_set_under'):
     191                under=options.getfieldvalue('cmap_set_under','0.5')
     192                cmap.set_under(under)
     193                cbar_extend+=2
     194        options.addfield('colormap',cmap)
    179195        #}}}
    180196
     
    183199        #colorbar {{{
    184200        if options.getfieldvalue('colorbar',1)==1:
    185                 fig = p.gcf()
    186                 ax = p.gca()
    187201                divider = make_axes_locatable(ax)
    188202                cax = divider.new_horizontal("5%", pad=0.05, axes_class=mpl.axes.Axes)
    189203                fig.add_axes(cax)
    190                 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1])
    191                 cbar_extend=0
    192                 if options.exist('cmap_set_over'):
    193                         over=options.getfieldvalue('cmap_set_over','0.5')
    194                         cmap.set_over(over)
    195                         cbar_extend+=1
    196                 if options.exist('cmap_set_under'):
    197                         under=options.getfieldvalue('cmap_set_under','0.5')
    198                         cmap.set_under(under)
    199                         cbar_extend+=2
    200204                if cbar_extend==0:
    201205                        extend='neither'
     
    226230        #streamlines
    227231
    228         #contours
     232        #contours {{{
     233        if options.exist('contourlevels'):
     234                plot_contour(md,data,options)
     235        #}}}
    229236
    230237        #axis positions
  • TabularUnified issm/trunk-jpl/src/m/plot/plot_manager.py

    r17654 r17756  
    3030        #initialize plot handle variable
    3131        handle=None
     32
     33        # initialize subplot
     34        p.subplot(nlines,ncols,i,aspect='equal')
    3235
    3336        ##basemap plot
     
    7073
    7174        #standard plot
    72         if not handle:
    73                 p.subplot(nlines,ncols,i,aspect='equal')
     75        #if not handle:
     76        #       p.subplot(nlines,ncols,i,aspect='equal')
    7477
    7578        #plot unit
  • TabularUnified issm/trunk-jpl/src/m/plot/plot_overlay.py

    r17657 r17756  
    5252        gtif=gdal.Open(inputname)
    5353        arr=gtif.ReadAsArray()
    54         os.system('rm -rf ./temp.tif')
     54        #os.system('rm -rf ./temp.tif')
    5555       
    5656        if gtif.RasterCount>=3:  # RGB array
     
    6262        # normalize array
    6363        arr=arr/npy.float(npy.max(arr.ravel()))
     64
     65        if options.getfieldvalue('overlayhist',0)==1:
     66                ax=plt.gca()
     67                num=2
     68                while True:
     69                        if not plt.fignum_exists(num):
     70                                break
     71                        else:
     72                                num+=1
     73                plt.figure(num)
     74                plt.hist(arr.flatten(),bins=256,range=(0.,1.))
     75                plt.title('histogram of overlay image, use for setting overlaylims')
     76                plt.sca(ax) # return to original axes/figure
     77               
    6478
    6579        # get parameters from cropped geotiff
     
    89103
    90104        norm=mpl.colors.Normalize(vmin=overlaylims[0],vmax=overlaylims[1])
     105
    91106        handle.pcolormesh(xgmap, ygmap, npy.flipud(arr), cmap=mpl.cm.Greys, norm=norm)
    92         plt.axes().set_aspect('equal','box')
     107        handle.set_aspect('equal','box')
    93108        return handle
  • TabularUnified issm/trunk-jpl/src/m/plot/plotmodel.py

    r17698 r17756  
    5656
    5757                if not hold: # TODO need to also check whether figurenumber is a new plot so that old plots are not mistakenly cleared
    58                         p.clf()
     58                        p.cla()
    5959
     60                #TODO fig, axarray = plt.subplots(nrows,ncols), then pass fix and axarr to plot_manager
    6061                #if figsize specified
    6162                if options.list[0].exist('figsize'):
Note: See TracChangeset for help on using the changeset viewer.