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)
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)
def single_time(fol, time): os.chdir(fol + '/agent_State/') axis = plt.subplot(111) output = results.AgentOutput(path=time) time = (output.time) for species in output.species_outputs: if species.members == []: continue for cell in species.members: name = species.name for (species_name, colormap_name) in species_color_dict.iteritems(): if name == species_name: norm = matplotlib.colors.Normalize(vmin=0, vmax=1) colormap = matplotlib.cm.get_cmap(colormap_name, 256) m = matplotlib.cm.ScalarMappable(norm=norm, cmap=colormap) age = float(cell.vars['age']) cell.color = m.to_rgba(age) toolbox_idynomics.plot_cells_2d(axis, output) output = results.EnvOutput(path='env_State(last).xml') for solute in output.solute_outputs: if solute.name == 'glucose': solute_output = solute toolbox_idynomics.solute_contour(axis, solute_output, interpolation='bicubic') axis.text(250, 250, 'Time: ' + str(int(time)) + 'h', va='top', ha='right', color='#bd0303', fontsize=fs) axis.set_xlabel(r'$\mu$m', fontsize=fs) axis.set_ylabel(r'$\mu$m', fontsize=fs) os.mkdir(fol + '/times/') os.chdir(fol + '/times/') plt.savefig('Biofilm time ' + time[12:-5] + '.png', bbox_inches='tight') plt.close()
def single_time(fol, time_fn, count, arate=True): biomass_names = [ 'activeBiomassGrowth', 'activeBiomassRepair', 'inactiveBiomassGrowth', 'inactiveBiomassRepair' ] ax = plt.subplot(111) os.chdir(fol + '/agent_State/') output = results.AgentOutput(path=time_fn) time = (output.time) ma1, ma2 = 0, 0 for species in output.species_outputs: if species.members == []: continue if not arate: all_growth = [] for cell in species.members: all_growth.append( float(cell.get_specific_growth_rate(biomass_names))) ma = max(all_growth) if ma1 == 0: ma1 = ma else: ma2 = ma for cell in species.members: name = species.name for (species_name, colormap_name) in species_color_dict.items(): if name == species_name: colormap = matplotlib.cm.get_cmap(colormap_name, 256) if not arate: l0, l06 = numpy.log(0.001), numpy.log(0.6) norm = matplotlib.colors.Normalize(vmin=l0, vmax=l06) else: norm = matplotlib.colors.Normalize(vmin=0, vmax=1) m = matplotlib.cm.ScalarMappable(norm=norm, cmap=colormap) if arate: age = float(cell.vars['age']) else: gr = float( cell.get_specific_growth_rate(biomass_names)) if gr == 0: gr = numpy.log(0.001) else: gr = numpy.log(gr) if arate: cell.color = m.to_rgba(age) else: cell.color = m.to_rgba(gr) toolbox_idynomics.plot_cells_2d(ax, output) os.chdir(fol + '/env_State/') output = results.EnvOutput(path=time_fn.replace('agent', 'env')) for solute in output.solute_outputs: if solute.name == 'glucose': solute_output = solute toolbox_idynomics.solute_contour(ax, solute_output, interpolation='bicubic') ax.text(250, 250, 'Time: ' + str(count) + 'h', va='top', ha='right', color='#bd0303', fontsize=fs) os.chdir(fol) if arate: plt.savefig(fol + '/times/' + str(count) + '.png', bbox_inches='tight', dpi=300) else: plt.savefig(fol + '/times_gr/' + str(count) + '.png', bbox_inches='tight', dpi=300) plt.close() return
growthrate = 1 else: growthrate = 0 if species.name == 'OldieA': OldieA_activelayer += growthrate elif species.name == 'OldieB': OldieB_activelayer += growthrate if species.name == 'OldieA': if growthrate == 1: cell.color = species_color_dict[0] elif growthrate == 0: cell.color = species_color_dict[1] elif species.name == 'OldieB': if growthrate == 1: cell.color = species_color_dict[2] elif growthrate == 0: cell.color = species_color_dict[3] toolbox_idynomics.plot_cells_2d(axis, output) os.chdir(folder + f + '/env_State') output = results.EnvOutput(path='env_State' + times[a][11:]) for solute in output.solute_outputs: if solute.name == 'glucose': solute_output = solute toolbox_idynomics.solute_contour(axis, solute_output, interpolation='bicubic') axis.text(250, 250, 'Time: ' + str(int(time)) + 'h', va='top', ha='right', color='#bd0303', fontsize=fs)