You are not logged in. Click here to log in.

Application Lifecycle Management

Search In Project

Search inClear

Tags:  not added yet

Getting Started - Netbeans and the OMS Console

Developing OMS models requires an integrated development environment (IDE) tool and the OMS Console. Modelers have some flexibility in the choice of their IDE tool, but for this training the Netbeans IDE should be used.

The general approach to OMS modeling involves using the IDE to develop, compile, and debug source code written in supported languages (currently Java, FORTRAN, C, C++, and NetLogo), and to build a .jar file for OMS simulations. Then the modeler uses the OMS Console and domain specific lanaguage (DSL) elements to create and run simulations (test, simulate, calibrate, analyze).

System Requirements and Installing OMS on Your Computer

Refer to the OMS home page at http://oms.javaforge.com (a parent page to this one) for complete instructions for installing and running OMS on your computer. Download the latest version of OMS. Following is a summary of the steps involved.

OMS Installation

Prerequisites

  • JDK 1.6 installed. The JRE is not sufficient to run OMS!
  • ANT 1.8+ if you need to build a model from within the Console; this is provided if Netbeans is used as the IDE (see next section)
  • GCC 4.+ if you need to integrate native code in FORTRAN or C; this is provided if you install MinGW (see next section)

You need to set the JAVA_HOME environment variable, and let it point to your JDK install directory. See instructions in the FAQ accessed from the OMS home page on how to do it if you are not sure.

Install
  1. Unzip the OMS download into any folder.
  2. Execute console.sh or console.bat in order to start the OMS Console.

On its first execution the console will install required jar files and configuration files into HOME/.oms. Those files are being used to run models, and an IDE can use the jar files during model development.

Installing Netbeans and Creating a Project Workspace (EXERCISE 1)

Instructions for installing MinGW and NetBeans in Windows

Instructions from Cheryl Porter as of 9/22/2011:

1. Go to the SourceForge Download page for MinGW: http://sourceforge.net/projects/mingw/files/

2. Near the top, click on the link for the latest version:

  • Looking for the latest version? Download mingw-get-inst-20110802.exe (579.4 kB)
  • Ignore all of the diversion ads and click on the direct link

3. Save the file to a temporary directory. Double click on it to run it.

4. Select the Use pre-packaged repository catalogues button and click on Next >

  • Click on the I accept the agreement button and Next >
  • The next box is Select Destination Location. Do not change from the default location c:\MinGW as this causes many problems!
  • Click on Next. And Next again.

5. In the Select Components box click on C++ (and Fortran Compiler if you want it!) and MinGW Developer Toolkit (to get make and debug !) and click Next >

6. Click on Install. Wait ~5 minutes for the .exe file to unpack and install.

7. Click on Finish.

8. Now you need to add C:\mingw\bin;C:\mingw\msys\1.0\bin to PATH:

  • Start => Control Panel => System => Advanced => Environment Variables
  • In the System variables window, scroll down to Path and click on Edit
  • In the Edit System Variable Box Window, ‘Variable Value’, append the line with ;C:\MinGW\bin;C:\MinGW\msys\1.0\bin
  • At the end of that field. Click OK. Click OK. Click OK

9. Now download and install Netbeans: Go to http://netbeans.org/

  • Click on the Download FREE NetBeans IDE 7.0.1 Button.
  • Click on the Download Button beneath the All Column.

10. Save the file into a temporary folder. Double click on it to install it.

  • Click on Next >. Click on I accept…, and Next >
  • Accept the installers defaults for NetBeans and for the jre (Java Runtime Environment) folders.
  • Wait 5 minutes for NetBeans to install.

11. You may have to install the Java Platform (JDK)

  • Follow the links in the installation for Java SE Development Kit 7 Downloads.
  • Select the Windows version appropriate for your machine, save to a temporary location, then double click to run the installer.
  • Choose all the defaults, click all the Next buttons. Wait 2 minutes or so for installation to complete.
  • Path to JDK on my computer was: "C:\Program Files\Java\jdk1.7.0". You will need to browse to this in your NetBeans installer window, if it prompts you for a JDK location.

12. Start NetBeans: Start => Programs => NetBeans => NetBeans 7.0.1

