def plot(iter_info, min_max_concns):
    axis = figure.add_subplot('', 111, frameon=options.frameon)
    toolbox_idynomics.color_cells_by_species(iter_info.agent_output,
                                                           species_color_dict)
    toolbox_idynomics.plot_cells_2d(axis, iter_info.agent_output)
    if options.substratum:
        axis.fill_between([0, nJ*res], [0]*2, y2=[-res]*2, color='k', zorder=-1)
    figure.subplots_adjust(left=0.01, bottom=0.01, right=0.9, top=0.9)
    figure.inset_axes()
    if not options.solute_name == "none":
        #print min_max_concns[options.solute_name]
        solute_output = toolbox_results.SoluteOutput(iter_info.env_output,
                                                     name=options.solute_name)
        cs = toolbox_idynomics.solute_contour(axis, solute_output,
                            concn_range=min_max_concns[options.solute_name],
                                                    interpolation='bicubic')
        if options.color_bar:
            toolbox_plotting.make_colorbar(axis, cs)
    if options.titleon:
        axis.set_title(r'Biofilm (%s g L$^{-1}$)'%(options.solute_name))
    if options.frameon:
        axis.set_xlabel('x')
        axis.set_ylabel('y')
    if options.timeon:
        axis.text(0.0, nI*res, 'Time: %d h'%(int(iter_info.time)),
                  va='top', ha='left')
    axis.set_xlim(0, nJ * res)
    axis.set_ylim(-res, nI * res)
    save_num = str(iter_info.number)
    #save_num = str(counter)
    #counter += 1
    save_num = (num_digits - len(save_num))*'0' + save_num
    save_path = os.path.join(sim.figures_dir,
                                     save_name+'_'+save_num+options.file_ext)
    figure.save(save_path, dpi=options.dpi)
def plot(iter_info, min_max_concns):
    axis = figure.add_subplot('', 111, frameon=options.frameon)
    for species in iter_info.agent_output.species_outputs:
        species_name = species.name
        for cell in species.members:
            spStatus = cell.vars['sporeStatus']
            mbStatus = cell.vars['metabolismStatus']
            if spStatus == 'spore':
                cell.color = species_color_dict[species_name+"_spore"]
                continue
            if spStatus == 'sporulating':
                cell.color = species_color_dict[species_name+"_sporulating"]
                continue
            if mbStatus == 'glycolysis':
                cell.color = species_color_dict[species_name+"_glycolysis"]
                continue
            if mbStatus == 'solventogenesis':
                cell.color = species_color_dict[species_name+"_solventogenesis"]
                continue
    toolbox_idynomics.plot_cells_2d(axis, iter_info.agent_output)
    if options.substratum:
        axis.fill_between([0, nJ*res], [0]*2, y2=[-res]*2, color='k', zorder=-1)
    lb = 0.01
    if options.frameon:
        lb = 0.12
        figure.process_lines()
    figure.subplots_adjust(left=lb, bottom=lb, right=0.9, top=0.9)
    figure.inset_axes()
    if not options.solute_name == "none":
        #print min_max_concns[options.solute_name]
        solute_output = toolbox_results.SoluteOutput(iter_info.env_output,
                                                     name=options.solute_name)
        cs = toolbox_idynomics.solute_contour(axis, solute_output,
                            concn_range=min_max_concns[options.solute_name],
                                                    interpolation='bicubic')
        if options.color_bar:
            toolbox_plotting.make_colorbar(axis, cs)
    if options.titleon:
        axis.set_title(r'Biofilm (%s g L$^{-1}$)'%(options.solute_name))
    if options.frameon:
        axis.set_xlabel(r'x ($\mu$m)')
        axis.set_ylabel(r'y ($\mu$m)')
    if options.timeon:
        axis.text(0.1*res, (nI+0.1)*res, 'Time: %.2f h'%(iter_info.time),
                  va='bottom', ha='left', color='0.5')
    axis.set_xlim(0, nJ * res)
    axis.set_ylim(-res, nI * res)
    save_num = str(iter_info.number)
    #save_num = str(counter)
    #counter += 1
    save_num = (num_digits - len(save_num))*'0' + save_num
    save_path = os.path.join(sim.figures_dir,
                                     save_name+'_'+save_num+options.file_ext)
    figure.save(save_path, dpi=options.dpi)
