THE IGR CALCULATOR

Calculator basic :

The igr client reads the data from the data base handler (dbh) into the quanties (q0, q1, ... , q131).
The data is then transferred to the plots (p0, p1, ... , p131).
The data in the plots are then plotted on the screen, and if printing (File->Print) is selected, to a postscript file.
Both the quantities and the plots are data structures which contains the data and information of the data.

Calculator
Normally the data is transferred directly from the quantities to the plots.

p0y = q0 (A binding is done from quantity 0 to plot 0)
p1y = q0 (A binding is done from quantity 1 to plot 1)
...
pny = qn

Select calculator
When pressing the Select->Calculator in the igr menubar the igr calculator Dialog appears.

Calculator
The expressions are typed in the text field at the top of the window, (input text line). When pressing the enter key on your keyboard, or the Apply button in the window the Calculator test the expression typed.
If it can be executed, the result will be seen in the text field in the middle of the window (plot text field).
If the Calculator finds some error, it writes a message in the Error message text line at the bottom of the window. At the same time the keyboard cursor is placed at the error in the input text line.

The expression usually have plots on the left side of the = , and quantities on the right side of the = . The = indicates the binding between the quantity q* and the plot p*y.

When the Update in the ISDAT time manager ctm is pressed, the equations in the plot text field in the Calculator defines what is plotted in the panels in the igr client.

Usually when plotting data in the igr client we have data values along the y-axis (p*y) and time along the x-axis. However we are also allowed to plot a quantity as a function of another quantity.

p0y = q0
p0x = q1
In this case we plot the data in quantity 0 as function of the data in quantity 1.

If you want to edit one of the line in the plot text field (middle panel), double-click with your left mouse button on the line.
This will copy the line up into the input text line (top line). Then you can edit it. Pressing the enter key on your keyboard, or the Apply button in the window the Calculator test the expression changed. If it can be executed, the changes will be seen in the plot text field.

Clear input line
To clean the input text line choose Clean input line under the Edit menu.
Clear marked plot
To erase one or more bindings/plots, and still keep the other, mark those bindings by clicking on them with the mouse in the plot text field. Then, in the Edit menu, select Clear marked plot. The marked bindings will then disappear. To take away an unwanted marking of a binding, point on that binding with the mouse and press the control key and the left button on the mouse.
Clear all
To take away all bindings and make the plot text field clean, choose Release all bindings under the Edit menu. In this case nothing is plotted.

Operators :

On the right side of the = have arithmetic operations between quantities, e.g.
p0y = q0 + q1
The + is an arithmetic operator which add each sample in the quantities q0 and q1.

The built in arithmetic operators in the Calculator is :

- -q0 negate all samples in q0
+ q0 + q1 add each sample in q0 and q1
* q0 * q1 multiply each sample in q0 and q1
/ q0 / q1 divide each sample in q0 with each sample in q1
X q0 X q1 make cross product between each sample in q0 and q1
join join(q0,q1) put all samples in q1 on the timeline/timetags used by q0
( ) (q1 + q0)/2 compute the expression between () first
pol_r pol_r(q0) norm r=sqrt(x^2 + y^2 + z^2) ; q0 is a vector (x,y,z)
pol_phi pol_phi(q0) phi = arctan(y/x) ; q0 is a vector (x,y,z)
pol_th pol_th(q0) theta = arccos(z/r) ; q0 is a vector (x,y,z)
re re(q0) returns the real part of complex variable
im im(q0) returns the imaginary part of complex variable
avg avg(q0) average spectra ; q0 is an array

Precedence:
Unary minus has the highest precedence.
* and / have higher precedence than + and - .
To override this precedence scheme use parenthesis.

Joining of data:
Joining will be performed if needed.
Example:

p0y = q0 + q1,
If q0 and q1 do not have the same number of samples or the sample times are not the same,
the Calculator will automatically join the least sparse of the two quantities
to the same time line as the most sparse one.

Constants:
Also constants can be used in the expressions, e.g. 3.14159265 .
Example:

p0 = (q1 + q2) / 2.0
p4y = q4 * 6371.2

External operators

In the ISDAT program it is possible for the user to write his own operator. In the $ISDAT_HOME/operators directory is many user written operators. Examples are av, sin, cos, asin, sqrt, fft, despin, ... .

To see what external operators you have compiled for your ISDAT system:
Press the Operator pulldown menue in the igr calculator window.

(If you have downloaded some operators from the ISDAT CVS to the $ISDAT_HOME/operators directory, remember to update the Imakefile in $ISDAT_HOME/operators directory. Then recompile the whole $ISDAT_HOME with make isdat in $ISDAT_HOME.)

Calculator
Some of the operators have their own Dialog window. To see this Dialog window mark the operator with the left mouse button in the input text line in the igr calculator window. Then press Edit-> Operator. Then if the operator contains a Dialog window it will show up.

In this figure we have shown how to display the fft Dialog window. (Be careful only to mark the correct characters, only the name of the operator.)

Temporary variable :

The igr calculator also have 10 temporary quantities: v0, v1, ... , v9,v10..... These can be used for storing a temporary variable in the Calculator.
example:
v0 = despin(q0)
p0y = v0[1]
(Actually we are allowed to use 132 temporary variables, v0, v1 .. v131.)

Variable types :

The main variable types (for each data points in the quantity) in Isdat, read by igr and handled by the Calculator are: scalar, vector and arrays/spectra.

scalar (rank 0 , dimension 0)

A scalar value is one single float value for each sample. All built in operators except X, pol_r, pol_phi, pol_th works on the scalar.

vector (rank 1, dimension 0)

A vector sample consists of three components, q0[0], q0[1] and q0[2] .
When plotting a vector q0 the value, ( |q0| , norm):
sqrt(q0[0]*q0[0] + q0[1]*q0[1] + q0[2]*q0[2])
is plotted. However the user can extract each value, e.g. p0y = q[1]
All built in operators (except re, im and avg,) works on a vector. As an example if we in the Calculator with two vectors writes:
p0y = q0 + q1
The operations performed are p0y[i] = q0[i] + q1[i] , i = 1,2,3

array/spectra (rank 0, dimension 1)

An array/spectra sample consists of an array of data values for each sample. The output from the fft operator is an array/spectra. The operators - +, * and avg works on arrays. It is possible in the Calculator to extract each single element in the spectra.
v0 = fft(q0)
p0y = v0[10]
This extract the eleventh bin in each of the spectra.
(However, the data output (p0y) has the original labels from the fft on the X and Y axis. )

Some tips on Cluster data :

x,y and z components of a vector

Many of the quantities in the Cluster data are vectors. They are then usually x, y and z components. To extract each component perform the p4y = q4[0] for the x-component, p5y = q4[1] for the y-component, and p6y = q4[2] for the z-component. (The above example assumes the quantity number four contains the vector)

Example:
  q0 is "CSDS_PP C1 FGM B_xyz_gse__C1_PP_FGM"
  Then q0[0] is Bx
       q0[1] is By
       q0[2] is Bz

Example:
  q4 is "Cluster 1 ephemeris position"
  Then q4[0] / 6371.2 is the x position (GSE) of the satellite in Re
       q4[1] / 6371.2 is the y position (GSE) of the satellite in Re
       q4[2] / 6371.2 is the z position (GSE) of the satellite in Re


Updated Feb 16, 2009 by Bjørn Lybekk