FunctionObject (and Subclasses)

Overview

Each image function used in the various Imfit programs is a subclass of an abstract base class called FunctionObject. Subclasses are defined for specific 2D image functions, each of which computes pixel intensity values based on input parameters and pixel coordinates. An instance of the ModelObject class holds a std::vector of pointers to one or more FunctionObjects, and constructs a model image by iterating over this vector.

When a model image is being computed, the first step is to call each FunctionObject instance’s Setup() method and pass in the current array of parameter values, as well as the central position (x0,y0) for the current function block. In practice, the entire parameter vector for the model is passed in, along with an integer offset telling the FunctionObject instance where to look for its particular parameter values.

Then the caller requests intensity values for individual pixels by repeatedly calling the GetValue() method and passing in the current pixel coordinates.

The main methods of this class are:

  • Setup() – Called by ModelObject to pass in the current parameter vector at the beginning of the computation of a model image; this allows the image function to store the relevant parameter values and do any useful computations that don’t depend on pixel position.

  • GetValue() – Called by ModelObject once for each pixel in the model image, to pass in the current pixel values (x,y); the image function uses these to compute and return the appropriate intensity value for that pixel.

    Many FunctionObject subclasses have additional private methods that do most of the calculations for each GetValue() call.

Note that the base class includes variant virtual methods for possible 1D subclasses, though Imfit does not use any of these.

API

Files: function_objects/function_object.h, function_objects/function_object.cpp

class FunctionObject

Virtual base class for function objects (i.e., 2D image functions)

Subclassed by BrokenExponential, BrokenExponential2D, BrokenExponentialBar, BrokenExponentialDisk3D, CoreSersic, DoubleBrokenExponential, EdgeOnDisk, EdgeOnDiskN4762, EdgeOnDiskN4762v2, EdgeOnRing, EdgeOnRing2Side, Exponential, ExponentialDisk3D, FerrersBar2D, FerrersBar3D, FlatBar, FlatExponential, FlatSky, Gaussian, GaussianExtraParams, GaussianRing, GaussianRing2Side, GaussianRing3D, GaussianRingAz, GenExponential, GenSersic, LogSpiral, LogSpiral2, LogSpiralGauss, ModifiedKing, ModifiedKing2, Moffat, N4608Disk, NaNFunc, PointSource, Sersic, TiltedSkyPlane, TriaxBar3D

Public Functions

FunctionObject()

Basic constructor: sets functionName and shortFunctionName.

bool HasExtraParams()

Boolean function: returns true if function can accept optional extra parameters (default = false)

int SetExtraParams(map<string, string>&)

Set optional extra parameters.

bool ExtraParamsSet()

Boolean function: returns true if optional extra parameters have been set.

bool IsPointSource()

Returns true if function models point sources (e.g., PointSource class)

void AddPsfData(double *psfPixels, int nColumns_psf, int nRows_psf)

Tell point-source function about PSF image data.

void AddPsfInterpolator(PsfInterpolator *theInterpolator)

Pass in pointer to PsfInterpolator object (for point-source classes only)

string GetInterpolationType()

Returns string with name of interpolation type (point-source classes only)

void SetOversamplingScale(int oversampleScale)

Sets internal oversamplingScale to specified value (for use in oversampled regions)

void SetSubsampling(bool subsampleFlag)

Turn pixel subsampling on or off (true = on, false = off).

void SetZeroPoint(double zeroPoint)

Used to specify a magnitude zero point (for 1D functions).

void SetLabel(string &userLabel)

Used to specify a string label for a particular function instance.

void Setup(double params[], int offsetIndex, double xc, double yc)

Base method for 2D functions: pass current parameters into the function object, storing them for when GetValue() is called, and pre-compute useful quantities. The parameter array params contains all parameters for all components in the overall model; offsetIndex is used to select the correct starting point for this component’s parameters.

void Setup(double params[], int offsetIndex, double xc)

Base method for 1D functions: pass current parameters into the function object, storing them for when GetValue() is called, and pre-compute useful quantities. The parameter array params contains all parameters for all components in the overall model; offsetIndex is used to select the correct starting point for this component’s parameters.

double GetValue(double x, double y)

Base method for 2D functions: Compute and return actual function value at pixel coordinates (x,y). This will be called once per pixel.

double GetValue(double x)

Base method for 1D functions: Compute and return actual function value at specified value of independent variable x.

bool IsBackground()

Returns true if class can calculate total flux internally.

bool CanCalculateTotalFlux()

Returns true if class can calculate total flux internally.

double TotalFlux()

Returns total flux of image function, given most recent parameter values.

string GetDescription()

Return a string containing function name + short description.

string &GetShortName()

Return a string containing just the function name.

string &GetLabel()

Return a string containing just the function label (will be “” if not set).

void GetParameterNames(vector<string> &paramNameList)

Add this function’s parameter names to a vector of strings.

int GetNParams()

Get number of parameters used by this function.

Protected Attributes

int nParams

number of input parameters that image-function uses

Protected Static Attributes

const char shortFuncName[]

Class data member holding name of individual class.