Beispiel #3
0
 def plot_rate_array(self, axis, detail_level, sif_name):
     array = self.get_rate_array(detail_level, sif_name)
     extent = [0.0, self.side_length]*2
     max_val = numpy.max(abs(array))
     cdict = {'red':   ((0, 0, 0), (0.5, 1, 1), (1, 1, 1)),
              'green': ((0, 0, 0), (0.5, 1, 1), (1, 0, 0)),
              'blue':  ((0, 1, 1), (0.5, 1, 1), (1, 0, 0))}
     cmap = matplotlib.colors.LinearSegmentedColormap('cmap', cdict, 255)
     cs = axis.imshow(array, interpolation='nearest', extent=extent,
                                                  origin='lower', cmap=cmap)
     cs.set_clim(-max_val, max_val)
     axis.set_xlim(0.0, self.side_length)
     axis.set_ylim(0.0, self.side_length)
     toolbox_plotting.make_colorbar(axis, cs)
Beispiel #4
0
 def plot_concn_array(self, axis, detail_level, sif_name, set_as_white=None, plot_cs=True):
     array = self.get_concn_array(detail_level, sif_name)
     extent = [-0.5/detail_level, self.side_length + 0.5/detail_level]*2
     bottom_red, top_red     = 0.1, 0.7
     bottom_green, top_green = 0.6, 0.0
     bottom_blue, top_blue   = 0.1, 0.5
     mid_point = 0.5
     if not set_as_white == None:
         max_val, min_val = numpy.max(array), numpy.min(array)
         up_diff, down_diff = max_val - set_as_white, set_as_white - min_val
         max_diff, total_diff = max(up_diff, down_diff), max_val - min_val
         up_rel_diff, down_rel_diff = up_diff/max_diff, down_diff/max_diff
         mid_point = down_diff/total_diff
     cdict = {'red':   ((0, bottom_red, bottom_red),
                        (mid_point, 1, 1),
                        (1, top_red, top_red)),
              'green': ((0, bottom_green, bottom_green),
                        (mid_point, 1, 1),
                        (1, top_green, top_green)),
              'blue':  ((0, bottom_blue, bottom_blue),
                        (mid_point, 1, 1),
                        (1, top_blue, top_blue))}
     my_cmap = \
            matplotlib.colors.LinearSegmentedColormap('my_cmap', cdict, 255)
     cs = axis.imshow(array, interpolation='nearest', origin='lower',
                                                extent=extent, cmap=my_cmap)
     axis.set_xlim(0.0, self.side_length), axis.set_ylim(0.0, self.side_length)
     if plot_cs:
         cbar = toolbox_plotting.make_colorbar(axis, cs, fontsize=8)
         return cbar
     else:
         return cs
