Exemplo n.º 1
0
def plotRxDConcentration(speciesLabel,
                         regionLabel,
                         plane='xy',
                         figSize=(5, 10),
                         fontSize=10,
                         scalebar=False,
                         title=True,
                         showFig=True,
                         saveFig=True):

    from .. import sim

    # set font size
    plt.rcParams.update({'font.size': fontSize})

    species = sim.net.rxd['species'][speciesLabel]['hObj']
    region = sim.net.rxd['regions'][regionLabel]['hObj']
    plane2mean = {'xz': 1, 'xy': 2}

    fig = plt.figure(figsize=figSize)
    plt.imshow(species[region].states3d[:].mean(plane2mean[plane]).T,
               interpolation='nearest',
               origin='upper')  #  extent=k[extracellular].extent('xy')

    ax = plt.gca()
    if scalebar:
        ax.xaxis.set_visible(False)
        ax.yaxis.set_visible(False)
        sb = ScaleBar(1e-6)
        sb.location = 'lower left'
        ax.add_artist(sb)

    plt.colorbar(label='[' + species.name + '] (mM)')
    plt.xlabel(plane[0] + ' location (um)')
    plt.ylabel(plane[1] + ' location (um)')
    if title:
        plt.title('RxD: ' + species.name + ' concentration')
    plt.tight_layout()

    # show fig
    if showFig: _showFigure()

    # save figure
    if saveFig:
        if isinstance(saveFig, basestring):
            filename = saveFig
        else:
            filename = sim.cfg.filename + '_rxd_concentration.png'
        plt.savefig(filename)

    return fig, {'data': species[region].states3d[:].mean(plane2mean[plane])}
Exemplo n.º 2
0
def plotRxDConcentration(speciesLabel,
                         regionLabel,
                         plane='xy',
                         figSize=(5, 10),
                         clim=None,
                         fontSize=10,
                         scalebar=False,
                         title=True,
                         showFig=True,
                         saveFig=True,
                         **kwargs):
    """
    Function to plot reaction-diffusion concentrations

    Parameters
    ----------
    speciesLabel : <type>
        <Short description of speciesLabel>
        **Default:** *required*

    regionLabel : <type>
        <Short description of regionLabel>
        **Default:** *required*

    plane : str
        <Short description of plane>
        **Default:** ``'xy'``
        **Options:** ``<option>`` <description of option>

    figSize : tuple
        <Short description of figSize>
        **Default:** ``(5, 10)``
        **Options:** ``<option>`` <description of option>

    fontSize : int
        <Short description of fontSize>
        **Default:** ``10``
        **Options:** ``<option>`` <description of option>

    scalebar : bool
        <Short description of scalebar>
        **Default:** ``False``
        **Options:** ``<option>`` <description of option>

    title : bool
        <Short description of title>
        **Default:** ``True``
        **Options:** ``<option>`` <description of option>

    showFig : bool
        <Short description of showFig>
        **Default:** ``True``
        **Options:** ``<option>`` <description of option>

    saveFig : bool
        <Short description of saveFig>
        **Default:** ``True``
        **Options:** ``<option>`` <description of option>


    """

    from .. import sim

    print('Plotting RxD concentration ...')

    # set font size
    plt.rcParams.update({'font.size': fontSize})

    species = sim.net.rxd['species'][speciesLabel]['hObj']
    region = sim.net.rxd['regions'][regionLabel]['hObj']
    plane2mean = {'xz': 1, 'xy': 2}

    extent = []
    extent.append(sim.net.rxd['regions'][regionLabel][plane[0] + 'lo'])
    extent.append(sim.net.rxd['regions'][regionLabel][plane[0] + 'hi'])
    extent.append(sim.net.rxd['regions'][regionLabel][plane[1] + 'lo'])
    extent.append(sim.net.rxd['regions'][regionLabel][plane[1] + 'hi'])

    vmin = None
    vmax = None
    if clim is not None:
        vmin = clim[0]
        vmax = clim[1]

    fig = plt.figure(figsize=figSize)
    plt.imshow(species[region].states3d[:].mean(plane2mean[plane]).T,
               interpolation='nearest',
               origin='upper',
               extent=extent,
               vmin=vmin,
               vmax=vmax)
    import numpy as np
    print('  min:',
          np.min(species[region].states3d[:].mean(plane2mean[plane]).T))
    print('  max:',
          np.max(species[region].states3d[:].mean(plane2mean[plane]).T))

    ax = plt.gca()
    if scalebar:
        ax.xaxis.set_visible(False)
        ax.yaxis.set_visible(False)
        sb = ScaleBar(1e-6)
        sb.location = 'lower left'
        ax.add_artist(sb)

    cb = plt.colorbar(label='[' + species.name + '] (mM)')
    plt.xlabel(plane[0] + ' location (um)')
    plt.ylabel(plane[1] + ' location (um)')

    if saveFig == 'movie':
        from neuron import h
        cb.ax.set_title('Time = ' + str(round(h.t, 1)), fontsize=fontSize)

    if title:
        plt.title('RxD: ' + species.name + ' concentration')
    plt.tight_layout()

    # show fig
    if showFig: _showFigure()

    # save figure
    if saveFig:
        if isinstance(saveFig, basestring):
            if saveFig == 'movie':
                filename = sim.cfg.filename + '_rxd_concentration_movie_' + str(
                    round(h.t, 1)) + '.png'
            else:
                filename = saveFig
        else:
            filename = sim.cfg.filename + '_rxd_concentration.png'
        plt.savefig(filename)

    return fig, {'data': species[region].states3d[:].mean(plane2mean[plane])}
