def __init__(self, simulation_directory, iterate_number):
     self.number = iterate_number
     self.min_max_concns = {}
     agent_path = os.path.join(simulation_directory.agent_State,
                                 'agent_State(%d).xml'%(iterate_number))
     agent_path = toolbox_basic.check_path(agent_path)
     self.agent_output = toolbox_results.AgentOutput(path=agent_path)
     self.time = self.agent_output.time
     agent_path = os.path.join(simulation_directory.agent_Sum,
                                 'agent_Sum(%d).xml'%(iterate_number))
     agent_path = toolbox_basic.check_path(agent_path)
     self.agent_sum = toolbox_results.AgentOutput(path=agent_path)        
     env_path = os.path.join(simulation_directory.env_State,
                                     'env_State(%d).xml'%(iterate_number))
     env_path = toolbox_basic.check_path(env_path)
     self.env_output = toolbox_results.EnvOutput(path=env_path)
     env_path = os.path.join(simulation_directory.env_Sum,
                                     'env_Sum(%d).xml'%(iterate_number))
     env_path = toolbox_basic.check_path(env_path)
     self.env_sum = toolbox_results.EnvOutput(path=env_path)
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()
예제 #3
0
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
예제 #4
0
             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)
 axis.set_xlabel(r'$\mu$m', fontsize=fs)
 axis.set_ylabel(r'$\mu$m', fontsize=fs)
        """
        lims = xlims[name]
        for (species_name, colormap_name) in species_color_dict.items():
            if name == species_name:
                colormap = matplotlib.cm.get_cmap(colormap_name, 256)
                norm = matplotlib.colors.Normalize(vmin=0, vmax=1)
                m = matplotlib.cm.ScalarMappable(norm=norm, cmap=colormap)
                age = float(cell.vars['age'])
                cell.color = m.to_rgba(age)
        spec_growth = float(cell.get_specific_growth_rate(biomass_names))
        colors.append(cell.color)
        growth_rates.append(spec_growth)
        xloc.append(x)
        yloc.append(y)
os.chdir(fi + '/env_State')
output = results.EnvOutput(path='env_State(1000).xml')
for solute in output.solute_outputs:
    if solute.name != 'glucose': continue
    array = solute.concentration_array()
solute = list(array)
concs = []
for a in range(len(colors)):
    x, y = int(xloc[a] / 4), int(yloc[a] / 4)
    conc = solute[x][y]
    concs.append(conc)
    ax2.scatter(conc,
                growth_rates[a],
                color=colors[a],
                s=20,
                edgecolors='gray',
                linewidths=0.1)