running in peter gould, pacific northwest research station growth-model user group meeting, june 2,...

14
Running in Peter Gould, Pacific Northwest Research Station Growth-Model User Group Meeting, June 2, 2010

Upload: milton-horton

Post on 03-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

  • Running

    in

    Peter Gould, Pacific Northwest Research StationGrowth-Model User Group Meeting, June 2, 2010

  • Acknowledgements I borrowed previous work on the implementation of the ORGANON dlls in Excel from Mark Hanus and Sean Garber.

    Mark Hanus helped troubleshoot problems with ORGANON8.4.

    David Hann and other ORGANON developers for providing DLLs.

  • Why run ORGANON in R? R users dont need to switch environments or interfaces to run different programs (on cutting and pasting).

    Can combine projections and summaries.

    Can automate processing (1 or 100,000 stands).

  • How to connect to ORGANONDLL (Dynamic-Link Library): a program that can be called by another program. Often used to create, manipulate, and update variables.

    ORGANON has three dlls:ORGVOL.dllORGEDIT.dllORGRUN.dll

  • Can we call the dlls directly from R?(Yes, in theory)Should I be worried?R sees the dll!R sees the functions in the dll!!R CRASHES!!!

  • Alternative Approach ORGANON can be run in MS EXCEL using the dlls.Mark Hanus did the original coding in VB. Sean Garber added more features I updated it for Version 8.4 (with help from Mark Hanus) and added features for input/output.

    R can control EXCEL using the rcom package (Thomas Baier (2008). rcom: R COM Client Interface and internal COM Server. R package version 2.0-4.)

    runOrg8.4 runs ORGANON via EXCEL.

  • What do you need? ORGANON DLLs and RUN_ORGANON8.4.xls need to be installed in: C:\Program Files\ORGANON\DLL

    R needs to be installed (Im using version 2.9.1) AND the rcom package.

    Excel need to be installed and macros enabled (Im using Excel2007).

    The runOrg8.4 function needs to be loaded.

  • Input FormatsOptional: HT, CR

    Tree list (use the exact variable names)

  • Input FormatsHeader info (use the exact variable names)

    Optional: USEGEN, DBHGAIN, HTGAIN, USESNC, RETAINYRS.

  • Process for runOrg8.4Opens the Excel workbook (set to be invisible). Loops through the standsUpdates header informationPastes the input treelist into the worksheetRuns ORGEDIT (adds heights, crown ratios, etc.)Runs ORGRUN (the actual projections)Copies output back to RCloses Excel and returns to R

  • Run the function and output

  • Example: Two stands, 30 plots / stand , 10 trees / plot, projected for 10 cycles (50 yrs). Elapse time: 5.5 seconds

  • The Excel WorkbookDouble-click above to open and then save with this name and path:

    C:\Program Files\ORGANON\DLL\RUN_ORGANON8.4.xls

    Use Excel1997-2003 format.

    INP header

    Species->DFTFPPSPICWHRCPYMDGCTACLBLWOBORAPDWI

    Height Calibration111111111111111111

    Crown calibration111111111111111111

    Diameter Calibration111111111111111111

    DF Site Index125This spreadsheet expects to find the DLL's in the directory C:\Program Files\ORGANON

    OC Site Index111.9430007935If you wish to change this directory select Tools>Macro>Visual Basic Editor and edit the path to the DLL's

    DF SDI0In the Module ORGANON

    TF SDI0Merchandising Specifications

    OC SDI0Cubic Foot Volume

    VERSION3Stump Height0

    N_POINTS1Top Diameter0

    Even Aged?1

    BH_AGE80Board Foot Volume

    STAND_AGE1015Log length32

    Cycles To Grow1Min Log length8

    CYCLES_GROWN1Top Diameter5

    MORTALITY1Stump height0.5

    Radial Growth?0Trim Allowance8

    Tripling0

    use Height Calibr.1

    use Diameter Calibr.1

    use Crown calibr.1

    USE GENETICS?0

    DBH genetic worth0

    HT genetic worth0

    USE SNC?0

    SNC Foliage Reten0

    PRUNED?0

    PARTIAL CUT?0

    FERTILIZED?0

    MAXSDI?0

    Use Wood quality?0

    Ingrowth?0

    Cut at start of cycle?0

    Conifers Cut?0

    TreeList

    StandPlotTreeSpecUser codeDBHHtCRSCRExpand

    1112021.520

    1122021.320

    1132022.220

    1142021.920

    1152021.720

    1162021.320

    1172021.320

    1182021.420

    1192021.820

    11102021.520

    OrgEdit

    Completed TreeList

    Completed tree listTree list errorsStand Errors

    StandPlotTreeSpecUser codeDBHHtCRSCRExpandDBH 40.006.1995801926

    30000000npts < 10HT too tall0LOGTD > 0.0 but < 1.00HT0LOGML < 8.0 or LOGML > 40.000.6230499744

    40000000DFSI = OCSI = 00BHAGE too small0LOGSH > 4.50CR0LOGTD > 12.006.1995801926

    50000000No major species0Species mix wrong0LOGTA > 0.0 but < 1.000LOGTA > 12.000

    60000000BHAge = 0 for even aged stand0sample tree count too small00Dbh ht ratio out of bounds00

    70000000BHAge > 0 unven-aged stand0stand too old000

    80000000STAGE too small for BHAGE0projected stand too old00

    90000000fertilizer applied to uneven-aged stand0projection length too long00

    100000000YSF or PN not set to zero for uneven-aged stand000

    Fertilization age too old (>70)00

    PN Out of range00

    BART(1) > BABT00

    YST or BART no set to 0 for un thinned stand00

    Yst older than stand00

    BART 000

    Mgexp 7.000

    Fertilization cannot be applied to a stand with foliage retention < 3.000

    Foliage retention is 0.85 when no Swiss needle cast impact is indicated0

    Graphs

    Graphs

    1

    #REF!

    Age (years)

    Trees per acre

    1

    #REF!

    Age (years)

    Basal Area

    1

    #REF!

    Age (years)

    Cubic foot volume per acre

    1

    #REF!

    Age (years)

    Board foot volume per acre

  • The R Code (double-click below to open)