13. Install plugin for C and C++ compilers.

  • Tools > plugins
  • Available plugins tab
  • Look for C++ category (you may see only one: Gdbserver). Check it.
  • Click install. Next. Accept. Install. Finish.

14. Install subversion version control (for this workshop we will need it).

  • Search for subversion in the upper right corner of the plugins window. You may see only one : Bundled subversion client for windows.
  • Install. Next. Accept. Install. Finish. (restart IDE automatically).

Setting Up a Project Workspace

To get started in Netbeans, modelers should open a basic OMS template project designed for the IDE, available from the OMS javaforge site, or adapt a previously developed project. The oms3.prj.csm project will be provided to training participants. Other project examples are available from the oms_examples directory (go to the SCM Repository tab at oms.javaforage.com).

Although modelers do not have to use one of the oms3.prj.<prjname> templates or examples, they can avoid several configuration and set-up steps by using one. A template project provides both Netbeans and OMS configuration properties necessary for a successful OMS modeling experience.

A project template should be extracted (if zipped) and/or copied to a directory of the modeler's choice. The basic oms3.prj.template provides the folder stucture displayed in the graphic below. Starting out, the folder name oms3.prj.template should be changed by replacing "template" with a suitable name, for example, the workshop training project is oms3.prj.csm ("csm" an acronym for crop simulation model).

Using Netbeans, the modeler should open the template project via File>Open Project. A snapshot of the Netbeans user interface follows, displaying the folders and files for a mock-up oms3.prj.csm.

As the modeler develops and compiles source code, Netbeans will add the build and dist folders to the project to contain the build products. Source code is saved in the src folder.

Simulations developed with the OMS Console are saved in the simulation folder. Data files for simulation are placed in the data folder. Simulation output files in the output folder. Auto-documentation also is saved to the output folder. Other relevant documentation is kept in the docs folder.

Using the OMS Console (EXERCISE 2)

The OMS Console has three primary user interfaces: (1) simulation, (2) parameter editor, and (3) analysis output.

OMS Console - Simulation

The OMS Modeling Console is a graphical user interface (GUI) for the OMS development platform. It provides simple access to core features, such as simulation management, output analysis, and documentation generation. Using the Console is just one way to interact with OMS. As open source software, modeling communities can integrate OMS system components into their own IDEs or custom model development applications.

The main purpose of the OMS Console is to allow a modeler a straightforward and simple tool to develop a model, create a simulation, run the simulation, provide for parameter editing and offer ad-hoc post run analysis and visualization. The figures below provide an overview of the OMS Console.

The Console's principal UI is shown in the figure above. Several buttons and layout features are familiar standard elements. The UI is organized as follows:

Working Directory

The working directory sets the base directory and system property oms3.work for a simulation. It defines a workspace for the simulation. If this folder contains the file oms3.conf, its content gets loaded and applied for all simulation. For example if the file oms3.conf contains a list of open files, they will be opened after setting this directory. The directory can be set using the button next to the directory name.

Simulation Tabs

Each tab contains one simulation script, tool bar, and associated console output. The console might have multiple simulations open at one time, however they must originate from the same workspace. Each simulation tabs operates independent from each other, means you can execute one simulation, while editing another one in a different tab.

Toolbars

The console has two tool bars. A global tool bar manages a set of simulations. In addition, each simulation has its own tool bar, allowing for different operations such as executing, documenting, etc. a simulation. The tool bar action are explained in detail below.

Editor

The simulation editor allows creating and editing a simulation file.

Console Output

This read only output area, shows all standard and error output from the simulation run. Users select the appropriate tab to view the output.

Status Line

Some informative message during console use.
Each simulation tab contains its own private tool bar. The tool bar actions are always directed towards the current simulation script in the editor.

