Note
Go to the end to download the full example code.
Analyse an inventory¶
This example shows the different types of statistics that can be applied to an existing inventory for analysis.
Necessary imports
from spatiocoexistence import Inventory
from spatiocoexistence.data import inventory_file
Initialize the inventory
inv = Inventory.from_data(inventory_file)
Access the data from the inventory.
all_data = inv.data
x = inv.x
dbh = inv.dbh
species = inv.species
crowding_conspecifics_BA = inv.CI_CS
crowding_conspecifics = inv.CI_C
Get the species abundance of that inventory. The index refers to that species.
inv.species_abundance()[10]
np.int64(129)
4. Get the amount of reproductive individuals per species that are alive. The reproduction is defined by a tree being larger than the reproductive size. In this example we set it to = 2dm, and assume it holds for all tree species.
inv.count_reproductives(2)
(array([ 0, 29, 105, 454, 143, 28, 1, 171, 84, 24, 90, 12, 25,
170, 45, 36, 157, 9, 5, 68, 52, 21, 41, 8, 12, 57,
168, 15, 123, 21, 228, 38, 97, 170, 80, 16, 36, 7, 168,
46, 74, 59, 9, 96, 1, 46, 35, 200, 89, 165, 11, 176,
36, 478, 11, 110, 39, 3, 31, 51, 6, 40, 198, 28, 179,
13, 989, 45, 24, 25, 224, 112, 11, 75, 38, 897], dtype=int32), array([ 2, 3, 4, ..., 20515, 20516, 20517], shape=(7684,)))
Get the summary statistics of the plot. More information how to calculate them can be found in … ToDo
inv.get_BA_and_k()
(array([ 2.5350216 , 5.72626862, 4.7558197 , 6.4313602 , 0. ,
1.64784671, 7.53022908, 15.64648526, 1.09822482, 7.8630367 ,
2.22380728, 1.98102032, 5.39247401, 2.98440828, 4.13861385,
4.19205058, 1.48804531, 1.59443177, 7.03923928, 3.103917 ,
4.3342495 , 2.55024865, 1.21389167, 1.17654637, 0. ,
3.89232701, 1.2560269 , 3.94285989, 2.16756748, 2.18731194,
1.87837071, 2.50698635, 2.3764987 , 41.1362981 , 2.32417211,
4.16847158, 1.09698991, 8.33869431, 3.48354924, 2.35825732,
5.71830032, 1.39442405, 12.2888562 , 1.19249398, 8.3054285 ,
1.19997058, 3.75313683, 2.99568669, 14.68735626, 1.51154357,
3.92766453, 1.35058536, 13.64581685, 1.64229196, 5.95414774,
3.40562048, 1.47416314, 7.93548456, 2.35126361, 2.07658206,
12.76626178, 6.2770597 , 1.3402427 , 7.40210651, 1.65191719,
5.0383856 , 2.37988218, 2.67879672, 1.86108429, 3.00701361,
6.27202722, 2.2433842 , 6.44153831, 3.10601604, 10.20857836]), array([5.90758954, 5.08752063, 5.69982887, 5.38651354, 7.85793112,
6.33134646, 7.07446448, 6.28096888, 5.46172053, 5.56389605,
6.02894799, 8.27618822, 4.03834144, 4.79437134, 5.06290242,
4.81607605, 6.2466325 , 3.63640657, 7.1625957 , 8.29118164,
6.61197696, 6.21393474, 7.52333069, 6.60224667, 6.23121126,
6.86527958, 8.3568061 , 7.33854142, 6.70779604, 5.94834094,
7.09196612, 8.1363333 , 7.20440694, 5.08248881, 6.63012037,
5.02001295, 6.78319929, 4.54380425, 6.46466454, 5.51783699,
5.10281631, 6.69679866, 7.53112227, 6.66044357, 6.12226063,
5.97925271, 7.13246896, 6.52352474, 6.37932903, 6.68226073,
7.10968036, 5.72514605, 7.15129205, 6.52804434, 6.25205638,
8.96772691, 6.49060014, 4.29412862, 7.30376756, 6.99373505,
5.97062498, 5.53180638, 6.59641942, 6.85485563, 5.88031301,
8.20320975, 6.31724548, 6.64008416, 8.48562408, 6.44811979,
6.91019766, 9.49152756, 4.74124138, 5.26695417, 5.48911063]), array([1.51051883, 1.98482017, 1.83285556, 1.78796788, 0. ,
1.18300472, 2.55852563, 4.73526673, 0.383275 , 2.69554008,
1.36491466, 1.05006378, 1.97484844, 1.37478768, 1.57172499,
1.81294576, 1.11501691, 1.11896385, 2.46549827, 1.76699476,
2.38793082, 1.45411667, 0.98840474, 0.79228712, 0. ,
1.86447676, 0.81457812, 1.64733581, 1.3288138 , 1.1655271 ,
1.21321332, 1.35337776, 1.33815419, 5.54636437, 1.25143879,
1.87125104, 0.77429224, 2.224403 , 1.46131462, 0.96476724,
1.42604871, 1.04772658, 3.80245902, 1.06759929, 2.22475864,
0.21952256, 2.11176605, 1.13115502, 3.95608645, 1.05128917,
1.82569503, 0.63683063, 3.73995502, 1.17400954, 2.55257984,
1.33328794, 1.09218013, 2.52948563, 1.42428891, 1.52449653,
4.68681597, 2.12815127, 0.51428139, 2.66717745, 1.04606137,
2.12661324, 1.27084488, 1.27280347, 1.19726066, 1.60438308,
1.77610739, 1.51011983, 1.86992486, 1.30235237, 3.77965877]), array([2.59673734, 2.24425932, 2.52463228, 2.38657495, 3.46252103,
2.77516803, 3.12808103, 2.7759844 , 2.40591127, 2.4536383 ,
2.65145538, 3.64107203, 1.78199219, 2.11009145, 2.22973307,
2.12052228, 2.72492471, 1.59897258, 3.15702772, 3.64055523,
2.90839606, 2.73113438, 3.20470348, 2.90257889, 2.74926476,
3.01771222, 3.6733024 , 3.23281864, 2.9494011 , 2.60389528,
3.10953354, 3.57332479, 3.1524134 , 2.26163074, 2.91728413,
2.20966239, 2.98223944, 2.01496351, 2.84628572, 2.43019668,
2.25402643, 2.93603463, 3.32659615, 2.87724756, 2.70062668,
2.64132087, 3.11044313, 2.87561732, 2.83557766, 2.9362603 ,
3.12683797, 2.51938593, 3.21610253, 2.86114047, 2.75306947,
3.94966648, 2.83713933, 1.89228554, 3.20632912, 3.0719007 ,
2.63019275, 2.4460011 , 2.90544223, 3.02844496, 2.58570521,
3.62684363, 2.77781894, 2.92238191, 3.72694989, 2.82395087,
3.05560072, 4.17132476, 2.09270623, 2.31890666, 2.47596806]), array([ 9.46097371, 6.99000943, 1.55998418, 0.87795643, 0. ,
2.07062529, 2.71320664, 0.50973253, 1.88558577, 2.70210348,
4.59685102, 1.09056731, 13.31604717, 0.69859657, 5.94055188,
4.2053578 , 1.79242665, 20.11784151, 1.7508829 , 3.5800251 ,
1.32733654, 3.33298513, 1.38514602, 1.31689595, 0. ,
1.35567395, 1.0421509 , 1.12349835, 1.11971527, 10.38348323,
2.64431099, 1.49966545, 1.63039396, 1.1379443 , 3.10190789,
5.9204547 , 1.62808115, 6.52889285, 5.18621149, 0.54767118,
0.84675654, 1.48038026, 6.63302399, 2.09356976, 0.43613966,
1.06052981, 2.77475292, 0.78908126, 1.98430405, 1.99897832,
0.96871284, 0.49111883, 1.3647738 , 2.74746419, 4.38010144,
2.30535182, 8.40747165, 9.37764521, 1.29069196, 0.97636966,
1.30949723, 1.60204177, 0.32312057, 1.65198829, 2.06197958,
1.65989253, 7.41549836, 1.50296838, 1.14998958, 1.32581722,
2.57180347, 6.9277689 , 11.89223095, 1.47732397, 1.04290659]), array([0.84276739, 0.87016185, 0.95080395, 0.93782846, 0.98695416,
0.85498654, 0.90318239, 0.89016167, 0.87125045, 0.94503105,
0.93527443, 0.84821539, 1.0211858 , 0.92587957, 1.0349787 ,
0.93143892, 0.926617 , 0.81935567, 0.87586605, 0.82153776,
0.93245914, 0.90492154, 0.87747729, 0.88119853, 0.93011775,
0.85408237, 0.88658749, 0.92567075, 0.93951381, 0.85523744,
0.88020223, 0.84140003, 0.79814146, 0.86119662, 0.93937029,
0.89400338, 0.88839459, 0.98124687, 0.84325599, 0.96229458,
0.87385577, 0.88607039, 0.88599882, 0.78766865, 0.96588658,
0.98477064, 0.83079559, 0.92153698, 0.82755301, 0.81332964,
0.86809334, 0.94592841, 0.86325998, 0.89327895, 0.95944619,
0.87601818, 0.93183596, 0.95285935, 0.85426466, 0.88955188,
1.029276 , 0.884409 , 0.95901931, 0.822559 , 0.89900076,
0.81410874, 0.94220999, 0.83418973, 0.8967298 , 0.93522333,
0.89870992, 0.87563905, 0.9517751 , 0.9987204 , 0.88559478]), array([ 114, 159, 853, 225, 51, 225, 304, 179, 54, 129, 68,
70, 243, 86, 60, 258, 444, 61, 102, 227, 77, 139,
1392, 76, 91, 362, 93, 279, 83, 640, 253, 255, 551,
97, 50, 72, 68, 229, 78, 137, 92, 199, 165, 740,
66, 51, 851, 169, 308, 100, 347, 101, 693, 231, 250,
86, 351, 57, 204, 112, 75, 302, 81, 329, 73, 1890,
127, 56, 146, 586, 165, 97, 106, 69, 2322]), array([20417, 20372, 19678, 20306, 20480, 20306, 20227, 20352, 20477,
20402, 20463, 20461, 20288, 20445, 20471, 20273, 20087, 20470,
20429, 20304, 20454, 20392, 19139, 20455, 20440, 20169, 20438,
20252, 20448, 19891, 20278, 20276, 19980, 20434, 20481, 20459,
20463, 20302, 20453, 20394, 20439, 20332, 20366, 19791, 20465,
20480, 19680, 20362, 20223, 20431, 20184, 20430, 19838, 20300,
20281, 20445, 20180, 20474, 20327, 20419, 20456, 20229, 20450,
20202, 20458, 18641, 20404, 20475, 20385, 19945, 20366, 20434,
20425, 20462, 18209]))
The inventory can be mapped, and a graphic displaying all the statistics is also available.
inv.plot_map(scale=5, filter=2)
inv.plot(scale=5, filter=3)
/builds/heinzej/CrowdingIndex/spatiocoexistence/inventory/_plotting.py:239: RuntimeWarning: divide by zero encountered in log
np.log(k_ff[mask_abund]),
/builds/heinzej/CrowdingIndex/spatiocoexistence/inventory/_plotting.py:263: RuntimeWarning: divide by zero encountered in log
np.log(BA_ff[mask_abund]),
/builds/heinzej/CrowdingIndex/spatiocoexistence/inventory/_plotting.py:289: RuntimeWarning: divide by zero encountered in log
np.log(sorted_k_ff),
Total running time of the script: (0 minutes 3.117 seconds)

