Calculate Window 
 
Calc.pro is a simple scripting language for working with tplot variables which has been provided 
in a  form that is usable at the command line and from within the THEMIS GUI. This routine takes 
a string as input and interprets the string as a mini-language. This language can manipulate normal 
idl variables and tplot variables.  The idl variables that can be modified are non-system variables 
in the scope in which the procedure is called.

From within the GUI you can access this language by selecting Calculate from the Analysis pull down
menu in the main GUI window. The GUI Calculate window provides a graphical user interface to the 
scripting or 'mini language'.

The 'Program Area' text box on the left side of the window is editable. This is where you can 
enter statements. You can simply type the text directly into the box or you can use the Insert 
list boxes on the right hand side of the window.  Insert list boxes include variables, functions, 
operators, and a droplist menu for constants.  Whenever you make a selection within an Insert box, 
the text for that item will be entered in the programming area where ever the cursor is located.  

Here is an example of a mini language call:
"tha_state_pos_avg" = mean("tha_state_pos",2)

The command takes the average of each x,y,z triplet and stores the output in a new tplot variable 
that has dimensions time by 1 rather than time by 3(x,y,z).  

Examples of command line usage can be found in the file:
themis/examples/thm_crib_calc.pro

Please note that the example crib contains command line examples only.  To run an example from the crib 
in the GUI, simply remove the text, 'calc, ' which preceeds the statement. 
              
Examples:
    a = 5  
    "pos_re" = "tha_state_pos"/6374  
    a += 7 
    "tvar" = "tvar" + var 
    "tvar" = ln("tvar")
    "tvar" = total("tvar"+3,2)
    "tvar" = -a + 5.43e-7 ^ ("thb_fgs_dsl_x" / total("thb_fgs_dsl_x"))

 Notes:
    1. The language generally uses a fairly straightforward computational syntax.  The main
       difference from idl is that quoted strings are treated as tplot variables in this language
    2. A full specification of language syntax in backus-naur form can be found
       in the file bnf_formal.txt, the programmatic specification of this syntax
       can be found in productions.pro
    3. The language is parsed using an slr parser.  The tables required to do this parsing
       are generated and stored ahead of time in the files grammar.sav and parse_tables.sav
    4. The routines that describe the evaluation rules for the language can be found in the file
       mini_routines.pro
    5. If you want to modify the way the language works you'll probably need to modify productions.pro,
       regenerate the slr parse tables using save_calc_tables and modify/add routines to mini_routines.pro
    6. Arrays must have the same dimensions to be combined, and tplot variables must also have the same times.
    7. Procedures: min,max,mean,median,count,total  all take a second argument that allow you to select the
       dimension over which the operation is performed