Fvsfuels¶
-
class
fuels.Fvsfuels(variant)[source]¶ Bases:
objectA Fvsfuels object is used to calculate component fuels at the individual tree level using the Forest Vegetation Simulator. To create an instance of this class you need two items: a keyword file (.key) and tree list file (.tre) with the same prefix as the keyword file. If you don’t already have a tree list file then you can use
fuels.Inventoryclass to generate one from a .csv file exported from an FVS database.Parameters: variant (string) – FVS variant to be imported Example:
A basic example to extract live canopy biomass for individual trees during year of inventory
>>> from fuels import Fvsfuels >>> stand001 = Fvsfuels("iec") >>> stand001.set_keyword("/Users/standfire/test/example.key") TIMEINT not found in keyword file, default is 10 years >>> stand001.keywords {"TIMEINT": 10, "NUMCYCLE": 10, "INVYEAR": 2010, "SVS": 15, "FUELOUT": 1} >>> stand001.run_fvs()
Now we can write the trees data frame to disk
>>> stand001.save_trees_by_year(2010)
Note
The argument must match one of the available variants in the PyFVS module. See below for a list of all available variants.
Available FVS variants:
Variant Abbreviation Southeast Alaska and Coastal British Columbia ak Blue Mountains bmc Inland California and Southern Cascades cac Central Idaho cic Central Rockies crc Central States cs East Cascades ecc Eastern Montana emc Inland Empire iec Klamath Mountains ncc Kootenai, Kaniksu, and Tally Lake ktc Lake States ls Northeast ne Pacific Northwest Coast pnc Southern sn South Central Oregon and Northeast California soc Tetons ttc Utah utc Westside Cascades wcc Western Sierra Nevada wsc -
get_simulation_years()[source]¶ Returns a list of the simulated years
Returns: simulated year Return type: list of integers
-
get_snags(year)[source]¶ Returns pandas data frame of the snags by indexed year
Parameters: year (integer) – simulation year of the data frame to return Returns: data frame of snags at indexed year Return type: pandas dataframe Note
If a data frame for the specified year does not exist then a message will be printed to the console.
-
get_standid()[source]¶ Returns stand ID as defined in the keyword file of the class instance
Returns: stand ID value Return type: string
-
get_trees(year)[source]¶ Returns pandas data frame of the trees by indexed year
Parameters: year (integer) – simulation year of the data frame to return Returns: data frame of trees at indexed year Return type: pandas dataframe Note
If a data frame for the specified year does not exist then a message will be printed to the console.
-
run_fvs()[source]¶ This method runs an FVS simulation using the specified keyword file. The simulation will be paused at each time cycle as defined by the stop point codes and the time interval (TIMEINT from the keyword file). During the pause tree and snag data are collected and appended to the fuels attribute of the Fvsfuels object.
Example:
>>> from standfire.fuels import Fvsfuels >>> stand010 = Fvsfuels("iec") >>> stand010.set_keyword("/Users/standfire/example/test.key") >>> stand010.run_fvs() >>> stand010.fuels["trees"][2010] xloc yloc species dbh ht crd cratio crownwt0 crownwt1 ... 33.49 108.58 PIPO 19.43 68.31 8.77 25 33.46 4.3 24.3 90.4 PIPO 11.46 56.6 5.63 15 6.55 2.33 88.84 162.98 PIPO 18.63 67.76 9.48 45 75.88 6.89 ...
FVS return codes from open-fvs wiki. Printed to the console:
- -1: indicates that FVS has not been started
- 0: indicates that FVS is in a good running state
- 1: indicates that FVS has detected an error of some kind and should not be used until reset by specifying new input
- 2: indicates that FVS has finished processing all the stands; new input can be specified
-
save_all()[source]¶ Allows the user to create output files of trees and snags by year for all years simulated. Output file are in the .csv format and are named: <standid>_<trees/snags>_<year>.csv
-
save_snags_by_year(year)[source]¶ Writes snag data frame at indexed year to .csv in working directory
Parameters: year (integer) – simulated year
-
save_trees_by_year(year)[source]¶ Writes tree data frame at indexed year to .csv in working directory
Parameters: year (integer) – simulated year
-
set_dir(wdir)[source]¶ Sets the working directory of a Fvsfuels object
This method is called by
Fvsfuels.set_keyword(). Thus, the default working directory is the folder containing the specified keyword file. If you wish to store simulation outputs in a different directory then use this method to do so.Parameters: wdir (string) – path to desired directory Example:
>>> from fuels import Fvsfuels >>> test = Fvsfuels("emc") >>> test.set_keyword("/Users/standfire/test/example.key") >>> test.set_dir("/Users/standfire/outputs/")
-
set_keyword(keyfile)[source]¶ Sets the keyword file to be used in the FVS simulation
This method will initalize an FVS simulation by registering the specified keyword file (.key) with FVS. The working directory of a Fvsfuels object will be set to the folder containing the keyword file. You can manually change the working directory with
Fvsfuels.set_dir(). This function will also call private methods in this class to extract information from the keyword file and set class fields accordingly for use in other methods.Parameters: keyfile (string) – path/to/keyword_file. This must have a .key extension Example:
>>> from fuels import Fvsfuels >>> test = Fvsfuels("iec") >>> test.set_keyword("/Users/standfire/test/example.key")
-
set_stop_point(code=1, year=-1)[source]¶ Function to set the FVS stop point code and year. This causes FVS to pause at points defined by the stop point code and year.
Parameters: - code (integer) – stop point code (default=1)
- year (integer) – stop point year (default=-1)
Note
year=0 means never stop and year=-1 means stop every cycle
stop point code Definition 0 Never stop -1 Stop at every location 1 Stop just before first call to Event Monitor 2 Stop just after first call to Event Monitor 3 Stop just before second call to Event Monitor 4 Stop just after second call to Event Monitor 5 Stop after growth and mort has been computed, but before applied 6 Stop just before the ESTAB routine is called
-