Assortments
Warning
This library is under development, none of the presented solutions are available for download.
Obtain the products generated by the forest inventory based on a product table. Use fitted taper functions to estimate commercial and non-commercial volume generated by the forest. Estimate volumes using fitted volumetric equations.
Class Parameters
Assortments(df, assortments_priority=None)
Parameters | Description |
---|---|
df | The dataframe containing the assortments data. |
assortments_priority | (Optional) The name of the column who defines the assortments priority. If None , uses the default order from the dataframe. |
Class Functions
Assortments.get_assortments(model, model_path, trees_df, tree_dbh, tree_height,
stump=0.1, initial_height=None)#(1)!
Assortments.get_taper_volumes(model, model_path, trees_df, tree_dbh,
tree_height, bark_factor=None, stump=0.1)#(2)!
Assortments.get_volumes(model, model_path, trees_df, tree_dbh,
tree_height, bark_factor=None)#(3)!
-
model = The name of the taper function or 'ann' to be used to calculate the assortments.
model_path = Path to the.json
file containing the coefficients of the fitted models or the.pkl
file containing the fitted artificial neural network.
trees_df = Pandas DataFrame containing the inventory for which the assortments should be calculated.
tree_dbh = The name of the column containing the diameter at breast height (DBH) values in centimeters.
tree_height = The name of the column containing the total height values of the trees in meters.
stump = (Optional) Stump height value (meters) to be considered in the assortment calculation. Ifstump==None
, it defaults to0.1
.
initial_height = (Optional) Height (meters) at which the products begin to be generated. Useful for cases where the base of the tree was damaged by fire or used for resin extraction. -
model = The name of the taper function or taper 'ann' to be used to calculate the volume.
model_path = Path to the.json
file containing the coefficients of the fitted models or the.pkl
file containing the fitted artificial neural network.
trees_df = Pandas DataFrame containing the inventory for which the volumes should be calculated.
tree_dbh = The name of the column containing the diameter at breast height (DBH) values in centimeters.
tree_height = The name of the column containing the total height values of the trees in meters.
bark_factor = (Optional) Value of the bark factor to be used to calculate volumes without bark.
stump = (Optional) Stump height value (meters) to be considered in the volumes calculation. Ifstump==None
, it defaults to0.1
. -
model = The name of the volumetric function or volumetric 'ann' to be used to calculate the volume.
model_path = Path to the.json
file containing the coefficients of the fitted models or the.pkl
file containing the fitted artificial neural network.
trees_df = Pandas DataFrame containing the inventory for which the volumes should be calculated.
tree_dbh = The name of the column containing the diameter at breast height (DBH) values in centimeters.
tree_height = The name of the column containing the total height values of the trees in meters.
bark_factor = (Optional) Value of the bark factor to be used to calculate volumes without bark.
Methods | Description |
---|---|
.get_assortments() | Returns the trees_df dataframe with additional columns indicating the number of products generated for each assortment, as well as the volume generated for each assortment in each tree. Calculates also the comercial volume, the total volume of the tree and also the wasted volume. |
.get_taper_volumes() | Returns the trees_df with the volumes calculated based on the integration of taper functions. It calculates the total volume with bark and without bark. |
.get_volumes() | Returns the trees_df with the volumes calculated based on the fitted volumetric functions. It calculates the total volume with bark and without bark. |
Example Usage
Consider a forest inventory dataset composed of 50 Eucalyptus trees, for which diameter at breast height (DBH) and total height were measured.
First 5 rows of the file:
Fazenda | Árvore | DAP (cm) | HT (m) |
---|---|---|---|
Fazenda 1 | 1 | 24.8 | 28.0 |
Fazenda 1 | 2 | 21.2 | 27.1 |
Fazenda 1 | 3 | 26.8 | 37.8 |
Fazenda 1 | 4 | 37.6 | 43.0 |
Fazenda 1 | 5 | 35.7 | 42.8 |
For this module to work, it is necessary to specify a DataFrame containing the description of the products to be extracted from each tree. This table must include, for each product, the following information: product name, minimum and maximum length, minimum diameter, cutting loss (caused by the equipment saw), and optionally, a column defining the extraction priority for each product.
Example of assortments table
Product | Length min (m) | Length max (m) | D min (cm) | Loss (cm) | Priority |
---|---|---|---|---|---|
Prod. 1 | 4.5 | 5 | 15 | 0.5 | 1 |
Prod. 2 | 2 | 2 | 8 | 0.5 | 2 |
Prod. 3 | 1 | 1 | 3 | 0.5 | 3 |
The column order must be followed.
taper_functions_example.py | |
---|---|
- Import
Assortments
class. - Import
pandas
for data manipulation.
For this example, we will use the equations fitted for the iterator "Fazenda 1". Thus, we will filter the data to calculate products only for the trees from "Fazenda 1". We will use the files generated by the Volumetrics module.
Download the file taper_functions_coefficients_Fazenda 1.json.
Download the file volumetrics_functions_coefficients_Fazenda 1.json.
- Loads the
assortments_df
DataFrame from anxlsx
file. - Loads the
inventory_df
DataFrame from anxlsx
file. - Filters the data to include only rows where the
Fazenda
column is equal toFazenda 1
. - Creates the
Prod
variable containing theAssortments
class using theassortments_df
DataFrame as the products. - Calculates assortments for each tree in the
inventory_df
using thekozak
model, theDAP
column for DBH values, and theHT
column for tree height values, storing the result in theassortments
variable. - Calculates volumes by integrating the
bi
function for each tree in theinventory_df
using thebi
model, theDAP
column for DBH values, and theHT
column for tree height values. A bark factor of90%
is also applied. - Calculates volumes using the volumetric function for each tree in the
inventory_df
using themeyer
model, theDAP
column for DBH values, and theHT
column for tree height values. A bark factor of85%
is also applied.
Outputs
Tables
assortments
(1)
- Initial DataFrame with the following additional columns:
For each product defined in theassortments_df
table, two columns will be created: one indicating the number of products extracted per tree and another showing the total volume generated (in cubic meters) for that product.
Additionally, the DataFrame will include the columnscommercial_volume
,tree_volume
, andwasted_volume
, which represent, respectively, the utilized commercial volume, the total tree volume, and the volume of wasted wood.
Fazenda | Árvore | DAP | HT | Prod. 1_quantity | Prod. 1_volume | Prod. 2_quantity | Prod. 2_volume | Prod. 3_quantity | Prod. 3_volume | commercial_volume | tree_volume | wasted_volume |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Fazenda 1 | 1 | 24.84076433 | 28 | 2 | 0.36529298 | 5 | 0.160465831 | 6 | 0.022446226 | 0.548205036 | 0.548793726 | 0.00058869 |
Fazenda 1 | 2 | 21.17834395 | 27.1 | 1 | 0.15662905 | 7 | 0.205798888 | 5 | 0.016228224 | 0.378656162 | 0.379971069 | 0.001314907 |
Fazenda 1 | 3 | 26.81528662 | 37.8 | 4 | 0.738422477 | 5 | 0.129884459 | 5 | 0.016047425 | 0.884354362 | 0.88558894 | 0.001234578 |
Fazenda 1 | 4 | 37.57961783 | 43 | 6 | 1.899253966 | 3 | 0.090801352 | 5 | 0.021413892 | 2.01146921 | 2.01247906 | 0.00100985 |
Fazenda 1 | 5 | 35.66878981 | 42.8 | 6 | 1.705021305 | 3 | 0.07966354 | 5 | 0.018106349 | 1.802791194 | 1.803503982 | 0.000712789 |
taper_volumes
(1)
- Initial DataFrame with the following additional columns:
Tree_volume
: Total tree volume calculated by integrating the specified taper function.
Tree_volume_without_bark
:Tree_volume
multiplied by the specified bark factor.
Fazenda | Árvore | DAP | HT | Tree_volume | Tree_volume_without_bark |
---|---|---|---|---|---|
Fazenda 1 | 1 | 24.84076433 | 28 | 0.545157869 | 0.490642083 |
Fazenda 1 | 2 | 21.17834395 | 27.1 | 0.38299769 | 0.344697921 |
Fazenda 1 | 3 | 26.81528662 | 37.8 | 0.870697291 | 0.783627562 |
Fazenda 1 | 4 | 37.57961783 | 43 | 2.005436616 | 1.804892954 |
Fazenda 1 | 5 | 35.66878981 | 42.8 | 1.790646854 | 1.611582169 |
volumes
(1)
- Initial DataFrame with the following additional columns:
Tree_volume
: Total tree volume calculated using the specified volumetric equation.
Tree_volume_without_bark
:Tree_volume
multiplied by the specified bark factor.
Fazenda | Árvore | DAP | HT | Tree_volume | Tree_volume_without_bark |
---|---|---|---|---|---|
Fazenda 1 | 1 | 24.84076433 | 28 | 0.545157869 | 0.490642083 |
Fazenda 1 | 2 | 21.17834395 | 27.1 | 0.38299769 | 0.344697921 |
Fazenda 1 | 3 | 26.81528662 | 37.8 | 0.870697291 | 0.783627562 |
Fazenda 1 | 4 | 37.57961783 | 43 | 2.005436616 | 1.804892954 |
Fazenda 1 | 5 | 35.66878981 | 42.8 | 1.790646854 | 1.611582169 |
If the user wants to use one of the neural network models trained for each function, simply replace the model name with ann
and specify the directory of the .pkl
file containing the parameters of the trained neural network.
Download the file taper_model_ann_Fazenda 1.pkl.
Download the file volumetric_ann_Fazenda 1.pkl.
- Calculates assortments for each tree in the
inventory_df
using artificial neural networks, theDAP
column for DBH values, and theHT
column for tree height values, saving the result in theassortments
variable. - Calculates volumes by integrating the artificial neural network for each tree in the
inventory_df
, using theDAP
column for DBH values and theHT
column for tree height values. A bark factor of90%
is also applied. - Calculates volumes using a volumetric artificial neural network for each tree in the
inventory_df
, using theDAP
column for DBH values and theHT
column for tree height values. A bark factor of85%
is also applied.