What is the name of the Initial Conditions Distribution table in R

Deliver geospatial models direct to decision makers with SyncroSim Forums ST-Sim & State-and-Transition Simulation Models What is the name of the Initial Conditions Distribution table in R

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #5530
    kblankenshipkblankenship
    Participant

    Hello! What is the name of the Non-Spatial, Initial Conditions, Distribution table in R? I tried “STSim_InitialConditionsNonSpatialDistribution”, “STSim_DistributionValue”, and several others. None of these has the same format as the Distribution table I see and can export from the ST-Sim GUI. When I tried accessing the “STSim_InitialConditionsNonSpatialDistribution”, which I thought was the most likely candidate, I found an empty table, even though this information is populated in my library.

    #5533
    colin-danielcolin-daniel
    Keymaster

    The name of the datasheet is indeed “STSim_InitialConditionsNonSpatialDistribution”.

    There are several reasons why the datasheet may appear empty to you – without looking at your R code it would be tough to figure out the reason. However if you want to see an example of how to set the Non-Spatial Initial Conditions for ST-Sim, you can look at the rsyncrosim-demo.R example script.

    #5540
    kblankenshipkblankenship
    Participant

    Hi Colin,
    I’m still having trouble. I’ve included my code below in case this helps. In ST-Sim the initial conditions distribution table for this library has 10-20 rows of data w/ the initial conditions for 5 different stratum.
    Thanks, Kori

    > library(rsyncrosim)
    > # Specify the location of the SyncroSim program on computer
    > programFolder = “C:/Program Files/SyncroSim”
    > Ses = session(programFolder)
    > module(Ses)
    name displayName version
    1 dgsim Demographic Population 2.1.13
    2 stsim ST-Sim State and Transition 3.1.16
    3 stsim-ecodep ST-Sim Ecological Departure Add-On 3.1.16
    4 stsim-stockflow ST-Sim Stocks and Flows Add-On 3.1.16
    > # Set working directory to the location of the STSim library
    > setwd(“C:/Users/kblankenship/Documents/aLANDFIRE/MODELING/SynchroSim2/LFMaster”)
    > # Specify the library, project and scenario
    > Lib = ssimLibrary(name=”practice5.ssim”, model=”stsim”, session=Ses)
    > Prj = project(Lib, project=”BpSModels”)
    > Scn = scenario(Prj, 1)
    > datasheet(Scn, “STSim_InitialConditionsNonSpatialDistribution”)
    [1] StratumID StateClassID AgeMin AgeMax RelativeAmount
    <0 rows> (or 0-length row.names)

    #5541
    colin-danielcolin-daniel
    Keymaster

    It seems most likely that you are opening a new empty scenario instead of the existing scenario you think you are opening. This is quite easy to do with the current version of rsyncrosim, as the library, project and scenario functions automatically create new objects if the one you specify does not exist.

    The best way to see what is going on is to check the summary contents of each object after you load it, to make sure it is in fact what you expect:
    project(Lib, summary=TRUE) will list all the projects in library Lib
    scenario(Prj, summary=TRUE) will list all the scenarios in the project Prj

    You can then confirm you are referencing the correct project and scenario before actually opening it.

    I hope this helps. Colin

    #5542
    kblankenshipkblankenship
    Participant

    OK, I tried to rule out that I might be calling a scenario that doesn’t exist, but I don’t think that is it. I think the code below shows that I do have a scenario 1 and that I am able to open another datasheet from the scenario:
    > library(rsyncrosim)
    > programFolder = “C:/Program Files/SyncroSim”
    > Ses = session(programFolder)
    > setwd(“C:/Users/kblankenship/Documents/aLANDFIRE/MODELING/SynchroSim2/LFMaster”)
    > Lib = ssimLibrary(name=”practice5.ssim”, model=”stsim”, session=Ses)
    > project(Lib, summary=TRUE)
    projectId name owner lastModified readOnly
    1 1 BpSModels N/A 12/19/2017 at 5:58 AM FALSE
    > Prj = project(Lib, project=”BpSModels”)
    > scenario(Prj, summary=TRUE)
    scenarioId projectId name isResult parentID owner
    1 1 1 AllModels No – LANDFIRE
    lastModified readOnly
    1 12/15/2017 at 6:36 AM FALSE
    > Scn = scenario(Prj, 1)
    > datasheet(Scn, “STSim_RunControl”)
    MinimumIteration MaximumIteration MinimumTimestep
    1 1 10 0
    MaximumTimestep IsSpatial
    1 1000 NA

    #5543
    colin-danielcolin-daniel
    Keymaster

    Are you using dependencies in your scenarios? I’m just wondering if the initial conditions are perhaps in a dependent scenario with a different ID?

    If not, could you email/postyour zipped .ssim file and R script (can go to info@apexrms.com)? I would need to look at it to diagnose further – Colin

    #5544
    colin-danielcolin-daniel
    Keymaster

    Hi Kori – it turns out this is an odd bug in rsyncrosim (version 1.0.3 or earlier) where nothing is returned if the Stratum Name is a number. We will fix this in the next rsyncrosim release. However in the interim you can get around the bug by prefixing your Stratum Name with a letter (e.g. “Bps-“).

    #6011
    kblankenshipkblankenship
    Participant

    Hi Colin –
    I’m now working on a database with ~900 models, and I’m encountering this issue with numeric Stratum names. It looks like the latest version of rsyncrosim on your website is v.1.0.2. Do I understand correctly that this problem still exists in the current version?

    What would you suggest as a work around for such a large model library? I tried unsuccessfully to add “BPS” to the beginning of each Stratum name using the following code, but it would not save the result to the datasheet.

    # *************************************************************
    # File/Package Setup
    # *************************************************************
    library(rsyncrosim)
    programFolder = “C:/Program Files/SyncroSim”

    # *************************************************************
    # Start Session & Library Setup
    # *************************************************************
    Ses = session(programFolder)
    module(Ses)
    setwd(“C:/Users/kblankenship/Documents/aLANDFIRE/MODEL/STSM/SynchroSim2/QC”)
    getwd()

    # Specify the library, project and scenario
    Lib = ssimLibrary(name=”MasterSsim09June2014-qc-50-5.ssim”, model=”stsim”, session=Ses)
    Prj = project(Lib, project=”BpSModels”)

    #Add “BPS” to Stratum name
    Stratumsheet = “STSim_Stratum”
    Stratumdata = datasheet(Prj, Stratumsheet)
    Stratumdata$Name<-paste(“BPS”,Stratumdata$Name, sep=””)
    saveDatasheet(Prj, Stratumdata, Stratumsheet,append = FALSE)
    y
    Stratumdata = datasheet(Prj, Stratumsheet)

    #6012
    kblankenshipkblankenship
    Participant

    In my last post I meant to say that my R code would NOT save the result to the datasheet.

    #6013
    colin-danielcolin-daniel
    Keymaster

    At present the Stratum Name is treated as a key for each Stratum in the Project Definitions. Which means that it is not easy to change the Names once the Definitions are set. We have discussed making it possible to change the values of fields like this programmatically, as you have tried to do, but haven’t yet found the funding to move ahead with that.

    In the interim there are 2 ways that you could change your names. The first is to edit them directly on the screen in the user interface. Our user interface handles this because it knows about a hidden primary key in the underlying database table that allows the Name to be changed. Unfortunately this primary key is not yet exposed in rsyncrosim (but we are looking to offer this option in a future release). Of course this would be challenging for 900 values. The other way to do it programmatically would be to update the .ssim SQLite database directly. You can do this in R by connecting to your .ssim file as a SQLite database (using the RSQLite package) and then issuing a SQL command to this database to update the appropriate database table. The names of the tables in the database are the same as the corresponding datasheet names. I recommend using the free SQLiteStudio software to peruse your .ssim file in order to figure out the query. I believe you can also invoke SQL queries directly from within SQLiteStudio. Be sure to backup your library before issuing direct SQL commands however!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.