Skip to content

Commit

Permalink
cubage hc acrescentado e nff corrigido
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosdanieldasilva committed May 6, 2024
1 parent 668a868 commit 1fc4afe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/cubage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Natural Form Factor (nff):
- Cylinder Vol 0,1 = volume of a cylinder with height equal to the total height of the tree and diameter taken at 1/10 of the total height.
Interpolate diameter at a given height using linear interpolation.
"""
@inline natural_form_factor(vt::Real, ht::Real, h::Vector{<:Real}, d::Vector{<:Real}) :: Float64 = vt / cylinder_volume(h[end], _diameter_interpolation(ht * 0.1, d, h))
@inline natural_form_factor(vt::Real, ht::Real, h::Vector{<:Real}, d::Vector{<:Real}) :: Float64 = vt / cylinder_volume(h[end], _diameter_interpolation(ht * 0.1, h, d))

"""
Form Quotient (qf):
Expand Down Expand Up @@ -125,11 +125,12 @@ function cubage(method::Type{<:CubingMethod}, h::Vector{<:Real}, d::Vector{<:Rea
# diameter at basal height and total height of the tree
dbh = d[idx]
ht = h[end]
hc = h[end - 1]
# Calculate volumes
v0 = cylinder_volume(h[begin], d[begin])
vi = bole_volume(method, h, d)
vn = cone_volume(ht - h[end - 1], d[end - 1])
vt = v0 + vi + vn
vc = bole_volume(method, h, d)
vn = cone_volume(ht - hc, d[end - 1])
vt = v0 + vc + vn
# Calculate the Form Factors
aff = artificial_form_factor(vt, ht, dbh)
nff = natural_form_factor(vt, ht, h, d)
Expand All @@ -138,10 +139,11 @@ function cubage(method::Type{<:CubingMethod}, h::Vector{<:Real}, d::Vector{<:Rea
DataFrame(
vt = vt,
v0 = v0,
vi = vi,
vc = vc,
vn = vn,
dbh = dbh,
ht = ht,
hc = hc,
aff = aff,
nff = nff,
qf = qf
Expand All @@ -159,7 +161,7 @@ function cubage(method::Type{<:CubingMethod}, h::Vector{<:Real}, d::Vector{<:Rea
# cone volume without bark
insertcols!(cubage_table, :vnwb => cubage_table.vn .* cubage_table.k.^2)
# bole volume without bark
insertcols!(cubage_table, :viwb => cubage_table.vi .* cubage_table.k.^2)
insertcols!(cubage_table, :vcwb => cubage_table.vc .* cubage_table.k.^2)
return cubage_table
end

Expand Down
14 changes: 14 additions & 0 deletions src/rascunho.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
using ForestMensuration, CSV, DataFrames



df = CSV.read("C:\\Users\\marco\\OneDrive\\Documents\\Programação\\dados_CSV\\exemplo-hipso.csv", DataFrame)

cub_data = CSV.read(
"C:\\Users\\marco\\OneDrive\\Documents\\Programação\\dados_CSV\\exemplo-cubagem-2.csv",
DataFrame
)

cb = cubage(Smalian, :arvore, :h_d, :d_h, :casca, cub_data)


gdf = groupby(cub_data, :arvore)

ForestMensuration._diameter_interpolation(gdf[1].h_d[end] * 0.1, gdf[1].h_d*1, gdf[1].d_h*1)

reg = regression(:ht, :dap, df)

reg2 = regression(:ht, :dap, df, best=5)
Expand Down

0 comments on commit 1fc4afe

Please sign in to comment.