Пример #1
0
f = 12. / np.max(p_species)
area = np.pi * (p_species*f)**2 # 0 to 12 point radiuses
pp.scatter(traits[0,:],traits[1,:],s=area,c=colors,alpha=0.6)
pp.xlim(0,1)
pp.ylim(0,1)
pp.axis('equal')
pl.show()

# sum of dendrogram branches
dist_species_v = fd.distance_v(traits)
pp.figure()
Z = ch.linkage(dist_species_v,method='single',metric='euclidean')
dend = ch.dendrogram(Z)
b = fd.branch_lengths(Z)
h = fd.branch_presence(Z)
div_fd = fd.fd(h,b)

# calculate rao's Q
dist_species_m = fd.distance_m(traits)
div_q = fd.rao(dist_species_m,p_species)

# calculate FAD
div_fad = fd.fad(dist_species_m)

# print diversity values
print "Functional Diversity: ", div_fd
print "Rao's Q: ", div_q
print "Functional Attribute Diversity: ", div_fad


Пример #2
0
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 16:56:52 2015
imp
@author: amandaprorok
"""

import numpy as np
import pylab as pl
import matplotlib.pyplot as pp
import numpy.linalg as la
import scipy.cluster.hierarchy as ch
import funcdef_diversity as fd

x = 10  # number of species
t = 2  # number of traits / dimensions

a = np.random.rand(t, x)
d = fd.distance_v(a)

Z = ch.linkage(d, method="single", metric="euclidean")
dend = ch.dendrogram(Z)

b = fd.branch_lengths(Z)
h = fd.branch_presence(Z)
fd = fd.fd(h, b)

print fd