OMS Toolbar buttons are described as follows:


  1. Create a new, empty simulation.
  2. Open an existing simulation from <working directory>/simulations.
  3. Save all open simulations.
  4. Select options and settings (show hidden files, folders; clear output before next run)
  5. Create a new project (currently inactive)
  6. Close current project
  7. Open project
  8. Save simulation script to a file. If the file is new, it will prompt for a name.
  9. Run the simulation script.
  10. Interrupt and stop a running simulation. If no simulation is running this button is disabled.
  11. Open the Parameter Editor loading referenced parameter files from the current simulation. The Parameter Editor is explained in a section below.
  12. Open the Analysis Output window. The window will open if a simulation specifying analysis has run. The analysis window is explained in more detail below.
  13. Generate Docbook5 documentation of the simulation and store it into the project output folder.
  14. Clean and build the model. This is an alternative to doing this in Netbeans or the IDE being used.
  15. Open the last output folder using the computer operating system file explorer.
  16. Clear the console output for this simulation.
  17. Set logging level for the simulation. This will result in more or less verbose output during simulation execution.
  18. (Not shown) Create a SHA digital signature of the simulation and print the simulation fingerprint to the Analysis Output Window.

Each tab has a context menu that is accessible with a right mouse click. It allows saving, saving under a different name, closing, and other operations with respect to the selected tab.

OMS Console - Parameter Editor

The Parameter Editor is a visual tool for parameter editing that is embedded in the OMS console. It can be started by clicking on the appropriate button in the tool bar of a simulation tab. It allows for a presentation and filtering of parameter values, bulk editing of values, statistics, and basic spread sheet like operations.

The editor works on parameter files that adhere to the OMS CSV parameter file format. Such files can be easily edited with other external tools such as Excel, however the parameter editor provides an easy to use interface to manipulate parameter values numerically.

Note that only parameter files referenced as properties in the model parameter sub-element in a simulation using the .. parameter(file:'<name>') ... construct can be loaded into the Parameter Editor. Parameters and parameter files referenced as sub-elements of the parameter sub-element, that is, contained within curly brackets "{...}" cannot be loaded into the Parameter Editor.

The figure above shows the Parameter Editor with loaded parameters. The layout of the window is organized as follows.

Parameter File

This combo box shows the active parameter file for editing. When opened the combo box lists all parameter files as specified within parentheses of the parameter sub-element. The modeler should select the parameter file to view and edit.

Filter

The Filter combo box allows switching views on the parameters in the selected file. They can be filtered by dimension, by scalars, or all parameters can be presented as shown in this figure. Changing the filter will cause different parameters sets to diplay in the Parameter Editor panel.

Command Console

The command line on this console allows the (bulk) manipulation of parameter data. This command line has a history, a help function and offers more powerful methods of editing parameter values. This will be demonstrated in more detail during the workshop.

Parameter Editor Panel

This table shows the parameter names and values. The layout might change when different filter are applied. It has in-place editing capabilities, by clicking on a cell, it value can be edited and changed.

The figure above shows the parameter editor with an applied dimension filter. The table presents all parameters bound to a specific dimension. Selecting cells in the table will print basic statistics about those on the bottom of the window. Any area can be selected, a column selection will print statistics about the whole column at the bottom of the editor.

OMS Console - Analysis Output

The Analysis Output window graphically displays output defined in the analysis section of a simulation. It is executed by pressing the Analysis Button in the tool bar in a simulation tab. The following graphic shows a time series plot of simulated streamflow (red), observed runoff (green), and the difference between the simulated and observed values.

The tile bar shows the output folder containing the analysis data. Depending on the setting in <outputstrategy>, such output can be versioned or unversioned. With either setting, the last output folder of a simulation run is presented.

The analysis tabs contain the plots, graphs, and charts, such as timeseries, error, scatter, flowduration, and other analyses. The tab name reflects the analysis performed.

A part of the analysis section used to create the plots above is shown below.

...
analysis(title:"Simulation Output") {
    timeseries(title:"East Fork Carson", view: COMBINED) {
        x(file:"%last/out1.csv", column:"date")
        y(file:"%last/out1.csv", column:"basin_cfs")
        calc(eq:"simulated - observed") {
             simulated(file:"%last/out1.csv", column:"basin_cfs")
             observed(file:"%last/out1.csv", column:"runoff[0]")
        }
        y(file:"%last/out1.csv", column:"runoff[0]")
    }
     timeseries(title:"Error", view: MULTI ) {
...

Note the timeseries sub-element of analysis maps to the view of the plot graph above. Note the variable %last references the last output folder of a simulation run. The plot contains three y axes, one of which involves the calculation of simulated minus observed values.

To reiterate, the Analysis Output window displays graphics only if the analysis DSL element is specified in the simulation file.