On 20/07/12 10:20, Paul Cardinaels wrote: > Hi all, > > I have been using Veusz for some years now and it has always helped me > in producing high quality graphs for my reports. > Now that I have started my graduation project in fluid dynamics I have > come across some problems that depend on the error function: > http://en.wikipedia.org/wiki/Error_function > > Is there a quick/easy way to use it in Veusz? I can't seem to find it.
If you're using Veusz from source (or in a linux distribution), you can get it from scipy if you have scipy installed (import from scipy.special in the custom definitions dialog). If you're using the binary distribution, there are some hacks to get veusz to see an installed version of scipy (I can provide some hints if you're interested). There's a simpler alternative, which is to use a python module to compute erf (to some precision). Here's some code, adapted from http://stackoverflow.com/questions/457408/is-there-an-easily-available-implementation-of-erf-for-python It seems to work for me (check, please!). Put it in a .py file. Go to the custom definition dialog, add a custom import. The problem might be that veusz can't find this file and you need to set the PYTHONPATH environment variable to find it. I should add an option to allow explicit paths to be included, or to set PYTHONPATH. You can set it to be loaded automatically in the options dialog with a custom definitions file. I think it could be compressed to one line and entered as a function instead, if anyone feels like rewriting it. Jeremy ----------------------------------- import numpy as np def erf(x): # save the sign of x sign = np.sign(x) sign[ sign == 0 ] = 1 x = np.abs(x) # constants a1 = 0.254829592 a2 = -0.284496736 a3 = 1.421413741 a4 = -1.453152027 a5 = 1.061405429 p = 0.3275911 # A&S formula 7.1.26 t = 1.0/(1.0 + p*x) y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*np.exp(-x*x) return sign*y # erf(-x) = -erf(x) _______________________________________________ Veusz-discuss mailing list [email protected] https://mail.gna.org/listinfo/veusz-discuss
