Source code for casatools.functional

#
# stub class definition file for docstring parsing
#

[docs]class functional: """ Functionals handling *Introduction* A functional is a function with parameters, defined as :math:`f(p;x)`, where :math:`p` are the parameters, and :math:`x` the arguments. Methods are available to calculate the value of a function for a series of argument values for the given set of parameters, and for the automatic calculation of the derivatives with respect to the parameters. The created functionals can be used in the fitting  or in any other  that needs to have generic function values or their derivatives. A functional has a mask associated with it, to indicate if certain parameters have to be solved for. See masks for details. Functionals are created in a variety of ways, in general by specifying the name of the functional, together with some necessary information like e.g. the order of a polynomial, or the code needed to compile your privately defined function. Parameters can be set at creation time or later. :: - a = fs.gaussian1d() # creates a 1D Gaussian, default arguments - b = fs.open('gaussian1') # creates the same one - a.state() # the 'state' of the functional [type=0, order=-1, ndim=1, npar=3, params=[1 0 1] ] - a.type() # its type gaussian1d - a.ndim() # its dimension (number of arguments) 1 - a.npar() # its number of parameters 3 - b.state() [type=0, order=-1, ndim=1, npar=3, params=[1 0 1] ] - a.f(1); # the value at x=1 0.0625 - a.fdf([0,0.5]); # value and derivatives [[1:2,] 1 1 0 0 0.5 0.5 1.38629 0.693147] In some cases an *order* can be specified as well (e.g. for polynomials): :: - a := dfs.poly(3) # creates a 3rd order polynomial - b := dfs.functional('polyn',3) # creates the same one, but with # original defaults - a.state() [type=5, order=3, ndim=1, npar=4, params=[1 1 1 1] ] - b.state() [type=5, order=3, ndim=1, npar=4, params=[0 0 0 0] ] An extremely valuable aspect of the Functionals module is the ability to create a functional from a compiled string specifying an arbitrary function. For example, let us make our own polynomial :math:`1 + 2*x + 3*x^2` and evaluate it at a few abcissa locations :: - a := dfs.compiled ('p0 + p1*x + p2*x*x', [1,2,3]) # Define - a.f([0,10,20]) # Evaluate at x=[0,10,20] [1 321 1241] The functions created can also be used to specify the function to be fitted in a least squares fit (see the fitting  ). """
[docs] def functional(self): """ Construct a functional tool Create a {\tt functional} tool. """ pass
[docs] def f(self, x=0): """ Calculate the value of the functional. .. rubric:: Parameters - ``x ({double, doubleArray}=0)`` - real argument values """ pass
[docs] def ndim(self): """ Get the number of dimensions Return the number of dimensions. """ pass
[docs] def done(self): """ Free resources of the functional Free the functional's resources. """ pass
[docs] def gaussian1d(self, amplitude=1, center=0, fwhm=1): """ Create and return a new functional tool representing a 1D Gaussian function Create a 1-dimensional Gaussian with the specified amplitude, fwhm, and center. .. rubric:: Parameters - ``amplitude (double=1)`` - amplitude of Gaussian - ``center (double=0)`` - center of Gaussian - ``fwhm (double=1)`` - FWHM of Gaussian """ pass
[docs] def gaussian2d(self, amplitude=1, center=[-1], fwhm=[-1], pa='0'): """ Create a 2D Gaussian function Create a 2-dimensional Gaussian with the specified amplitude, fwhms, and center. The created functional has method {\em f} to calculate the function value at a series of {\em x, y} values, or the value. .. rubric:: Parameters - ``amplitude (double=1)`` - Amplitude of Gaussian - ``center (doubleArray=[-1])`` - Center (x,y) position. Must have exactly 2 elements. - ``fwhm (doubleArray=[-1])`` - FWHM of the axes. Must have exactly 2 elements. - ``pa ({string, doubleQuant}='0')`` - The angle between the positive y axis and the major axis, measured counterclockwise. """ pass
[docs] def polynomial(self, coefficients=[0]): """ Create and return a new functional tool representing a 1D polynomial function, y = c_0 + c_1*x + c_2*x**2 + ... + c_n*x**n Create a 1-dimensional polynomial function with the specified coefficents. .. rubric:: Parameters - ``coefficients (doubleArray=[0])`` - Array of coefficients. Number of coefficients determines order of polynomial. """ pass
[docs] def powerlogpoly(self, coefficients=[0]): """ Create and return a new functional tool representing a 1D power log polynomial function, y = c_0 * x**( c_1 + c_2*ln(x) + c_3*ln(x)**2 + ... c_n*ln(x)**(n-1) Create a 1-dimensional power log polynomial function with the specified coefficents. .. rubric:: Parameters - ``coefficients (doubleArray=[0])`` - Array of coefficients. """ pass