Module gwy :: Class ShapeFitPreset
[hide private]
[frames] | no frames]

Class ShapeFitPreset

source code

Instance Methods [hide private]
 
needs_same_units()
Reports if a 3D geometrical shape fitter preset requires the same lateral and value units.
source code
 
get_nparams()
Reports the number of parameters of a 3D geometrical shape fitter preset.
source code
 
get_param_name(i)
Gets the name of a fitting parameter of a 3D geometrical shape fitter preset.
source code
 
get_param_description(i)
Gets the description of a fitting parameter of a 3D geometrical shape fitter preset.
source code
 
get_param_flags(i)
Gets the properties of a fitting parameter of a 3D geometrical shape fitter preset.
source code
 
get_param_units(i, siunit_xy, siunit_z)
Derives the SI unit of a fitting parameter from the units of abscissa and ordinate.
source code
 
get_param_power_xy(i)
Gets the power of abscissa units in a shape fitting parameter.
source code
 
get_param_power_z(i)
Gets the power of ordinate units in a shape fitting parameter.
source code
 
get_nsecondary()
Reports the number of secondary (derived) quantities of a 3D geometrical shape fitter preset.
source code
 
get_secondary_name(i)
Gets the name of a secondary (derived) quantity of a 3D geometrical shape fitter preset.
source code
 
get_secondary_description(i)
Gets the description of a secondary quantity of a 3D geometrical shape fitter preset.
source code
 
get_secondary_flags(i)
Gets the properties of a secondary (derived) quantity of a 3D geometrical shape fitter preset.
source code
 
get_secondary_units(i, siunit_xy, siunit_z)
Derives the SI unit of a secondary (derived) quantity from the units of abscissa and ordinate.
source code
 
get_secondary_power_xy(i)
Gets the power of abscissa units in a shape fitting secondary (derived) quantity.
source code
 
get_secondary_power_z(i)
Gets the power of ordinate units in a shape fitting secondary (derived) quantity.
source code
 
setup(points, n, params)
Initialises parameter values of a 3D geometrical shape fitter preset.
source code
 
get_value(x, y, params)
Calculates the value of a 3D geometrical shape fitter preset in a single point.
source code
 
fit(fitter, points, n, params, fixed_param, rss)
Performs a non-linear least-squares fit with a 3D geometrical shape fitter.
source code
Method Details [hide private]

needs_same_units()

source code 

Reports if a 3D geometrical shape fitter preset requires the same lateral and value units.

For instance, fitting a sphere is meaningless if the horizontal and vertical radii would be different physical quantities.

Returns:
True if the function requires the same lateral and value units. (bool)

Since: 2.47

get_nparams()

source code 

Reports the number of parameters of a 3D geometrical shape fitter preset.

Returns:
The number of function parameters. (int)

Since: 2.47

get_param_name(i)

source code 

Gets the name of a fitting parameter of a 3D geometrical shape fitter preset.

The name may contain Pango markup.

Parameters:
  • i - Parameter number. (int)
Returns:
The name of the i-th parameter. (string)

Since: 2.47

get_param_description(i)

source code 

Gets the description of a fitting parameter of a 3D geometrical shape fitter preset.

The description may contain Pango markup. It may also be None if the parameter is currently undescribed.

Parameters:
  • i - Parameter number. (int)
Returns:
The description of the i-th parameter, possibly None. (string)

Since: 2.61

get_param_flags(i)

source code 

Gets the properties of a fitting parameter of a 3D geometrical shape fitter preset.

Parameters:
  • i - Parameter number. (int)
Returns:
The flags of the i-th parameter. (NLFitParamFlags)

Since: 2.47

get_param_units(i, siunit_xy, siunit_z)

source code 

Derives the SI unit of a fitting parameter from the units of abscissa and ordinate.

Note that angle parameters are by default in radians and thus unitless. If you want to convert them to degrees for presentation to the user you must do it explicitly.

Parameters:
  • i - Parameter number. (int)
  • siunit_xy - SI unit of lateral coordinates. (SIUnit)
  • siunit_z - SI unit of values. (SIUnit)
Returns:
A newly created SIUnit with the units of the i-th parameter. (SIUnit)

Since: 2.47

get_param_power_xy(i)

source code 

Gets the power of abscissa units in a shape fitting parameter.

Usually it is easier to let ShapeFitPreset.get_param_units() derive the parameter units.

Parameters:
  • i - Parameter number. (int)
Returns:
The power of abscissa in the parameter. (int)

Since: 2.50

get_param_power_z(i)

source code 

Gets the power of ordinate units in a shape fitting parameter.

Usually it is easier to let ShapeFitPreset.get_param_units() derive the parameter units.

Parameters:
  • i - Parameter number. (int)
