-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path4b_allometry_sampling.R
201 lines (162 loc) · 7.74 KB
/
4b_allometry_sampling.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# To be used later for the conversion of diameter reconstruction to biomass
# Sampling the MCMC output generated by PEcAn to obtain ranges of possible biomass as opposed to a single line
# As new sites and species are added, new allometry equations will need to be developed
allom.base <- "allometries"
#path consistent with WIKI
# creating an object to serve as a home for all of the allometry samples we will pull from the individual species mcmc
allometries<- list()
# Sampling 500 random rows from the last 5000 runs of the MCMC
# need to not pull rows with a negative mu1
# loading in the MCMC data from PEcAn for PIPO
load(file.path(allom.base, "Allom.PIPO.2.Rdata"))
allometries[["PIPO"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$PIPO)
# loading in PSME pecan mcmc runs and making a PSME section within the allometries list. This will be repeate for all species present in the DOE study.
load(file.path(allom.base, "Allom.PSME.2.Rdata"))
allometries[["PSME"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$PSME)
# loading in ABCO pecan mcmc runs
load(file.path(allom.base, "Allom.ABCO.2.Rdata"))
allometries[["ABCO"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$ABCO)
# loading in general spruce pecan mcmc runs
load(file.path(allom.base, "Allom.PICEA.2.Rdata"))
allometries[["picea.sp"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$picea.sp)
# loading in general pine pecan mcmc runs
load(file.path(allom.base, "Allom.PINUS.2.Rdata"))
allometries[["pinus.sp"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$pinus.sp)
# loading in general fir pecan mcmc runs
load(file.path(allom.base, "Allom.ABIES.2.Rdata"))
allometries[["abies.sp"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$abies.sp)
# loading in ACRU pecan mcmc runs
load(file.path(allom.base, "Allom.ACRU.2.Rdata"))
allometries[["ACRU"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$ACRU)
# loading in ACSA pecan mcmc runs
load(file.path(allom.base, "Allom.ACSA.2.Rdata"))
allometries[["ACSA"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$ACSA)
# loading in Silver Maple pecan mcmc runs
load(file.path(allom.base, "Allom.ACSA2.2.Rdata"))
allometries[["ACSAC"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$ACSAC)
# loading in BEPA pecan mcmc runs
load(file.path(allom.base, "Allom.BEPA.2.Rdata"))
allometries[["BEPA"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$BEPA)
# loading in early.hardwood pecan mcmc runs
load(file.path(allom.base, "Allom.BEPA.2.Rdata"))
allometries[["e.hard"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$e.hard)
# loading in FAGR pecan mcmc runs
load(file.path(allom.base, "Allom.BEPA.2.Rdata"))
allometries[["FAGR"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$FAGR)
# loading in FRAM pecan mcmc runs
load(file.path(allom.base, "Allom.BEPA.2.Rdata"))
allometries[["FRAM"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$FRAM)
# loading in late.con pecan mcmc runs
load(file.path(allom.base, "Allom.late.con.2.Rdata"))
allometries[["late.con"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$late.con)
# loading in late.hardwood pecan mcmc runs
load(file.path(allom.base, "Allom.late.hardwood.2.Rdata"))
allometries[["late.hard"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$late.hard)
# loading in LITU pecan mcmc runs
load(file.path(allom.base, "Allom.LITU.2.Rdata"))
allometries[["LITU"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$LITU)
# loading in mid.con pecan mcmc runs
load(file.path(allom.base, "Allom.mid.con.2.Rdata"))
allometries[["mid.con"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$mid.con)
# loading in north.mid.hardwood pecan mcmc runs
load(file.path(allom.base, "Allom.n.mid.hardwood.2.Rdata"))
allometries[["north.mid.hardwood"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$north.mid.hardwood)
# loading in n.pine pecan mcmc runs
load(file.path(allom.base, "Allom.n.pine.2.Rdata"))
allometries[["n.pine"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$n.pine)
# loading in NYSY pecan mcmc runs
load(file.path(allom.base, "Allom.NYSY.2.Rdata"))
allometries[["NYSY"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$NYSY)
# loading in PIST pecan mcmc runs
load(file.path(allom.base, "Allom.PIST.2.Rdata"))
allometries[["PIST"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$PIST)
# loading in POGR pecan mcmc runs
load(file.path(allom.base, "Allom.POGR.2.Rdata"))
allometries[["POGR"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$POGR)
# loading in POTR pecan mcmc runs
load(file.path(allom.base, "Allom.POTR.2.Rdata"))
allometries[["POTR"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$POTR)
# loading in QUAL pecan mcmc runs
load(file.path(allom.base, "Allom.QUAL.2.Rdata"))
allometries[["QUAL"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$QUAL)
# loading in QURU pecan mcmc runs
load(file.path(allom.base, "Allom.QURU.2.Rdata"))
allometries[["QURU"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$QURU)
#loading in QUVE pecan mcmc runs
load(file.path(allom.base, "Allom.QUVE.2.Rdata"))
allometries[["QUVE"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$QUVE)
# loading in so.mid.hardwood pecan mcmc runs
load(file.path(allom.base, "Allom.s.mid.hardwood.2.Rdata"))
allometries[["so.mid.hardwood"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$so.mid.hardwood)
# loading in southern pine pecan mcmc runs
load(file.path(allom.base, "Allom.s.pine.2.Rdata"))
allometries[["s.pine"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$s.pine)
# loading in SAAL pecan mcmc runs
load(file.path(allom.base, "Allom.SAAL.2.Rdata"))
allometries[["SAAL"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$SAAL)
# loading in TIAM pecan mcmc runs
load(file.path(allom.base, "Allom.TIAM.2.Rdata"))
allometries[["TIAM"]] <- mc[[3]][sample(which(mc[[3]][,"mu1"]>=0), size=500, replace=T),]
summary(allometries)
summary(allometries$TIAM)
##Instead of these repeated code fragments can we have a list containing all the names of the the species and then loop through all the
#save the list as ______ to draw from later when we convert diameter reconstructions into biomass
save(allometries, file="processed_data/allometries_list.Rdata")