Next: Operators for Opus Expressions
Up: Expressions
Previous: Variable Names in Expressions
Index
Unary Functions for Opus Expressions
There are a set of unary functions defined to use in expressions, as
follows. These all operate on numpy arrays.
- clip_to_zero
- Returns the input values with all negative values
clipped to 0.
- exp
- Returns an array consisting of
raised to the input
values.
- ln
- Returns an array of natural logarithms. Input values of 0
result in 0. (The intent is that this function be used on arrays of
values, where 0 denotes a missing value. However, be cautious -- as you
approach 0 from the positive side, the result value becomes more and more
negative, and then suddenly returns to 0 at 0.)
- ln_bounded
- Returns an array of natural logarithms. Values
less than 1 result in 0.
- ln_shifted
- Returns an array of natural logarithms. The input
values are shifted by the second argument before taking the log. (The
default shift value is 1.)
- ln_shifted_auto
- If the input values includes values that are
less than or equal to 0, they are shifted so that that the minimum of the
shifted values is 1 before taking the log. Otherwise the log is taken on
the original values.
- sqrt
- Returns an array of square roots. Values less than 0
result in 0.
In addition, all of the functions in numpy are available. To avoid name
collisions, the function name in an expression must include the package
name numpy. For example, this expression gives you the reciprocals
of all the values in a variable v:
numpy.reciprocal(v)
Next: Operators for Opus Expressions
Up: Expressions
Previous: Variable Names in Expressions
Index
info (at) urbansim.org