From 1fc4afe6ef63372f497b98b67801fabf2756b458 Mon Sep 17 00:00:00 2001 From: marcosdanieldasilva Date: Mon, 6 May 2024 15:14:47 -0300 Subject: [PATCH] cubage hc acrescentado e nff corrigido --- src/cubage.jl | 14 ++++++++------ src/rascunho.jl | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/cubage.jl b/src/cubage.jl index 242df01..2134eff 100644 --- a/src/cubage.jl +++ b/src/cubage.jl @@ -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): @@ -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) @@ -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 @@ -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 diff --git a/src/rascunho.jl b/src/rascunho.jl index a587d24..aba9bd8 100644 --- a/src/rascunho.jl +++ b/src/rascunho.jl @@ -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)