[Kst] Scripting plan

Barth Netterfield netterfield at astro.utoronto.ca
Wed Mar 9 17:12:47 CET 2005

Yesterday, George, MAMD, and I met to discuss the scripting language for kst.  
A proposal is in kdeextragear-2/kst/devel-docs/scripting.txt.

All interested parties are encouraged to comment while it is easy to 
change :-)

Javascript Definition:

A planck-HFI reqirement is that kst support scripting to allow flexable
generation of complex plots.  We plan to use JavaScript as excellent
facilities for this exist within KDE.

- Complete bindings to all objects
        - everything that can be done in a .kst file can be done with a
- DCOP based commandline tool with konsole
        - will provide a 'command line' to kst (like sm or idl)
        - Can be commanded from either an embedded konsole, or an external
- Multiple ways of entering scripts
        - from command line when starting kst
                eg: kst -J "file=\"data.dat\";field=\"N15C2\"" bolo.js
        - From file menue
        - From DCOP/command line tool.
- We will not use automatic bindings.  Instead, we will "ideal" bindings
  and implement them as internal calls to our internal objects
- The update thread doesn't run if the interpreter is running, and blocks the
  interpreter from starting up during an update There will be a force
  update/repaint mechanism to allow updates during script interpretation.
- vectors can be referenced as strings (tagname) everywhere too

Open Questions:
- kjsembed or qsa?

A plot with points + error bars, and a line fit.
The X axis vector has to be re-scaled.

var f = File.load("Data.dat");

var Vx = DataVector(f, "1");
string Vn = DataVector(f, "2").tag; // refer to this vector w/ its tagname
var Vp = DataVector(f, "3");
var Vm = DataVector(f, "4");

var Ex = Equation("[" + Vx.tag + "] * 0.0042", Vx);

var C = Curve(Ex.sv, Vn);
C.hasPoint = true;
C.hasLines = false;
C.setYError(Vp, Vm);

var lfit = fit("kstfit_linear_unweighted", Ex.sv, Vn); // convenience class

var Cf = Curve(Ex.sv, lfit.Y_Fitted);

var P = Plot();

P.addCurve(C);  // ordering etc.............  P.curves.append() etc?

P.xLabel.text = "x axis";
P.yLabel.text = "y axis";

L = PlotLabel(lfit.parameterstring);
L.setPos(0.2, 0.8);


More information about the Kst mailing list