Ejemplo n.º 1
0
sys.path.append('Analysis/')
from AverageShape import PlotAvgShape

N = 1000
S = 100
sample_size = 50

rel = False

fig = plt.figure()
title = 'log(%N)'
""" 1. The Broken Stick Model constrained by N and S """
ax = fig.add_subplot(3, 3, 1)
RACsample = Models.SimBrokenStick(N, S, sample_size, rel)

fig = HeatMap.RACHeatMap(fig, RACsample)
fig = PlotAvgShape(fig, RACsample)

plt.title('Broken Stick', fontsize=13)
plt.xlabel('Rank')
#plt.ylabel('Abundance')
plt.ylabel(title)

print 'finished broken stick\n'
""" 2. The Log-normal (75/25) constrained by N and S """
ax = fig.add_subplot(3, 3, 2)
RACsample = Models.SimLogNormFloat(N, S, sample_size, rel)

fig = HeatMap.RACHeatMap(fig, RACsample)
fig = PlotAvgShape(fig, RACsample)
Ejemplo n.º 2
0
def fig2(SADModels):
    '''Heat map of one site, observed v heat from each model'''
    # Still working...
    #1. get obs for one site 2. put into each model 3. heat map

    fig = plt.figure()

    for i, model in enumerate(SADModels):

        fig.add_subplot(2, 2, i + 1)

        obs_pred_data = import_obs_pred_data(mydir + '/Results/' + model +
                                             '.txt')
        obs = ((obs_pred_data["obs"]))
        site = ((obs_pred_data["site"]))

        obs_data = []

        for sites in np.unique(site):
            obs_data.append(obs[sites == site])

        OBSSad = obs_data[10]

        OBSSad = map(int, OBSSad.tolist())
        N = sum(OBSSad)
        S = len(OBSSad)
        sample_size = 100
        print OBSSad

        if model == 'SimBrokenStick':
            prdSADs = Models.SimBrokenStick(N, S, sample_size)
            HeatMap.RACHeatMap(fig, prdSADs)
            plt.plot(np.log(AverageShape.AvgShape(prdSADs)),
                     color='lime',
                     label='Predicted',
                     lw=2)

        elif model == 'SimLogNormInt':
            prdSADs = Models.SimLogNormInt(N, S, sample_size)
            HeatMap.RACHeatMap(fig, prdSADs)
            plt.plot(np.log(AverageShape.AvgShape(prdSADs)),
                     color='lime',
                     label='Predicted',
                     lw=2)

        elif model == 'SimpleRandomFraction':
            prdSADs = Models.SimpleRandomFraction(N, S, sample_size)
            HeatMap.RACHeatMap(fig, prdSADs)
            plt.plot(np.log(AverageShape.AvgShape(prdSADs)),
                     color='lime',
                     label='Predicted',
                     lw=2)

        elif model == 'SimParetoInt':
            prdSADs = Models.SimParetoInt(N, S, sample_size)
            HeatMap.RACHeatMap(fig, prdSADs)
            plt.plot(np.log(AverageShape.AvgShape(prdSADs)),
                     color='lime',
                     label='Predicted',
                     lw=2)

        plt.title(model)
        plt.plot(np.log(OBSSad), color='m', lw=3, label="Observed", alpha=1.0)

        leg = plt.legend(loc=1, prop={'size': 8})
        leg.draw_frame(False)
        plt.text(10, 8, 'N =' + str(N) + ', S =' + str(S), fontsize=8)
        plt.xlim(0, S + 2)
        plt.xlabel('Rank in abundance', fontsize=12)
        plt.ylabel('log(abundance)', fontsize=12)
        plt.subplots_adjust(wspace=.35, hspace=.35)

    plt.savefig(
        '/Users/Nathan_Hillis/GitHub/SADModels/Projects/Mar2015meeting/HeatMaps_OneSite.png',
        dpi=600,
        bbox_inches='tight',
        pad_inches=0.03)
    plt.show()
    return
Ejemplo n.º 3
0
Well it was a nice try but I ran out of memory.'''

SADModels = ['SimBrokenStick', 'SimLogNormInt', 'SimpleRandomFraction',
                            'SimParetoInt']
N = 40000
S = 100
sample_size = 100
fig = plt.figure()

for i, model in enumerate(SADModels):

        fig.add_subplot(2, 2, i+1)

        if model == 'SimBrokenStick':
                    prdSADs = Models.SimBrokenStick(N, S, sample_size)
                    HeatMap.RACHeatMap(fig, prdSADs)
                    plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color = 'lime', label = 'Predicted', lw = 2)
                    print 'BS'
                    
        elif model == 'SimLogNormInt':
                    prdSADs = Models.SimLogNormInt(N, S, sample_size)
                    HeatMap.RACHeatMap(fig, prdSADs)
                    plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color = 'lime', label = 'Predicted', lw = 2)
                    print 'SLN'
                    
        elif model == 'SimpleRandomFraction':
                    prdSADs = Models.SimpleRandomFraction(N, S, sample_size)
                    HeatMap.RACHeatMap(fig, prdSADs)
                    plt.plot(np.log(AverageShape.AvgShape(prdSADs)), color = 'lime', label = 'Predicted', lw = 2)
                    print 'RandFrac'