def plot(iter_info, min_max_concns):
    axis = figure.add_subplot('', 111, frameon=options.frameon)
    toolbox_idynomics.color_cells_by_species(iter_info.agent_output,
                                             species_color_dict)
    toolbox_idynomics.plot_cells_2d(axis, iter_info.agent_output)
    if options.substratum:
        axis.fill_between([0, nJ * res], [0] * 2,
                          y2=[-res] * 2,
                          color='k',
                          zorder=-1)
    lb = 0.01
    if options.frameon:
        lb = 0.06
        figure.process_lines()
    figure.subplots_adjust(left=lb, bottom=lb, right=0.9, top=0.9)
    figure.inset_axes()
    if not options.solute_name == "none":
        #print min_max_concns[options.solute_name]
        solute_output = toolbox_results.SoluteOutput(iter_info.env_output,
                                                     name=options.solute_name)
        cs = toolbox_idynomics.solute_contour(
            axis,
            solute_output,
            concn_range=min_max_concns[options.solute_name],
            interpolation='bicubic')
        if options.color_bar:
            toolbox_plotting.make_colorbar(axis, cs)
    if options.titleon:
        axis.set_title(r'Biofilm (%s g L$^{-1}$)' % (options.solute_name))
    if options.frameon:
        axis.set_xlabel(r'x ($\mu$m)')
        axis.set_ylabel(r'y ($\mu$m)')
    if options.timeon:
        axis.text(0.1 * res, (nI + 0.1) * res,
                  'Time: %d h' % (int(iter_info.time)),
                  va='bottom',
                  ha='left',
                  color='0.5')
    axis.set_xlim(0, nJ * res)
    axis.set_ylim(-res, nI * res)
    save_num = str(iter_info.number)
    #save_num = str(counter)
    #counter += 1
    save_num = (num_digits - len(save_num)) * '0' + save_num
    save_path = os.path.join(sim.figures_dir,
                             save_name + '_' + save_num + options.file_ext)
    figure.save(save_path, dpi=options.dpi)
Beispiel #6
0
 def make_run_plot(self, detail_level, sif_name, maxP=None):
     fig = toolbox_plotting.ThesisFigure(double_column=True)
     axis = fig.add_subplot('A', 221)
     #self.plot_rate_array(axis, detail_level, sif_name)
     self.plot_population(axis, detail_level, sif_name)
     toolbox_plotting.empty_padding_axis(axis, "bottom")
     axis = fig.add_subplot('B', 222)
     toolbox_plotting.empty_padding_axis(axis, "bottom")
     if maxP == None:
         maxP = numpy.max(self.get_concn_array(detail_level, sif_name))
         maxP = 10**math.ceil(math.log10(maxP))
     self.plot_kinetics(axis, detail_level, sif_name, maxP)
     axis.text(8, 0.2, r'$q_{A}([H])$', color='r', va='center', ha='center')
     axis.text(8, 0.8, r'$-q_{B}([H])$', color='b', va='center', ha='center')
     analytic = AnalyticApproach()
     analytic.set_parameters(A=1, qmaxA=1, pmax=10, kA=10, qmaxB=5, pmin=0.04, kB=30)
     p_equal = analytic.calc_equal_concn()
     r_equal = analytic.production(p_equal)
     axis.plot([p_equal]*2, [0,r_equal+0.05],
                                 color='0.5', linestyle='-', zorder=-10)
     axis.text(p_equal, r_equal+0.05, '%.2f'%(p_equal),
                         color='0.5', va='bottom', ha='center', fontsize=8)
     axis.plot([0, p_equal+0.5], [r_equal]*2,
                                 color='0.5', linestyle='-', zorder=-10)
     axis.text(p_equal+0.6, r_equal, '%.2f'%(r_equal),
                          color='0.5', va='center', ha='left', fontsize=8)
     axis = fig.add_subplot('C', 223)
     cs = self.plot_concn_array(axis, detail_level, sif_name, plot_cs=False)
     cbar = toolbox_plotting.make_colorbar(axis, cs, side="bottom")
     #label = r'Product concentration ($\mu$M)'
     label = r'Hydrogen concentration ($\mu$M)'
     cbar.set_ticks([2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7])
     cbar.set_label(label)
     axis.set_xticklabels(['']*10)
     axis = fig.add_subplot('D', 224)
     toolbox_plotting.empty_padding_axis(axis, "bottom")
     self.calc_nearest_neighbor_distances(detail_level)
     self.scatter_oNN_dist_vs_rate(axis, detail_level, sif_name)
     fig.subplots_adjust(left=0.05, right=0.98, bottom=0.08, top=0.96,
                                                 wspace=0.3, hspace=0.25)
     fig.process_subplots(label_pos=(0.0, 1.1))
     axis = fig.find_axis_from_label('C')
     axis.tick_params(bottom="off")
     fig.save(os.path.join(self.get_run_dir(detail_level, sif_name), 'run_plot.pdf'))