[portland] Using log() programmatically

Rich Shepard rshepard at appl-ecosys.com
Fri Sep 28 20:15:01 CEST 2007

   One of our applications uses wxPython as the UI. One of the widgets is a
drop-down combo box list of scaling factors for variables. The choices in
that widget are strings, which do not allow for mathematical computation.

   I've created a dictionary that associates numbers and log functions with
the appropriate key strings:

self.scaleDict = {'x 1': 1, 'x 10': 10, 'x 100': 100, 'x 1,000': 1000,
                       'x 10,000': 10000, 'x log 10': log(), 'x log 2': log(,2),
                       'x log e': log(e)}

   What I want to do is look up the selected key for that variable, then
adjust a numeric value by multiplying, or taking the logarithm, by the value
of the key. Doing this for the multipliers is easy enough, but I've no idea
how to use the logs.

   On a related issue, I thought that I'd replace log2 and log(e) (the
natural log) with numbers as values in the dictionary, but ipython keeps
telling me that log() and log10() are not defined, even after importing

   Pointers much appreciated.


Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.        |         Accelerators(TM)
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863

More information about the Portland mailing list