Scripting
The Console is capable of executing scripts written in the BeanShell language. This language has a syntax virtually identical to that of the Java language, making it easy to rewrite a script into a full program.
The Kernel class encapsulates (a growing subset of) all the commonly used Console algorithms into an easy to use, self-contained collection of methods. For example, reading a RV table and computing the fully integrated χ2 is as easy as:
// creates a new Kernel context and read RV table from file import systemic.*; Kernel k = new Kernel(); k.setMstar(2e33); k.addRVDataSet("data.vels"); // adds two planets double[][] els = new double[2][OESIZE]; els[0][PER] = 9.6; els[0][MASS] = 1.; els[0][ECC] = 0.15; els[1][PER] = 20.4; els[1][MASS] = 0.02; els[1][ECC] = 0.01; k.setElements(els); // uses Bulirsch-Stoer k.setIntMethod(7); k.calculate(); output.println(k.getChiSqr());Read the JavaDoc for a description of all the Kernel methods. A Class Browser is available in the GUI under Scripts -> Class Browser.
Running scripts from the command line
To run a script from the command line, use the following command:java -jar Console.jar script [arg1 arg2 ...]All command-line arguments are passed in a global String[] array named
args
.
Running scripts from the GUI
The GUI will automatically add all scripts placed in the scripts/ directory and ending with the .conscript extension to the "Script" menu. The current GUI state (loaded datasets, orbital configuration, velocity offsets, etc.) can be retrieved as a new Kernel object by calling the static methodKernel.getGUIState()