Skip to content

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.

Example of assortments table

Product Length min (m) Length max (m) D min (cm) Loss (cm) Priority
Prod. 1 10 10 12 0.5 1
Prod. 2 2 2 8 0.5 2
Prod. 3 1 1.5 2 0.5 3

*The column order must be followed.

Class Functions

functions and parameters
  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)

  1. 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. If stump==None, it defaults to 0.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.

  2. 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. If stump==None, it defaults to 0.1.

  3. 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.

Parameters 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

taper_functions_example.py
1
2
from fptools.assortments import Assortments #(1)
import pandas as pd #(2)

  1. Import Assortments class.
  2. Import pandas for data manipulation.

Create a variable for the Volumetrics Class

taper_functions_example.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
assortments_df = pd.read_csv(r'C:\Your\path\csv_tree_cubage_file.csv') #(1)
inventory_df = pd.read_csv(r'C:\Your\path\csv_tree_cubage_file.csv') #(2)

Prod = Assortments(assortments_df) #(3)


assortments = Prod.get_assortments('kozak', r"D:\Your\path\for\taper_functions_coefficients.json",
                                   inventory_df, "DAP", "HT") #(4)
taper_volumes = Prod.get_taper_volumes('bi', r"D:\Your\path\for\taper_functions_coefficients.json",
                                       inventario, "DAP", "HT", .9) #(5)             
volumes = Prod.get_volumes('meyer', r"D:\Your\path\for\taper_functions_coefficients.json",
                           inventario, "DAP", "HT", .85) #(6)

  1. Load your assortments df from a csv file.
  2. Load your inventory df from a csv file.
  3. Create the variable Prod containing the Assortments class and using the assortments_df dataframe as products.
  4. Calculate assortments for each tree in the inventory_df using the kozak model, the DAP column for DBH values and the HT column for the tree height values.
  5. Calculate volumes with integration of bi function for each tree in the inventory_df using the bi model, the DAP column for DBH values and the HT column for the tree height values. Also uses a bark factor of 90%.
  6. Calculate volumes with volumetric function for each tree in the inventory_df using the meyer model, the DAP column for DBH values and the HT column for the tree height values. Also uses a bark factor of 85%.