Returns:
The power of ordinate in the parameter. (int)

Since: 2.50

get_nsecondary()

source code 

Reports the number of secondary (derived) quantities of a 3D geometrical shape fitter preset.

Returns:
The number of secondary quantities. (int)

Since: 2.47

get_secondary_name(i)

source code 

Gets the name of a secondary (derived) quantity of a 3D geometrical shape fitter preset.

The name may contain Pango markup.

Parameters:
  • i - Secondary quantity number. (int)
Returns:
The name of the i-th secondary quantity. (string)

Since: 2.47

get_secondary_description(i)

source code 

Gets the description of a secondary quantity of a 3D geometrical shape fitter preset.

The description may contain Pango markup. It may also be None if the quantity is currently undescribed.

Parameters:
  • i - Secondary quantity number. (int)
Returns:
The description of the i-th secondary quantity, possibly None. (string)

Since: 2.61

get_secondary_flags(i)

source code 

Gets the properties of a secondary (derived) quantity of a 3D geometrical shape fitter preset.

Parameters:
  • i - Secondary quantity number. (int)
Returns:
The flags of the i-th secondary quantity. (NLFitParamFlags)

Since: 2.47

get_secondary_units(i, siunit_xy, siunit_z)

source code 

Derives the SI unit of a secondary (derived) quantity from the units of abscissa and ordinate.

Note that angle parameters are by default in radians and thus unitless. If you want to convert them to degrees for presentation to the user you must do it explicitly.

Parameters:
  • i - Secondary quantity number. (int)
  • siunit_xy - SI unit of lateral coordinates. (SIUnit)
  • siunit_z - SI unit of values. (SIUnit)
Returns:
A newly created SIUnit with the units of the i-th secondary quantity. (SIUnit)

Since: 2.47

get_secondary_power_xy(i)

source code 

Gets the power of abscissa units in a shape fitting secondary (derived) quantity.

Usually it is easier to let ShapeFitPreset.get_secondary_units() derive the quantity units.

Parameters:
  • i - Secondary quantity number. (int)
Returns:
The power of abscissa in the secondary quantity. (int)

Since: 2.50

get_secondary_power_z(i)

source code 

Gets the power of ordinate units in a shape fitting secondary (derived) quantity.

Usually it is easier to let ShapeFitPreset.get_secondary_units() derive the quantity units.

Parameters:
  • i - Secondary quantity number. (int)
Returns:
The power of ordinate in the secondary quantity. (int)

Since: 2.50

setup(points, n, params)

source code 

Initialises parameter values of a 3D geometrical shape fitter preset.

The parameters are quickly set to reasonable values that roughly correspond to the ranges of the data points. They may serve as starting values for manual experimentation but often will not be good enough as initial parameter estimates for the fit. See also ShapeFitPreset.guess().

Parameters:
  • points - Array of XYZ data to fit. (const-XYZ*)
  • n - Number of data points. (int)
  • params - The array to fill with initialised parameter values. (gdouble*)

Since: 2.47

get_value(x, y, params)

source code 

Calculates the value of a 3D geometrical shape fitter preset in a single point.

If you want multiple values you should use either ShapeFitPreset.calculate_z() or ShapeFitPreset.calculate_xyz() instead of calling this function in a cycle.

Parameters:
  • x - X-coordinate. (float)
  • y - Y-coordinate. (float)
  • params - Fitting parameter values. (const-gdouble*)
Returns:
The calculated function value in (x,y). (float)

Since: 2.47

fit(fitter, points, n, params, fixed_param, rss)

source code 

Performs a non-linear least-squares fit with a 3D geometrical shape fitter.

If you pass None fitter the function creates one for you and immediately performs the fit. If you want to modify the fitter settings beforehand or set callback functions create it using ShapeFitPreset.create_fitter() and pass to this function. The fitter must be created for the same preset.

Additional quantities such as parameter errors or the correlation matrix can be obtained from the fitter. See gwy_math_nlfit_fit_full() for details.

Parameters:
  • fitter - A Marquardt-Levenberg nonlinear fitter already initialized for preset's function, or None. (MathNLFit*)
  • points - Array of n XYZ data defining the lateral coordinates and values to fit. (const-XYZ*)
  • n - Number of items in points. (int)
  • params - Fitting parameters filled with initial estimates (the fitting starts from the provided values). (gdouble*)
  • fixed_param - Which parameters should be treated as fixed (set corresponding element to True for them). May be None if all parameters are free. (const-gboolean*)
  • rss - Location to store the residual sum of squares, as returned by gwy_math_nlfit_fit_idx(), may be None. (gdouble*)
Returns:
Either fitter itself, or a newly created fitter if it was None. (MathNLFit*)

Since: 2.47