You are a guest. Restricted access. Read more.
SCaVis manual

# Calculations with units

Calculations with units are performed using the Java class `jhplot.UCalc`. Here is the example of such calculations:

```from jhplot import *
u=UCalc()
s="2 hours + 23 min - 32 sec"
print s,"=",u.eval(s,"sec")  # "sec" is expected unit```

You will the the output with the correct number of seconds hat follows this expression.

One can make quite complicated calculations using the following constants:

```pi          ratio of circumference to diameter
c           speed of light
e           charge on an electron
h           Planck's constant```

and the following functions:

```ln        natural logarithm
log       base-10 logarithm
log2      base-2  logarithm
exp       exponential
sqrt      square root, sqrt(x) = x^(1/2)
cuberoot  cube root, cuberoot(x) = x^(1/3)```

Exponents are specified using the operator ^ or **.

Let us give a more complicated example:

```from jhplot import *
u=UCalc()
print u.eval("sqrt(10*50ft/90 (cm/s^2))","s")```

which will return “13.012814

Another example: let us find suppose you want to find the wavelength, in meters, of a 200 MHz radio wave. You can do it as:

```from jhplot import *
u=UCalc()
print u.eval("c / 200 MHz","m")```

which will print the correct wavelength.

You are not full member and have a limited access to this section. One can unlock this part after becoming a full member.