Changeset 27087


Ignore:
Timestamp:
06/22/22 01:42:55 (3 years ago)
Author:
bdef
Message:

BUG: fixes to caxis plotting and issues with P2 elements

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

Legend:

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

    r26928 r27087  
    1111from plot_contour import plot_contour
    1212from plot_streamlines import plot_streamlines
     13from plot_edgeoverlay import plot_edgeoverlay
    1314
    1415
     
    156157    # {{{ ShowBasins TODO
    157158    # }}}
    158     # {{{ clim
    159     if options.exist('clim'):
    160         lims = options.getfieldvalue('clim')
    161         assert len(lims) == 2, 'error, clim should be passed as a list of length 2'
    162     elif options.exist('caxis'):
     159    # {{{ caxis
     160    if options.exist('caxis'):
    163161        lims = options.getfieldvalue('caxis')
    164162        assert len(lims) == 2, 'error, caxis should be passed as a list of length 2'
    165         options.addfielddefault('clim', lims)
     163        options.addfielddefault('caxis', lims)
    166164    else:
    167165        if len(data) > 0:
     
    192190    if options.exist('contourlevels'):
    193191        plot_contour(md, data, options, ax)
     192    # }}}
     193    # {{{ edgeoverlay
     194    if options.exist('edgeoverlay'):
     195        edgedata = options.getfieldvalue('edgeoverlay')
     196        plot_edgeoverlay(md, edgedata, options, ax)
    194197    # }}}
    195198    # {{{ wrapping TODO
  • issm/trunk-jpl/src/m/plot/plot_unit.py

    r25125 r27087  
    5252        cmap = getcolormap(options)
    5353    if options.exist('cmap_set_over'):
    54         over = options.getfieldvalue('cmap_set_over', '0.5')
     54        over = options.getfieldvalue('cmap_set_over', 'k')
    5555        cmap.set_over(over)
    5656    if options.exist('cmap_set_under'):
    57         under = options.getfieldvalue('cmap_set_under', '0.5')
     57        under = options.getfieldvalue('cmap_set_under', 'k')
    5858        cmap.set_under(under)
    5959    options.addfield('colormap', cmap)
     
    7575        limextent = 0.
    7676
    77     if options.exist('clim'):
    78         lims = options.getfieldvalue('clim', [np.nanmin(data), np.nanmax(data)])
    79     elif options.exist('caxis'):
     77    if options.exist('caxis'):
    8078        lims = options.getfieldvalue('caxis', [np.nanmin(data), np.nanmax(data)])
    8179    else:
     
    9391    else:
    9492        norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1])
    95     if options.exist('log'):
    96         norm = mpl.colors.LogNorm(vmin=lims[0], vmax=lims[1])
    97     else:
    98         norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1])
    9993    options.addfield('colornorm', norm)
    10094    # }}}
     
    10296    # Plot depending on the datatype
    10397    # {{{ data are on elements
    104 
    10598    if datatype == 1:
    10699        if is2d:
  • issm/trunk-jpl/src/m/plot/plotmodel.py

    r26569 r27087  
    8686        #       taken from https://matplotlib.org/api/_as_gen/mpl_toolkits.axes_grid1.axes_grid.ImageGrid.html
    8787        #
    88         direction = options.list[0].getfieldvalue('direction', 'row') # {"row", "column"}, default: "row"
    89         axes_pad = options.list[0].getfieldvalue('axes_pad', 0.25) # float or (float, float), default : 0.02; Padding or (horizonal padding, vertical padding) between axes, in inches
    90         add_all = options.list[0].getfieldvalue('add_all', True) # bool, default: True
    91         share_all = options.list[0].getfieldvalue('share_all', True) # bool, default: False
    92         label_mode = options.list[0].getfieldvalue('label_mode', 'L') # {"L", "1", "all"}, default: "L"; Determines which axes will get tick labels: "L": All axes on the left column get vertical tick labels; all axes on the bottom row get horizontal tick labels;. "1": Only the bottom left axes is labelled. "all": all axes are labelled.
     88        direction = options.list[0].getfieldvalue('direction', 'row')  # {"row", "column"}, default: "row"
     89        axes_pad = options.list[0].getfieldvalue('axes_pad', 0.25)  # float or (float, float), default : 0.02; Padding or (horizonal padding, vertical padding) between axes, in inches
     90        add_all = options.list[0].getfieldvalue('add_all', True)  # bool, default: True
     91        share_all = options.list[0].getfieldvalue('share_all', True)  # bool, default: False
     92        label_mode = options.list[0].getfieldvalue('label_mode', 'L')  # {"L", "1", "all"}, default: "L"; Determines which axes will get tick labels: "L": All axes on the left column get vertical tick labels; all axes on the bottom row get horizontal tick labels;. "1": Only the bottom left axes is labelled. "all": all axes are labelled.
    9393
    9494        # Translate MATLAB colorbar mode to matplotlib
  • issm/trunk-jpl/src/m/plot/processdata.py

    r26569 r27087  
    6060    #  quiver plot {{{
    6161    if datasize[1] > 1 and datasize[0] != numberofvertices + 1:
    62         if datasize[0] == numberofvertices and datasize[1] == 2:
     62        if datasize[0] == numberofvertices and datasize[1] in [2, 3]:
    6363            datatype = 3
     64            if md.mesh.dimension() == 3:
     65                if datasize[1] == 2:
     66                    data = np.hstack(data, np.zeros((datasize[0])))
     67                elif datasize[1] > 3:
     68                    raise ValueError('plotmodel error message: data should have two or three columns of length md.mesh.numberofvertices for a quiver plot')
    6469        else:
    65             raise ValueError('plotmodel error message: data should have two columns of length md.mesh.numberofvertices for a quiver plot')
     70            #we should have a patch
     71            print("Assuming that data provided is a patch")
     72            datatype = 4
     73            index = md.mesh.elements
     74            if np.shape(data)[1] < np.shape(index)[1]:
     75                    raise ValueError('plotmodel error message: data should have more columns than vertices per elements to plot a patch')
     76            procdata = np.zeros((numberofvertices))
     77            procdata[md.mesh.elements -1] = data[:, 0:np.shape(index)[1]]
     78            datasize = [numberofvertices, 1]
     79
    6680    # }}}
    6781
     
    142156    nanfill = options.getfieldvalue('nan', -9999)
    143157    if np.any(np.isnan(procdata)):
    144         lb = np.nanmin(procdata)
    145         ub = np.nanmax(procdata)
    146         if lb == ub:
    147             lb = lb - 0.5
    148             ub = ub + 0.5
    149             nanfill = lb - 1
     158        if options.exist('caxis'):
     159            [lb, ub] = options.getfieldvalue('caxis')
     160        else:
     161            lb = np.nanmin(procdata)
     162            ub = np.nanmax(procdata)
     163            if lb == ub:
     164                lb = lb - 0.5
     165                ub = ub + 0.5
     166                nanfill = lb - 1
     167            options.addfielddefault('caxis', [lb, ub])
     168
    150169        procdata[np.isnan(procdata)] = nanfill
    151170        procdata = np.ma.array(procdata, mask=np.isnan(procdata))
    152         #clim looks to be deprecated and replaced by caxis
    153         #options.addfielddefault('clim', [lb, ub])
    154         options.addfielddefault('cmap_set_under', '1')
    155         print(("WARNING: nan's treated as", nanfill, "by default.  Change using pairoption 'nan', nan_fill_value in plotmodel call"))
     171        print('from nan processing {} and {}'.format(lb, ub))
     172        if nanfill < lb:
     173            options.addfielddefault('cmap_set_under', 'k')
     174        elif nanfill > ub:
     175            options.addfielddefault('cmap_set_over', 'k')
     176        if nanfill < ub and nanfill > lb:
     177            print(("WARNING: nan's treated as", nanfill, "by default. Which is in your data interval, change it with ['nan', value] in plotmodel options"))
    156178    # }}}
    157179
Note: See TracChangeset for help on using the changeset viewer.