Changeset 14260


Ignore:
Timestamp:
01/16/13 18:36:29 (12 years ago)
Author:
cborstad
Message:

NEW: python version of checkplotoptions, fixed nlines in subplot call

Location:
issm/trunk-jpl/src/m/plot
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/plot/checkplotoptions.m

    r13730 r14260  
    8181        end
    8282        textweightvalues=repmat(textweightvalues,1,numtext); textweightvalues(numtext+1:end)=[];
     83
    8384        %3: textsize
    8485        if exist(options,'textsize'),
     
    107108        end
    108109        textcolorvalues=repmat(textcolorvalues,1,numtext); textcolorvalues(numtext+1:end)=[];
    109         %4: textposition
     110        %5: textposition
    110111        if exist(options,'textposition'),
    111112                textpositionvalues=getfieldvalue(options,'textposition');
     
    191192        if strcmpi(getfieldvalue(options,'scaleruler'),'on')
    192193                %default values
    193                 Lx=max(md.mesh.y)-min(md.mesh.y);
     194                Lx=max(md.mesh.x)-min(md.mesh.x);
    194195                Ly=max(md.mesh.y)-min(md.mesh.y);
    195196                %default values
  • issm/trunk-jpl/src/m/plot/checkplotoptions.py

    r13411 r14260  
     1import numpy as npy
     2
    13def checkplotoptions(md,options):
    24        '''
     
    1113        '''
    1214
    13         print "WARNING: checkplotoptions not implemented: options returned as passed"
     15
     16        #units
     17        if options.exist('unit'):
     18                if 'km' in options.getfieldvalue('unit','km'):
     19                        options.changefieldvalue('unit',10**-3)
     20                if '100km' in options.getfieldvalue('unit','100km'):
     21                        options.changefieldvalue('unit',10**-5)
     22       
     23        #density
     24        if options.exist('density'):
     25                density=options.getfieldvalue('density')
     26                options.changefieldvalue('density',abs(ceil(density)))
     27       
     28        #show section
     29        if options.exist('showsection'):
     30                if 'on' in options.getfieldvalue('showsection','on'):
     31                        options.changefieldvalue('showsection',4)
     32       
     33        #smooth values
     34        if options.exist('smooth'):
     35                if 'on' in options.getfieldvalue('smooth','on'):
     36                        options.changefieldvalue('smooth',0)
     37
     38        #contouronly values
     39        if options.exist('contouronly'):
     40                if 'on' in options.getfieldvalue('contouronly','on'):
     41                        options.changefieldvalue('contouronly',1)
     42
     43        #colorbar
     44        if options.exist('colorbar'):
     45                if 'on' in options.getfieldvalue('colorbar','on'):
     46                        options.changefieldvalue('colorbar',1)
     47                elif 'off' in options.getfieldvalue('colorbar','off'):
     48                        options.changefieldvalue('colorbar',0)
     49
     50        #text
     51        if options.exist('text'):
     52                #1: textvalue
     53                textvalues=options.getfieldvalue('text')
     54                numtext=len(textvalues)
     55
     56                #2: textweight
     57                if options.exist('textweight'):
     58                        textweightvalues=options.getfieldvalue('textweight')
     59                else:
     60                        textweightvalues='n'
     61                textweightvalues=npy.tile(textweightvalues,numtext)
     62
     63                #3 textsize
     64                if options.exist('textsize'):
     65                        textsizevalues=options.getfieldvalue('textsize')
     66                else:
     67                        textsizevalues=14
     68                textsizevalues=npy.tile(textsizevalues,numtext)
     69
     70                #4 textcolor
     71                if options.exist('textcolor'):
     72                        textcolorvalues=options.getfieldvalue('textcolor')
     73                else:
     74                        textcolorvalues='k'
     75                textcolorvalues=npy.tile(textsizevalues,numtext)
     76
     77                #5 textposition
     78                if options.exist('textposition'):
     79                        options.getfieldvalue('textposition')
     80                else:
     81                        raise Exception("plotmodel error message: 'textposition' option is missing")
     82
     83                #6 textrotation
     84                if options.exist('textrotation'):
     85                        textrotationvalues=options.getfieldvalue('textrotation')
     86                else:
     87                        textrotationvalues=0
     88                textrotationvalues=npy.tile(textrotationvalues,numtext)
     89
     90                options.changfieldvalue('text',textvalues)
     91                options.changfieldvalue('textsize',textsizevalues)
     92                options.changfieldvalue('textweight',textweightvalues)
     93                options.changfieldvalue('textcolor',textcolorvalues)
     94                options.changfieldvalue('textposition',textpositionvalues)
     95                options.changfieldvalue('textrotation',textrotationvalues)
     96
     97        #expdisp
     98        expdispvaluesarray=[0,0]
     99        expstylevaluesarray=[0,0]
     100        expstylevalues=[0,0]
     101        if options.exist('expstyle'):
     102                expstylevalues=options.getfieldvalue('expstyle')
     103        if options.exist('expdisp'):
     104                expdispvalues=options.getfieldvalue('expdisp')
     105                for i in npy.arange(len(expdispvalues)):
     106                        expdispvaluesarray.append(expdispvalues[i])
     107                        if len(expstylevalues)>i+1:
     108                                expstylevaluesarray.append(expstylevalues[i])
     109                        else:
     110                                expstylevaluesarray.append('-k')
     111
     112        options.changefieldvalue('expstyle',expstylevaluesarray)
     113        options.changefieldvalue('expdisp',expdispvaluesarray)
     114
     115        #latlonnumbering
     116        if options.exist('latlonclick'):
     117                if 'on' in options.getfieldvalue('latlonclick','on'):
     118                        options.changefieldvalue('latlonclick',1)
     119
     120        #northarrow
     121        if options.exist('northarrow'):
     122                if 'on' in options.getfieldvalue('northarrow','on'):
     123                        #default values
     124                        Lx=max(md.mesh.x)-min(md.mesh.x)
     125                        Ly=max(md.mesh.y)-min(md.mesh.y)
     126                        options.changefieldvalue('northarrow',[min(md.mesh.x)+1./6.*Lx, min(md.mesh.y)+5./6.*Ly, 1./15.*Ly, 0.25, 1./250.*Ly])
     127
     128        #scale ruler
     129        if options.exist('scaleruler'):
     130                if 'on' in options.exist('scaleruler','on'):
     131                        Lx=max(md.mesh.x)-min(md.mesh.x)
     132                        Ly=max(md.mesh.y)-min(md.mesh.y)
     133                        options.changefieldvalue('scaleruler',[min(md.mesh.x)+6./8.*Lx, min(md.mesh.y)+1./10.*Ly, 10**(ceil(log10(Lx)))/5, floor(Lx/100), 5])
     134
     135        #log scale
     136        if options.exist('log'):
     137                if options.exist('caxis'):
     138                        options.changefieldvalue('caxis',log(options.getfieldvalue('caxis'))/log(options.getfieldvalue('log')))
     139                options.changefieldvalue('cutoff',log(options.getfieldvalue('cutoff',1.5))/log(options.getfieldvalue('log')))
     140
    14141        return options
    15 
  • issm/trunk-jpl/src/m/plot/plotmodel.py

    r14252 r14260  
     1import numpy as npy
    12
    23try:
     
    2122        subplotwidth=ceil(sqrt(options.numberofplots))
    2223       
     24        #Get figure number and number of plots
     25        figurenumber=options.figurenumber
     26        numberofplots=options.numberofplots
     27
    2328        #if nlines and ncols specified, then bypass
    2429        if options.list[0].exist('nlines'):
     
    2631                nl=True
    2732        else:
    28                 nlines=subplotwidth
     33                nlines=npy.ceil(numberofplots/subplotwidth)
    2934                nl=False
    3035       
     
    4045                raise StandardError('error: nlines and ncols need to be specified together, or not at all')
    4146       
    42         #Get figure number and number of plots
    43         figurenumber=options.figurenumber
    44         numberofplots=options.numberofplots
    4547       
    4648        #Go through plots
Note: See TracChangeset for help on using the changeset viewer.