Exemplo n.º 3
0
    cax = divider.append_axes('bottom', size='5%', pad=0.1)
    cbar = plt.colorbar(mapColor, cax=cax, orientation='horizontal')
    xpos = np.linspace(vmin, vmax, 7)
    xpos = np.around(xpos, decimals=1)
    cbar.set_ticks(xpos)
    cbar.ax.xaxis.tick_bottom()
    cbar.ax.xaxis.set_label_position('bottom')
    cbar.ax.set_xlabel('Composição de {} (% massa)'.format(el))
    # ax.text(s=el, x=15, y=170, backgroundcolor='white')

    ax.axhline(135, color='black', ls='--', lw=1.5)

    if i == 0:
        from matplotlib_scalebar.scalebar import ScaleBar
        scalebar = ScaleBar(1e-6)
        scalebar.location = 'lower right'
        ax.add_artist(scalebar)

    i += 1

I['C'] = comp['C'].values.reshape(400, -1)

ax = axes[i][0]
Si = np.mean(I['Si'][129:131, :], axis=0)
Mn = np.mean(I['Mn'][129:131, :], axis=0)
Cu = np.mean(I['Cu'][129:131, :], axis=0)
C = np.mean(I['C'][129:131, :], axis=0)
C[100:110] = 100.

x = np.linspace(0, 400., 400)
ax.plot(x, Si, lw=1.)
Exemplo n.º 4
0
def plotRxDConcentration(speciesLabel, regionLabel, plane='xy', figSize=(5,10), fontSize=10, scalebar=False, title=True, showFig=True, saveFig=True):
    """
    Function for/to <short description of `netpyne.analysis.rxd.plotRxDConcentration`>

    Parameters
    ----------
    speciesLabel : <type>
        <Short description of speciesLabel>
        **Default:** *required*

    regionLabel : <type>
        <Short description of regionLabel>
        **Default:** *required*

    plane : str
        <Short description of plane>
        **Default:** ``'xy'``
        **Options:** ``<option>`` <description of option>

    figSize : tuple
        <Short description of figSize>
        **Default:** ``(5, 10)``
        **Options:** ``<option>`` <description of option>

    fontSize : int
        <Short description of fontSize>
        **Default:** ``10``
        **Options:** ``<option>`` <description of option>

    scalebar : bool
        <Short description of scalebar>
        **Default:** ``False``
        **Options:** ``<option>`` <description of option>

    title : bool
        <Short description of title>
        **Default:** ``True``
        **Options:** ``<option>`` <description of option>

    showFig : bool
        <Short description of showFig>
        **Default:** ``True``
        **Options:** ``<option>`` <description of option>

    saveFig : bool
        <Short description of saveFig>
        **Default:** ``True``
        **Options:** ``<option>`` <description of option>


    """



    from .. import sim

    # set font size
    plt.rcParams.update({'font.size': fontSize})

    species = sim.net.rxd['species'][speciesLabel]['hObj']
    region = sim.net.rxd['regions'][regionLabel]['hObj']
    plane2mean = {'xz': 1, 'xy': 2}

    extent = []
    extent.append(sim.net.rxd['regions'][regionLabel][plane[0] + 'lo'])
    extent.append(sim.net.rxd['regions'][regionLabel][plane[0] + 'hi'])
    extent.append(sim.net.rxd['regions'][regionLabel][plane[1] + 'lo'])
    extent.append(sim.net.rxd['regions'][regionLabel][plane[1] + 'hi'])

    fig = plt.figure(figsize=figSize)
    plt.imshow(species[region].states3d[:].mean(plane2mean[plane]).T, interpolation='nearest', origin='upper', extent=extent)

    ax = plt.gca()
    if scalebar:
        ax.xaxis.set_visible(False)
        ax.yaxis.set_visible(False)
        sb = ScaleBar(1e-6)
        sb.location = 'lower left'
        ax.add_artist(sb)

    plt.colorbar(label='[' + species.name + '] (mM)')
    plt.xlabel(plane[0] + ' location (um)')
    plt.ylabel(plane[1] + ' location (um)')
    if title:
        plt.title('RxD: ' + species.name +  ' concentration')
    plt.tight_layout()

    # show fig
    if showFig: _showFigure()

    # save figure
    if saveFig:
        if isinstance(saveFig, basestring):
            filename = saveFig
        else:
            filename = sim.cfg.filename + '_rxd_concentration.png'
        plt.savefig(filename)

    return fig, {'data': species[region].states3d[:].mean(plane2mean[plane])}