treetopper mods¶
treetopper.blank_sheet module¶
To create a formatted blank CSV or Excel inventory sheet, call the blank_sheet module from the terminal and run throught the prompts
python -m treetopper.blank_sheet
- treetopper.blank_sheet.create_blank_csv(directory: Optional[str] = None, full_cruise=False)¶
- treetopper.blank_sheet.create_blank_excel(directory: Optional[str] = None, full_cruise=False)¶
treetopper.fvs module¶
- class treetopper.fvs.FVS¶
Bases:
object
The FVS class will create FVS-formatted databases for use in FVS. FVS is a software made by the US Forest Service to run models, inventories and simulations on different forest stands. The three types of databases the FVS class creates are Microsoft Access, Microsoft Excel and SQLite
If you would like a blank database to manually input your data, you can call the fvs module from the terminal and run through the prompts
python -m treetopper.fvs
If you would like to create the databases from a Stand Class, you can instantiate the FVS class and call the fvs.set_stand method. There are seven required arguments, these are data that the FVS software needs for its models, they include
stand (the Stand Class) variant (str) [These are two-letter acronyms for different eco-regions throughout the US] forest_code (int) [This is the forest code for the closest national forest to your stand] region (int) [This is the region code for the forest service region your stand is in] stand_age (int) [The approximate age of the stand] site_species (str) [The species acronym for the species being used to measure site index] site_index (int) [The site index of the stand]
kwargs can be used to add additional data to your stand. To see the list of the other stand data call the fvs.show_stand_args method, use this console printout to find the index of your desired argument(s), then use the list index to set your argument to fill in the kwargs, for example fvs.set_stand(… fvs.stand_args[4]=22)
After setting the stand in the FVS class, you can then create or append your databases by calling the database-specific methods listed above
- access_db(filename: str, directory: Optional[str] = None, blank_db: bool = False)¶
Creates or updates an FVS-formatted Microsoft Access Database (.accdb)
- excel_db(filename: str, directory: Optional[str] = None, blank_db: bool = False)¶
Creates or updates an FVS-formatted Microsoft Excel Database (.xlsx)
- set_stand(stand, variant: str, forest_code: int, region: int, stand_age: int, site_species: str, site_index: int, **kwargs)¶
Extracts the stand and tree data from the Stand class and updates the stand_fvs and tree_fvs dictionaries which will be used to create or update the databases
- show_stand_args()¶
Shows the optional stand data and their indices within self.stand_args
- sqlite_db(filename: str, directory: Optional[str] = None, blank_db: bool = False)¶
Creates or updates an FVS-formatted SQLite Database (.db)
treetopper.log module¶
- class treetopper.log.Log(timber, stem_height: int, length: int, defect_pct: int = 0, grade: Optional[str] = None)¶
Bases:
object
Log Class calculates the volume of an individual log from the Timber Classes. If coming from the TimberQuick class, it will also calculate the grade of the log
treetopper.plot module¶
- class treetopper.plot.Plot¶
Bases:
object
The Plot Class is an individual plot within a Stand’s Inventory. It holds Timber Classes of the trees within the plot and runs calculations and statistics from those tree’s metrics.
For inventories, this class is meant to be added to the Stand Class using the Stand Class method of add_plot
- add_tree(timber)¶
The timber argument should be one of the two Timber Classes (TimberQuick and/or TimberFull). The Timber Class is added to the plot’s trees list and plot calculations and statistics are re-run
treetopper.stand module¶
- class treetopper.stand.Stand(name: str, plot_factor: float, acres: Optional[float] = None, inventory_date: Optional[str] = None)¶
Bases:
object
The Stand Class represents a stand of timber that has had an inventory conducted on it. It should made up of plots (Plot Class) which contain trees (Timber Classes).
The Stand class will run calculations and statistics of the current stand conditions and it will run calculations of the log merchantabilty for three metrics: logs per acre, log board feet per acre, and log cubic feet per acre, based on log grades, log length ranges and species.
- add_plot(plot: treetopper.plot.Plot)¶
Adds a plot to the stand’s plots list and re-runs the calculations and statistics of the stand. plot argument needs to be the a Plot Class
- console_report()¶
Prints a console-formatted string of the complete stand report
- get_console_report_text()¶
Returns a console-formatted string of the complete stand report
- get_logs_table_text()¶
Returns a console-formatted string of stand logs data
- get_stand_table_text()¶
Returns a console-formatted string of current stand conditions
- get_stats_table_text()¶
Returns and console-formatted string of stand stand statistics
- import_sheet_full(file_path: str)¶
Imports tree and plot data from a CSV or XLSX file for a full cruise and adds that data to the stand
- import_sheet_quick(file_path: str)¶
Imports tree and plot data from a CSV or XLSX file for a quick cruise and adds that data to the stand
- pdf_report(filename: str, directory: Optional[str] = None, start_file_upon_creation: bool = False)¶
Exports a pdf of the complete stand report to a user specified directory or if directory is None, to the current working directory. Will open the created pdf report if start_file_upon_creation is True
- table_to_csv(filename: str, directory: Optional[str] = None)¶
Creates or appends a CSV file with tree data from self.table_data
- table_to_excel(filename: str, directory: Optional[str] = None)¶
Creates or appends an Excel file with tree data from self.table_data
treetopper.thin module¶
- class treetopper.thin.Thin(stand, target_density: int, species_to_cut: list, min_dbh_to_cut: int, max_dbh_to_cut: int)¶
Bases:
object
The Thin Class is the parent class of the three thinning child classes: ThinTPA, ThinBA, and ThinRD.
The thinning classes create a deepcopy of the stand class so as not to disrupt any of the tree information.
The thinning classes start to thin the stand by getting a dictionary of whole-number diameters based on species, these contain per-diameter metrics such as tpa, ba_ac, rd_ac, bf_ac…, and these metrics, other than tpa, also have a corresponding metric per tree value, by dividing the per-diameter metric by the per-diameter tpa.
The thinnings then calculate a harvest-ratio to lower the stand’s density to the target density, in accordance to the species and diameter limitations (if any). The harvest ratio is used to calculate the removal and residual per-diameter TPAs, which are then used to calculate the other removal and residual per-diameter metrics by multiplying the respective TPAs by the per-diameter metric per tree values
- console_report()¶
Prints a console-formatted string of the thinning report
- get_console_report_text()¶
Returns a console-formatted string of the thinning report
- pdf_report(filename: str, directory: Optional[str] = None, start_file_upon_creation: bool = False)¶
Exports a pdf of the thinning report to a user specified directory or if directory is None, to the current working directory
- class treetopper.thin.ThinBA(stand, target_density: int, species_to_cut: list = 'all', min_dbh_to_cut: int = 0, max_dbh_to_cut: int = 999)¶
Bases:
treetopper.thin.Thin
Thin by Basal Area per Acre
- class treetopper.thin.ThinRD(stand, target_density: int, species_to_cut: list = 'all', min_dbh_to_cut: int = 0, max_dbh_to_cut: int = 999)¶
Bases:
treetopper.thin.Thin
Thin by Relative Density per Acre
- class treetopper.thin.ThinTPA(stand, target_density: int, species_to_cut: list = 'all', min_dbh_to_cut: int = 0, max_dbh_to_cut: int = 999)¶
Bases:
treetopper.thin.Thin
Thin by Trees per Acre
treetopper.timber module¶
- class treetopper.timber.TimberFull(plot_factor: float, species: str, dbh: float, total_height: int)¶
Bases:
object
TimberFull is a class that will cruise a tree based on it’s based on the user-cruised logs. These logs can be manually added to the class using the add_log method. Required arguments for add_log are stem height (int), log length (int), log grade (str), and log defect (int). Log defect should be the whole number value of the estimated percent defect 10% = 10.
Like TimberQuick, TimberFull uses stem-taper equations from Czaplewski, Kozak, or Wensel (depending on species) to calculate the DIB (diameter inside bark) at any stem height.
TimberFull will instantiate the tree with common individual and per acre metrics based on the input args.
When the user adds a log using the add_log method, the log metrics are sent to the Log Class, to which their volumes in Board Feet (using Scribner Coefficients based on Log Length and top DIB) and Cubic Feet (based on the Two-End Conic Cubic Foot Rule) are calculated.
For inventories, this class is meant to be added to the Plot Class using the Plot Class method of add_tree
- add_log(stem_height, length, grade, defect)¶
Adds Log Class to the logs dictionary of TimberFull and recalculates the tree’s volumes and volume-related metrics
- get_any_dib(stem_height)¶
Returns the diameter inside bark (DIB) at any given stem height
- class treetopper.timber.TimberQuick(plot_factor: float, species: str, dbh: float, total_height: int, preferred_log_length: int = 40, minimum_log_length: int = 16)¶
Bases:
object
TimberQuick is a class that will virtually cruise a tree based on it’s species, DBH, total height and plot factor. For fixed-area plots use the negative inverse of the plot size (1/30th ac = -30), for variable-area plots use the Basal Area Factor (BAF) (40 BAF = 40).
Preferred Log Length and Minimum Log Length are needed but set at the default industry standard of 40 foot preferred and 16 foot minimum.
TimberQuick uses stem-taper equations from Czaplewski, Kozak, or Wensel (depending on species) to calculate the DIB (diameter inside bark) at any stem height.
TimberQuick will instantiate the tree with common individual and per acre metrics based on the input args.
To cruise the tree, first TimberQuick determines the merchantable DIB of the tree, this is calculated from 40% of the DIB at a stem height of 17 feet (the FORM height). This is industry standard.
TimberQuick then correlates that Merch DIB to a merchantable height. The tree is then split up into logs, based on this Merch Height with priority given to the preferred log length and if preferred log length cannot be achieved, then if the remaining length up to Merch Height is greater than or equal to the minimum log length, that final log is added.
Log metrics are sent to the Log Class, to which their volumes in Board Feet (using Scribner Coefficients based on Log Length and top DIB) and Cubic Feet (based on the Two-End Conic Cubic Foot Rule). Log grades are determined by species, minimum log lengths and minimum top DIBs set forth by the Official Rules for the Log Scaling and Grading Bureaus. Log defect is always 0%
For inventories, this class is meant to be added to the Plot Class using the Plot Class method of add_tree
- get_any_dib(stem_height)¶
Returns the diameter inside bark (DIB) at any given stem height