Syntax:

-expr var"="expression

Example 1.
$ ./vartools -i EXAMPLES/1 -expr 'mag=sqrt(mag+5)' -o EXAMPLES/1.add

EXAMPLES/1

$ head -3 EXAMPLES/1

53725.173920 10.085 0.00119
53725.176540 10.0847 0.00144
53725.177720 10.0825 0.00123

$ head -3 EXAMPLES/1.add

  53725.173920000   3.88394   0.00119
  53725.176540000   3.88390   0.00144
  53725.177720000   3.88362   0.00123

Use the vartools analytic expression evaluation command -expr to add a constant (in this case 5) to all the magnitude values in the light curve EXAMPLES/1, and then take the square root. Write out the result to EXAMPLES/1.add. The two "head" calls show how the light curve is affected.

Example 2.
$ ./vartools -l EXAMPLES/lc_list -header \
    -LS 0.1 10. 0.1 1 0 \
    -rms -chi2 \
    -expr 'mag2=mag' \
    -Killharm ls 0 0 0 \
    -rms -chi2 \
    -expr \
        'mag=(Npoints_5*(Chi2_6-Chi2_2)<-10000)*mag+
            (Npoints_5*(Chi2_6-Chi2_2)>=-10000)*mag2' \
    -o EXAMPLES/OUTDIR1 nameformat '%s.cleanharm'

#Name LS_Period_1_0 Log10_LS_Prob_1_0 LS_SNR_1_0 Mean_Mag_1 RMS_1 Expected_RMS_1 Npoints_1 Chi2_2 Weighted_Mean_Mag_2 Killharm_Mean_Mag_4 Killharm_Period_1_4 Killharm_Per1_Fundamental_Sincoeff_4 Killharm_Per1_Fundamental_Coscoeff_4 Killharm_Per1_Amplitude_4 Mean_Mag_5 RMS_5 Expected_RMS_5 Npoints_5 Chi2_6 Weighted_Mean_Mag_6
EXAMPLES/1     0.97821072 -452.25157   41.33409  10.24745   0.15944   0.00101  3122  34711.71793  10.24430  10.29306     0.97821072  -0.08947  -0.17167   0.38717  10.24061   0.08469   0.00101  3122   8276.59620  10.24430
EXAMPLES/2     1.23440877 -704.49194   58.45119  10.11802   0.03663   0.00102  3313   1709.50065  10.11178  10.12217     1.23440877   0.05008  -0.00222   0.10026  10.11176   0.00231   0.00102  3313      6.51484  10.11178
EXAMPLES/3     1.14786351  -30.00548   15.74701  10.16674   0.00490   0.00104  3417     27.06322  10.16684  10.16696     1.14786351  -0.00104   0.00073   0.00253  10.16671   0.00479   0.00104  3417     26.12389  10.16684
EXAMPLES/4     0.93414718  -56.81460   12.51470  10.35142   0.00209   0.00114  3227      5.19874  10.35137  10.35140     0.93414718   0.00077   0.00053   0.00188  10.35141   0.00200   0.00114  3227      4.66738  10.35137
EXAMPLES/5     7.40645262  -53.86771   10.01489  10.43962   0.00288   0.00114  3903      8.26418  10.43932  10.43945     7.40645262  -0.00047  -0.00103   0.00227  10.43963   0.00278   0.00114  3903      7.47762  10.43932
EXAMPLES/6     0.96306814  -42.42348   10.53479  10.52762   0.00209   0.00121  3933      3.94650  10.52748  10.52775     0.96306814   0.00071   0.00042   0.00165  10.52756   0.00203   0.00121  3933      3.67621  10.52748
EXAMPLES/7     0.32704113  -11.84669    4.77871  10.56966   0.00349   0.00116  3626     10.39941  10.56951  10.56958     0.32704113  -0.00041   0.00043   0.00119  10.56964   0.00346   0.00116  3626     10.24368  10.56951
EXAMPLES/8     3.07991099  -88.30735   15.34709  10.61152   0.00225   0.00125  3957      4.19887  10.61132  10.61144     3.07991099  -0.00078  -0.00013   0.00158  10.61142   0.00213   0.00125  3957      3.93631  10.61132
EXAMPLES/9     7.23420953  -37.93155   14.15476  10.73139   0.00187   0.00133  3954      2.67020  10.73129  10.73141     7.23420953   0.00062   0.00002   0.00124  10.73138   0.00182   0.00133  3954      2.51788  10.73129
EXAMPLES/10     0.96906857  -40.55309   11.32727  10.87781   0.00236   0.00143  3974      3.72218  10.87763  10.87782     0.96906857  -0.00078  -0.00048   0.00183  10.87775   0.00230   0.00143  3974      3.48930  10.87763

An example of using the vartools analytic expression evaluation command, together with other commands, to fit a sinusoid signal to various light curves and subtract the signal only for cases where the sinusoid shows a significant delta chi2 improvement over the flat model. Here the -LS command is used to find a periodic signal, the first call to -expr copies the light curve magnitudes to a new vector variable mag2, -Killharm fits and subtracts a sinusoid model from mag, -chi2 and -rms are calculated on the residuals (currently stored in mag), and the second call to -expr sets the magnitude to the residuals if there is a significant chi2 improvement (Npoints_5*(Chi2_6-Chi2_2)<-10000), or back to the original magnitudes if the improvement is not significant (>=-10000). Note that the '<' and '>=' will evaluate to 1 (0) when true (false). One could alternatively use an -if, -else, and -fi construct to achieve a similar result.

Example 3.
$ ./vartools -i EXAMPLES/1 \
    -expr 'flux=10^(-0.4*(mag-25.0))' \
    -stats flux median \
    -expr 'flux=flux/STATS_flux_MEDIAN_1' \
    -stats flux,mag median,stddev \
    -oneline

Name                = EXAMPLES/1
STATS_flux_MEDIAN_1 = 842674.79516438092
STATS_flux_MEDIAN_3 = 1
STATS_flux_STDDEV_3 = 0.1290865428119792
STATS_mag_MEDIAN_3  = 10.18585
STATS_mag_STDDEV_3  = 0.15946976931434606

In this example we use the -expr command to convert the magnitudes in a light curve to fluxes. We then use -stats to compute the median flux, and the second -expr command to normalize the flux by its median value. The final call to stats then calculates the median and standard deviations of the magnitudes and fluxes.