Skip to content

Commit 122d057

Browse files
wagnerdsmshettlesNicholas Crookston
authored
Brining Release up to 2023 Q2 Status (#18)
* Added the parameter field for the SUMMARY DBS keyword to the keyword window * Small typo fix in the databaseDescription.xlsx file * Bug fix: Grey screen was occurring when trying to edit the PLANT/NATURAL management action window. * Removed two extraneous unused variables, and another unused commented-out section, from the kcpVetting function. * Limited the types of file extensions the kcpUpload button looks for to be .kcp and .RData * • Bug fix: when trying to change to freeform with a stand or group selected, the grey screen was occurring. Added a clause to instead return from the function in this instance, similar to how the Edit button works (i.e., nothing happens). • Bug fix: when clicking the “Save in component collection” button more than once when the last keyword in the KCP was in a conditional block, and ENDIF keyword was being added more than once. • Added a few “## “ labels above some observer functions that did not have them, making identification easier. * Removed all references to "fvsOLdev", added code that tests on the library fvsOL is loaded from and if it is R-dev, then the neading is adjusted to say "Dev". Modified the run scripts so that rFVS will be loaded from R-dev if it is located at that location. * Modified the date of revision, cleaned up some line endings, reorganized a bit of code so that a cluster instance is not started if an error condition is discovered. * Removed one more "devVersion" code sequence, cleaning up the fvsOLdev issue. * Fixed a small bug when the PlotInit table is absent in the mapping code. * Updates to voleqnum.kwd to include additional available volume equations * modifications to basekeys.kwd to allow for user input to top diameter limits and stump in BFVOLUME and VOLUME keyword dialogs * Minor typo fix in ui.R * Added the three cmpSummary tables to the list of simulation-level tables for use in the "Database tables to consider" window in the View outputs > Load menu. * Standardized the "## " titles for observer functions in server.R as many were absent, or had different number of pound signs and spacing. This is to (hopefully) make easier the searching for, and learning of, code for any future interface programmers. * Updated the "Release date" variables to be 20230106 * Added the old iet01.key and iet01.tre files into a ../tests folder for use with the introductory rFVS wiki examples. * Deletion of fvsOLdev folder from the development branch * Typo fix * Bug fix: composite tables were showing up in the "Database tables to consider" window when a single run with a single stand was selected in the "Runs to consider" window. * Updated Wensel &Olsen Scribner 32 function names to remove a '-' that was causing an uncommon character. Replaced with parentheses. * Voleqnum.kwd parm updates Added space to Wensel & Olsen Removed all Sharpneck equations from availability Removed F0#FW2W260, general hemlock equations Compared volume eq table document returns (BF vol vs cubic vol) and removed equations that didn't return the proper volume type from the respective cubic ft vs board ft equation lists * Added some more standardization for labeling functions, and removed an unnecessary clause that was precluding the creation of the stand and stock table that was introduced in a recent test commit. * Added 3 eqs missing from ec, wc, bm, pn, op, oc 628BEHW093 = Region 6:Engelmann spruce - Behres Hyperbola 616TRFW747 = Region 6:black cottonwood - PNW tariff Equation 616TRFW998 = Region 6:unknown hardwood - PNW tariff Equation * Strange character encoding correction Found other instances of 'Behre's' begin translated with unusual characters. Changed to 'Behres' * Removal of newSum variable from server.R and calls to the writeKeyFile function that was preventing new runs from keeping the Summary2 table as the default if any previous runs had the Summary table in them. * Bringing Main up to 2023 Q2 Status (#17) * rFVS: added fvsCutNow and fvsMakeyFile functions, Fixed a typo in fvsAddActivity, added the ability to set/get "special" tree tag and kutkod used in prescription thinnings. fvsOL: modified code to support package sf (more work to do on this). * Started process of adding support of package sf * Rmeoved "NAMESPACE" from management by the repository * Finished changes to convert from package sp to sf for spatial data * Commented out the ability to specify "development" code in new projects. * Fixed a bug I just introduced. * Removed the use of R-dev as an installation library (a change to the makefiles) This restores the code to a previous version. * rFVS: Improved the documentation for fvs[Get|Set]SpeciesAttrs, reset the revision date in DESCRIPRTION * fvsOL: Fixed a bug that caused a warning in some cases when a run's variant was not set, modified the code that runs the Acadian variant so that fvs tree ids are maintained (the trees were being renumbered). Updated the revision tag in DESCRIPTION * Pull Request #14 Updates from NCrookston * 1. When trying to manually add the RRTREIN and BBCLEAR root disease keywords a crash was occurring. 2. When trying to add in the THINRDSL keyword into the Run contents using a non-NE variant, a crash was occurring (keyword only applies to the NE variant). 3. When trying to import a custom SQL query using the Import runs and other items, a crash was occurring, and the query was also not showing up in the Custom query menu after import. 4. Improvements to the SQLIN/SQLOUT database keyword windows: a. Updated example text & code was added to below the windows b. A column ruler was added to be above the editor window c. The needed DATABASE/END keywords are now automatically added around the query when building the keyword file at run time (they were previously being tagged as “base” instead of “dbs”) 5. The “Rebuild StdStk” button now works in that if a run containing a StdStk (or cmpStdStk) table is pre-selected in the “Runs to consider” window, and then the “Rebuild StdStk” button is clicked after changing the “DBH class size” and/or “Large DBH” values, the “DBHClasses” under the Explore menu are immediately updated. Previously, a run had to not be selected before changing either of those values, and then a run selected, for the changes to then reflect under the Explore menu. 6. A logical variables was added to the keyword writing function to prevent two successive END keywords from being written that was happening when a base keyword was following a conditionally-scheduled non-base keyword. * Update fvsRunUtilities.R Fixing inadvertent overwrite when merging multiple pull requests * Bug fixes (fvsOL): • When trying to import a project backup the check for a blank/null INV_YEAR field in the input database was causing a crash if the column name for that variables was not upper case. The tolower() function was added to coerce it to lower case for even comparison of all casings of that variable. • The keyword writing code was missing logic to handle when a conditional was following a previous conditional that had multiple non-base keywords. • When deleting the only stand from a run that had components attached to groups (thus creating a blank-appearing run), the components were being inherited by any subsequently-added stands. This made sense for runs with multiple stands (where deleting one stand didn’t result in a blank run) but was deemed confusing (since adding stands into a blank run should not carry any keyword inheritance). Now, any groups & their associated keywords associated with the stand being deleted from a single-stand run are now removed from the run upon clicking “Cut/delete”. • The sumOnSpecies indicator variable in the graphing code was not setup to accommodate the 3 newer species codes (SpeciesFVS, SpeciesPLANTS, SpeciesFIA) resulting in plots containing any one of those 3 variables were resulting in erroneously large Y-axis values (e.g., 4000ft tall trees). * 2023 q2 shettles final (#17) * Bug fixes (fvsOL): • When trying to import a project backup the check for a blank/null INV_YEAR field in the input database was causing a crash if the column name for that variables was not upper case. The tolower() function was added to coerce it to lower case for even comparison of all casings of that variable. • The keyword writing code was missing logic to handle when a conditional was following a previous conditional that had multiple non-base keywords. • When deleting the only stand from a run that had components attached to groups (thus creating a blank-appearing run), the components were being inherited by any subsequently-added stands. This made sense for runs with multiple stands (where deleting one stand didn’t result in a blank run) but was deemed confusing (since adding stands into a blank run should not carry any keyword inheritance). Now, any groups & their associated keywords associated with the stand being deleted from a single-stand run are now removed from the run upon clicking “Cut/delete”. • The sumOnSpecies indicator variable in the graphing code was not setup to accommodate the 3 newer species codes (SpeciesFVS, SpeciesPLANTS, SpeciesFIA) resulting in plots containing any one of those 3 variables were resulting in erroneously large Y-axis values (e.g., 4000ft tall trees). * The BurnReDB database keyword was still being displayed as BurnRept in the Keywords menu dropdown menu list. * Removal of a browser() command from code. * 1) Added keyword windows for the REGREPTS and INVSTATS DBS keywords (#18) 2) Added the new BHTWTBA and AHTWTBA Event Monitor variables to the "Variables" dropdown list * Update of "Release date" for upper right panel in GUI to read 20230518 for upcoming Q2 release. (#19) * Modified R/externalCallable.R to add the ability to delete stands and modified the function that lists stands to return a data.frame that has the stand uuid as well as the standid. Modified fvsRunAadian to not use fvsStopPoint 7. The stoppoint works, but what we were trying to accomplish was not getting done. * Removed NAMESPACE from being tracked by git. It is automatically built when R builds the package. * 1) Updated the example text under the SQLout window (#21) 2) Fixed the Lory's height EM variable calculation so that it inserts the correct variable --------- Co-authored-by: Nicholas Crookston <ncrookston.fs@gmail.com> Co-authored-by: MICHAEL A. SHETTLES <michael.a.shettles@usda.gov> --------- Co-authored-by: Michael Shettles <michael.a.shettles@usda.gov> Co-authored-by: Nicholas Crookston <ncrookston.fs@gmail.com> Co-authored-by: mshettles <100229112+mshettles@users.noreply.github.com>
1 parent a498fd3 commit 122d057

122 files changed

Lines changed: 1868 additions & 57088 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

FVSPrjBldr/server.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ shinyServer(function(input, output, session) {
2929
workDir = paste0("/home/shiny/FVSwork/",uuid)
3030
cat("workDir=",workDir,"\n")
3131
dir.create(workDir)
32-
if (input$version == "production")
32+
# if (input$version == "production")
3333
cat ('library(fvsOL)\nfvsOL(fvsBin="/home/shiny/FVS/bin")\n',file=paste0(workDir,"/app.R"))
34-
if (input$version == "development")
35-
cat ('library(fvsOLdev)\nfvsOL(fvsBin="/home/shiny/FVSdev/bin")\n',file=paste0(workDir,"/app.R"))
34+
# if (input$version == "development")
35+
# cat ('library(fvsOLdev)\nfvsOL(fvsBin="/home/shiny/FVSdev/bin")\n',file=paste0(workDir,"/app.R"))
3636
# projectId file...
3737
cat("email=",emailnew,"\ntitle=",input$title,"\n")
3838
cat(file=paste0(workDir,"/projectId.txt"),

FVSPrjBldr/ui.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ shinyUI(fluidPage(
2020
textInput("title", "Your new project title"),
2121
textInput("emailnew", "Your Email address"),
2222
textInput("emaildup", "Your Email address again"),
23-
radioButtons("version",NULL,choices=list(
24-
"Use the production version of the software"="production",
25-
"Use the development version"="development"),
26-
selected="production"),
23+
# radioButtons("version",NULL,choices=list(
24+
# "Use the production version of the software"="production",
25+
# "Use the development version"="development"),
26+
# selected="production"),
2727
p("By pressing submit you are certifying that you agree to the Notice posted below."),
2828
actionButton("submitnew","Submit"),
2929
tags$style(type="text/css","#actionMsg{color:darkred;}"),

fvsOL/DESCRIPTION

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
Package: fvsOL
2-
Title: Forest Vegetation Simulator
3-
Version: 2022.09.30
4-
Authors@R: c(person("Nicholas", "Crookston", email = "ncrookston.fs@gmail.com",
5-
role = c("aut")),
6-
person("Michael", "Shettles", email = "michael.a.shettles@usda.gov",
7-
role = c("aut", "cre")))
8-
Description: An R-Shiny interface to the Forest Vegetation Simulator which can be
9-
run as an "Online" or "Onlocal" configuration.
10-
Depends: R (>= 4.0.0), rFVS (>= 2021.03.15), shiny (>= 1.6.0), Cairo (>= 1.5.11),
11-
rhandsontable (>= 0.3.7), ggplot2 (>= 3.3.3), parallel (>= 4.0.0),
12-
RSQLite (>= 2.2.4), plyr (>= 1.8.6), dplyr (>= 1.0.4), colourpicker (>= 1.1.0),
13-
rgl (>= 0.105.0), leaflet (>= 2.0.4.1), zip (>= 2.1.1), openxlsx (>= 4.2.3)
14-
Suggests: rgdal (>= 1.5-23), nlme (>= 3.1-140)
15-
License: MIT
16-
Roxygen: list(markdown = TRUE)
17-
RoxygenNote: 7.1.2
1+
Package: fvsOL
2+
Title: Forest Vegetation Simulator
3+
Version: 2023.05.18
4+
Authors@R: c(person("Nicholas", "Crookston", email = "ncrookston.fs@gmail.com",
5+
role = c("aut")),
6+
person("Michael", "Shettles", email = "michael.a.shettles@usda.gov",
7+
role = c("aut", "cre")))
8+
Description: An R-Shiny interface to the Forest Vegetation Simulator which can be
9+
run as an "Online" or "Onlocal" configuration.
10+
Depends: R (>= 4.0.0), rFVS (>= 2021.03.15), shiny (>= 1.6.0), Cairo (>= 1.5.11),
11+
rhandsontable (>= 0.3.7), ggplot2 (>= 3.3.3), parallel (>= 4.0.0),
12+
RSQLite (>= 2.2.4), plyr (>= 1.8.6), dplyr (>= 1.0.4), colourpicker (>= 1.1.0),
13+
rgl (>= 0.105.0), leaflet (>= 2.0.4.1), zip (>= 2.1.1), openxlsx (>= 4.2.3)
14+
Suggests: rgdal (>= 1.5-23), nlme (>= 3.1-140)
15+
License: MIT
16+
Roxygen: list(markdown = TRUE)
17+
RoxygenNote: 7.2.3
18+
Encoding: UTF-8

fvsOL/NAMESPACE

Lines changed: 0 additions & 21 deletions
This file was deleted.

fvsOL/R/componentWins.R

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ keyword.dbs.StandSQL.Win <- function(title, prms, globals, input, output)
5353
}
5454
keyword.dbs.StandSQL.Win.mkKeyWrd <- function(input,output)
5555
{
56-
list(ex="base",
56+
list(ex="dbs",
5757
kwds = paste0("StandSQL\n",input$freeEdit,"\nEndSQL\n"),
5858
reopn = c(freeEdit=input$freeEdit)
5959
)
@@ -82,14 +82,12 @@ keyword.dbs.TreeSQL.Win <- function(title, prms, globals, input, output)
8282
}
8383
keyword.dbs.TreeSQL.Win.mkKeyWrd <- function(input,output)
8484
{
85-
list(ex="base",
85+
list(ex="dbs",
8686
kwds = paste0("TreeSQL\n",input$freeEdit,"\nEndSQL\n"),
8787
reopn = c(freeEdit=input$freeEdit)
8888
)
8989
}
9090

91-
92-
9391
keyword.dbs.SQLIn.Win <- function(title, prms, globals, input, output)
9492
{
9593
globals$currentCmdDefs <- c(f1=" ",freeEdit="")
@@ -99,22 +97,29 @@ keyword.dbs.SQLIn.Win <- function(title, prms, globals, input, output)
9997
ans = list(
10098
list (
10199
mkScheduleBox("f1",prms,NULL,globals,input,output),
100+
tags$style(type="text/css",
101+
"#freeEditCols{font-family:monospace;font-size:90%;width:95%;}"),
102+
tags$p(id="freeEditCols",
103+
HTML(paste0("&nbsp;",paste0("....+....",1:8,collapse="")))),
102104
tags$style(type="text/css",
103105
"#freeEdit{font-family:monospace;font-size:90%;width:95%;}"),
104106
tags$textarea(id="freeEdit", rows=10, globals$currentCmdDefs["freeEdit"]),
105107
tags$p(id="instruct",HTML(paste0(
106-
"Run an query on the DSNIn connection. If the query is a SELECT, ",
107-
"then the last row of the result table will define the values of ",
108-
"variables in the Event Monitor. The variables will have the column names.<br>",
109-
"Example:<br><b>Select Inv_Year as MyYear from FVS_StandInit ",
110-
"where Stand_ID = '%StandID%';<br></b>will define MyYear in the Event Monitor")
111-
))
108+
"Run a query on the DSNIn connection. If the query is a SELECT, ",
109+
"the column names from the table are compared to the names of ",
110+
"user-defined Event Monitor variables. For any matching variable, ",
111+
"the value in the last row of the result table will define the values of ",
112+
"variables in the Event Monitor.<br>",
113+
"Example:<br><b>SELECT Inv_Year as MyYear<br>FROM FVS_StandInit<br>",
114+
"WHERE Stand_ID = '%StandID%'<br></b>will define ",
115+
"MyYear as a variable in the Event Monitor")
116+
))
112117
),list())
113118
ans
114119
}
115120
keyword.dbs.SQLIn.Win.mkKeyWrd <- function(input,output)
116121
{
117-
list(ex="base",
122+
list(ex="dbs",
118123
kwds = paste0(sprintf("SQLIn %10s\n",input$f1),input$freeEdit,"\nEndSQL\n"),
119124
reopn = c(f1=input$f1,freeEdit=input$freeEdit)
120125
)
@@ -130,15 +135,29 @@ keyword.dbs.SQLOut.Win <- function(title, prms, globals, input, output)
130135
ans = list(
131136
list (
132137
mkScheduleBox("f1",prms,NULL,globals,input,output),
138+
tags$style(type="text/css",
139+
"#freeEditCols{font-family:monospace;font-size:90%;width:95%;}"),
140+
tags$p(id="freeEditCols",
141+
HTML(paste0("&nbsp;",paste0("....+....",1:8,collapse="")))),
133142
tags$style(type="text/css",
134143
"#freeEdit{font-family:monospace;font-size:90%;width:95%;}"),
135-
tags$textarea(id="freeEdit", rows=10, globals$currentCmdDefs["freeEdit"])),
136-
list())
144+
tags$textarea(id="freeEdit", rows=10, globals$currentCmdDefs["freeEdit"]),
145+
tags$p(id="instruct",HTML(paste0(
146+
"Run a query on the DSNOut connection. If the query is a SELECT, ",
147+
"the column names from the table are compared to the names of ",
148+
"user-defined Event Monitor variables. For any matching variable, ",
149+
"the value in the last row of the result table will define the values of ",
150+
"variables in the Event Monitor.<br>",
151+
"Example:<br><b>SELECT SDI as MySDI<br>FROM FVS_Summary2<br>",
152+
"WHERE StandID = '%StandID%'<br></b>will define ",
153+
"MySDI as a variable in the Event Monitor")
154+
))
155+
),list())
137156
ans
138157
}
139158
keyword.dbs.SQLOut.Win.mkKeyWrd <- function(input,output)
140159
{
141-
list(ex="base",
160+
list(ex="dbs",
142161
kwds = paste0(sprintf("SQLOut %10s\n",input$f1),input$freeEdit,"\nEndSQL\n"),
143162
reopn = c(f1=input$f1,freeEdit=input$freeEdit)
144163
)
@@ -241,9 +260,10 @@ PlantNaturalFullWin <- function(title, prms, globals, input, output, full=TRUE)
241260
{
242261
pknum = match("management.PlantNatural",names(prms))
243262
globals$currentCmdPkey = as.character(pknum) #point to the pkeys.
244-
globals$currentCmdDefs <- c(pnDOD="1",pnYD="1",pnPBrn=" ",pnPMch=" ",
245-
pnSprt=getPstring(atag=globals$activeVariants[1],pkey="hasSproutingSpecies",
246-
pkeys=prms[[pknum]])[[1]],
263+
globals$currentCmdDefs <- c(pnDOD="1")
264+
if (full) globals$currentCmdDefs <- c(globals$currentCmdDefs,pnYD="1", pnPBrn=" ",pnPMch=" ")
265+
globals$currentCmdDefs <- c(globals$currentCmdDefs, pnSprt=getPstring(atag=globals$activeVariants[1],
266+
pkey="hasSproutingSpecies",pkeys=prms[[pknum]])[[1]],
247267
pnYpn1="1",pnTr1="1",pnSp1=" ", pnTpa1=" ",pnPsv1="100.",pnAge1=" ",
248268
pnHt1=" ",pnShd1="0",
249269
pnYpn2="1",pnTr2="1",pnSp2=" ", pnTpa2=" ",pnPsv2="100.",pnAge2=" ",

fvsOL/R/editDataUtilities.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# $Id$
2-
31
mkStdSel <- function (dbGlb)
42
{
53
if (length(dbGlb$sids) > 1000) return(renderUI(NULL))

fvsOL/R/externalCallable.R

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# $Id: externalCallable.R 4018 2022-07-27 22:59:15Z nickcrookston $
2-
#
31
#' Build an FVS run in a project
42
#'
53
#' Build an FVS run in a project and add it to the list of runs in the project.
@@ -38,7 +36,7 @@ extnMakeRun <- function (prjDir=getwd(),title=NULL,standIDs=NULL,
3836
if (!file.exists("FVS_Data.db"))
3937
{
4038
warning("FVS_Data.db did not exist, default training data was loaded.")
41-
frm=system.file("extdata", "FVS_Data.db.default", package=if (devVersion) "fvsOLdev" else "fvsOL")
39+
frm=system.file("extdata", "FVS_Data.db.default", package="fvsOL")
4240
file.copy(frm,dbfile)
4341
}
4442
if (!file.exists(dbfile)) stop ("FVS_Data.db must exist")
@@ -668,7 +666,7 @@ extnMakeKeyfile <- function(prjDir=getwd(),runUUID,fvsBin="FVSBin",
668666
prjDir = normalizePath(prjDir)
669667
prjDB = file.path(prjDir, "FVSProject.db")
670668
db=dbConnect(SQLite(), dbname = "FVS_Data.db")
671-
rtn = writeKeyFile(globals,db,newSum=TRUE,keyFileName,verbose=verbose)
669+
rtn = writeKeyFile(globals,db,keyFileName,verbose=verbose)
672670
if(rtn=="Run data query returned no data to run.") return("wrong active database")
673671
dbDisconnect(db)
674672
rtn
@@ -681,7 +679,7 @@ extnMakeKeyfile <- function(prjDir=getwd(),runUUID,fvsBin="FVSBin",
681679
#' @param prjDir is the path name to the project directory, if null the
682680
#' current directory is the project directory.
683681
#' @param runUUID a character string of the run uuid that is processed
684-
#' @return a vector of stand ids that are in the run.
682+
#' @return data.frame of stand ids and corresponding uuids that are in the run.
685683
#' @examples
686684
#' runID <- extnMakeRun(title="Make a run, list the stands",
687685
#' standIDs=c("01100202010068","01100205010076","01100202010146"),
@@ -695,9 +693,42 @@ extnListStands <- function(prjDir=getwd(),runUUID)
695693
on.exit(dbDisconnect(db))
696694
fvsRun = loadFVSRun(db,runUUID)
697695
if (!exists("fvsRun")) stop("runUUID run data not loaded")
698-
stands = c()
699-
for (std in fvsRun$stands) stands=c(stands,std$sid)
700-
return(stands)
696+
return(data.frame(uuid= unlist(lapply(fvsRun$stands,function(x) x$uuid)),
697+
stand=unlist(lapply(fvsRun$stands,function(x) x$sid ))))
698+
}
699+
700+
#' Given a project directory a run uuid, this function deletes stands using
701+
#' the stand's UUIDs.
702+
#'
703+
#' @param prjDir is the path name to the project directory, if null the
704+
#' current directory is the project directory.
705+
#' @param runUUID a character string of the run uuid that is processed
706+
#' @param a vector of stand UUIDs that are in the run that you want deleted.
707+
#' @return the number of stands deleted.
708+
#' @examples
709+
#' runID <- extnMakeRun(title="Make a run, list the stands",
710+
#' standIDs=c("01100202010068","01100205010076","01100202010146"),
711+
#' variant="ie")
712+
#' thestands <- extnListStands(runUUID=runID)
713+
#' todel <- thestands[1,2] # delete the second stand
714+
#' extnDeleteStands(prjDir=getwd(),runUUID,todel)
715+
#' @export
716+
extnDeleteStands <- function(prjDir=getwd(),runUUID,deleteStandUUIDs)
717+
{
718+
if (missing(runUUID)) stop("runUUID required")
719+
if (missing(deleteStandUUIDs)) stop("deleteStandUUIDs required")
720+
db = connectFVSProjectDB(prjDir)
721+
on.exit(dbDisconnect(db))
722+
fvsRun = loadFVSRun(db,runUUID)
723+
if (!exists("fvsRun")) stop("runUUID run data not loaded")
724+
uuids=unlist(lapply(fvsRun$stands,function(x) x$uuid))
725+
del=na.omit(match(deleteStandUUIDs,uuids))
726+
if (length(del))
727+
{
728+
fvsRun$stands[del]=NULL
729+
storeFVSRun(db,fvsRun)
730+
}
731+
return(length(del))
701732
}
702733

703734
#' Fetch a run
@@ -812,8 +843,6 @@ extnAddStands <- function(prjDir=getwd(),runUUID,stands,
812843
}
813844
allNeed = c("Groups","Inv_Year","AddFiles","FVSKeywords","Sam_Wt",needFs)
814845
fields = intersect(toupper(fields),toupper(allNeed))
815-
if (length(fields) < length(allNeed)) stop("required db fields are missing")
816-
817846
getStds = data.frame(getStds=if (addStandReps) stands else setdiff(stands,
818847
unlist(lapply(fvsRun$stands,function(x) x$sid))))
819848
if (nrow(getStds) == 0) return(nadd)
@@ -844,7 +873,7 @@ extnAddStands <- function(prjDir=getwd(),runUUID,stands,
844873
newstd <- mkfvsStd(sid=sid,uuid=uuidgen(),rep=0,repwt=1,invyr=as.character(invyr))
845874

846875
addfiles = fvsInit[row,"ADDFILES"]
847-
if (!is.na(addfiles)) for (addf in names(addfiles))
876+
if (!is.null(addfiles)) for (addf in names(addfiles))
848877
{
849878
nadd$ncmps=nadd$ncmps+1
850879
newstd$cmps <- append(newstd$cmps,
@@ -970,6 +999,16 @@ extnSimulateRun <- function(prjDir=getwd(),runUUID,fvsBin="FVSBin",ncpu=detectCo
970999
# adjust location of the input database in the keyword file.
9711000
indb=grep ("FVS_Data.db$",kwds)
9721001
if (length(indb)) kwds[indb]=paste0("../",kwds[indb])
1002+
if (length(.libPaths()) > 1)
1003+
{
1004+
libpaths=""
1005+
for (l in .libPaths())
1006+
{
1007+
libpaths = if (nchar(libpaths)) paste0(libpaths,",") else ".libPaths(c("
1008+
libpaths=paste0(libpaths,'"',l,'"')
1009+
}
1010+
libpaths=paste0(libpaths,"))")
1011+
} else libpaths=NA
9731012
clindx=1
9741013
for (set in names(asign))
9751014
{
@@ -987,7 +1026,8 @@ extnSimulateRun <- function(prjDir=getwd(),runUUID,fvsBin="FVSBin",ncpu=detectCo
9871026
close(opnout)
9881027
# make the run script
9891028
opnout = file(file.path(rundir,sub(".key$",".Rscript",keyFileName)),open="wt")
990-
cat ("library(rFVS)\n",file=opnout)
1029+
if (!is.na(libpaths)) cat(libpaths,"\n",file=opnout,append=TRUE)
1030+
cat ("library(rFVS)\n",file=opnout,append=TRUE)
9911031
if (dir.exists(fvsBin)) fvsBin=gsub(pattern="\\\\",replacement="/",x=normalizePath(fvsBin))
9921032
cat ("rtn=try(fvsLoad('",fvsRun$FVSpgm,"',bin='",fvsBin,
9931033
"'))\nif(class(rtn)=='try-error') stop('fvs load failed')\n",sep="",file=opnout)
@@ -997,7 +1037,7 @@ extnSimulateRun <- function(prjDir=getwd(),runUUID,fvsBin="FVSBin",ncpu=detectCo
9971037
# look in the system extdata directory to find it in the package
9981038
cmdfil=paste0("customRun_",fvsRun$runScript,".R")
9991039
if (!file.exists(cmdfil)) cmdfil=system.file("extdata", cmdfil,
1000-
package = if (devVersion) "fvsOLdev" else "fvsOL")
1040+
package = "fvsOL")
10011041
if (file.exists(paste=cmdfil))
10021042
{
10031043
cat ("curdir=getwd();setwd('..')\n",file=opnout)
@@ -1021,13 +1061,12 @@ extnSimulateRun <- function(prjDir=getwd(),runUUID,fvsBin="FVSBin",ncpu=detectCo
10211061
cat ('cat (Sys.getpid()," ',fvsRun$title,'; ',ncpu,' CPUs; ",',
10221062
'format(Sys.time(),"%Y-%m-%d_%H_%M_%S"),"\\n",sep="",file="',
10231063
pidStat,'")\n',sep="",file=rscript)
1024-
if (devVersion) cat('require(fvsOLdev)\n',file=rscript,append=TRUE) else
1025-
cat('require(fvsOL)\n', file=rscript,append=TRUE)
1064+
if (!is.na(libpaths)) cat(libpaths,"\n",file=rscript,append=TRUE)
1065+
cat('require(fvsOL)\n',file=rscript,append=TRUE)
10261066
cat('fvsprocs = makePSOCKcluster(',ncpu,')\n',sep="",file=rscript,append=TRUE)
10271067
cat('pids = unlist(clusterEvalQ(fvsprocs,Sys.getpid()))\n',sep="",file=rscript,append=TRUE)
10281068
cat('cat ("fvsPids:",pids,"\\n",file="',pidStat,'",append=TRUE)\n',sep="",file=rscript,append=TRUE)
1029-
cat(paste0('clusterEvalQ(fvsprocs,library(',if (devVersion) 'fvsOLdev' else 'fvsOL',
1030-
'))\n'),sep="",file=rscript,append=TRUE)
1069+
## ??? cat(paste0('clusterEvalQ(fvsprocs,library(fvsOL))\n'),sep="",file=rscript,append=TRUE)
10311070
for (i in 1:ncpu) cat('clusterEvalQ(fvsprocs[',i,'],setwd("',paste0(runUUID,names(asign)[i]),'"))\n',
10321071
sep="",file=rscript,append=TRUE)
10331072
cat ('try(clusterEvalQ(fvsprocs,source("',runUUID,'.Rscript")))\n',sep="",file=rscript,append=TRUE)
@@ -1056,8 +1095,7 @@ extnSimulateRun <- function(prjDir=getwd(),runUUID,fvsBin="FVSBin",ncpu=detectCo
10561095
}
10571096
}
10581097
dbDisconnect(dbcon)\n',
1059-
file=rscript,append=TRUE)
1060-
1098+
file=rscript,append=TRUE)
10611099
cat ('file.remove("',paste0(runUUID,".pidStatus"),'")\n',sep="",file=rscript,append=TRUE)
10621100

10631101
rsloc = if (exists("RscriptLocation")) RscriptLocation else

fvsOL/R/fvsOutUtilities.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# $Id$
2-
31
initTableGraphTools <- function (globals,session,output,fvsOutData)
42
{
53
cat ("initTableGraphTools\n")

0 commit comments

Comments
 (0)