The are classes which hold information about individual instances of Imfit image functions (FunctionDescription), the function sets which group one or more functions with a common central coordinate (FunctionSet), and finally Models which combine all function sets with optional image-description information (ModelDescription, SimpleModelDescription).
Each FunctionDescription, in turn, holds a set of ParameterDescription objects, which keep track of parameter names, initial or current values, and limits.
To properly instantiate an instance of the Imfit class, you must supply it with a previously generated instance of the ModelDescription (or SimpleModelDescription) class.
pyimfit.descriptions.
FunctionDescription
(func_name: str, label: Optional[str] = '', parameters=None)¶Holds information describing a single Imfit image function and its associated parameters, including their values and limits.
This contains the official Imfit image-function name (e.g., “Gaussian”, “EdgeOnDisk”), an optional label (e.g., “disk”, “outer ring”), and a list of ParameterDescription objects which describe the parameter names, values, and limits (or fixed status) for each of the image function’s parameters.
label
¶optional label for this image function (e.g., “NSC”, “Outer disk”, etc.)
str
_funcName
¶name of the image function (e.g., “Gaussian”, “EdgeOnDisk”)
str
_label
¶unique (optional) label for this function (e.g., “disk”, “nuclear ring”)
str
_parameters
¶the list of ParameterDescription objects for the image-function parameters
list of ParameterDescription
nParameters
¶number of parameters for this function
int
addParameter
(p)¶Add a ParameterDescription instance for one of the function’s parameter
parameterList
()¶Returns a list of the ParameterDescription objects
getStringDescription
(noLimits=False, errors: Optional[Sequence[float]] = None)¶Returns a list of strings suitable for inclusion in an imfit/makeimage config file.
noLimits (bool, optional) – if True, then only parameter values (no limits or “fixed” indicators) are output
errors (sequence float, optional) – errors on parameter values (e.g., from Levenberg-Marquardt minimization)
outputStrings – list of newline-terminated strings, starting with function name and followed by one string for each parameter, as output by ParameterDescription.getStringDescription If errors is supplied, then parameter strings will contain “# +/- <error>” at end
list of string
label
¶Custom name/label for the function (e.g., “disk”, “nuclear ring”).
parameterList
()¶A list of the parameters (ParameterDescription objects) of this image function.
param_list – List of the parameters.
list of ParameterDescription
parameterNameList
()¶A list of the parameters names (list of str) of this image function.
param_list – List of the parameter names.
list of str
pyimfit.descriptions.
FunctionSetDescription
(name: str, x0param: Optional[pyimfit.descriptions.ParameterDescription] = None, y0param: Optional[pyimfit.descriptions.ParameterDescription] = None, functionList: Optional[List[pyimfit.descriptions.FunctionDescription]] = None)¶Holds information describing an image-function block/set: one or more Imfit image functions sharing a common (X0,Y0) position on the image.
This contains the X0 and Y0 coordinates, a list of FunctionDescription objects, and name or label for the function set (e.g., “fs0”, “star 1”, “galaxy 5”, “offset nucleus”, etc.)
name
¶name for the function set
str
_name
¶name for the function set
str
x0
¶x-coordinate of the function block/set’s center
y0
¶y-coordinate of the function block/set’s center
_functions
¶the FunctionDescription objects, one for each image function
list of FunctionDescription
nFunctions
¶number of functions in the function set
int
nParameters
¶total number of parameters for this function set, including X0 and Y0
int
addFunction
(f)¶Add a FunctionDescription instance
functionList
()¶Returns a list of the FunctionDescription objects in the function set
functionNameList
()¶Returns a list of names for the image-functions in the function set
functionLabelList
()¶Returns a list of labels for the image-functions in the function set
parameterList
()¶Returns a list of ParameterDescription objects corresponding to the function block/set (including X0,Y0)
addFunction
(f: pyimfit.descriptions.FunctionDescription)¶Add an Imfit image function created using make_image_function()
.
f (FunctionDescription
.) – Function description to be added to the function set.
functionLabelList
()¶A list of labels for the Imfit image-functions making up this function set.
function_list – List of the function types.
list of str
functionList
()¶A list of the FunctionDescription objects making up this function set.
function_list – List of the functions.
list of FunctionDescription
functionNameList
()¶A list of the Imfit image-function names making up this function set.
function_list – List of the function types.
list of str
getStringDescription
(noLimits=False, errors: Optional[Sequence[float]] = None)¶Returns a list of strings suitable for inclusion in an imfit/makeimage config file.
noLimits (bool, optional) – if True, then only parameter values (no limits or “fixed” indicators) are output
errors (sequence float, optional) – errors on parameter values (e.g., from Levenberg-Marquardt minimization)
outputStrings – list of newline-terminated strings describing the function set. If errors is supplied, then parameter strings will contain “# +/- <error>” at end
list of string
name
¶Custom name/label for the function set.
parameterList
()¶A list of all the parameters corresponding to this function set (including the X0,Y0 position).
param_list – List of the parameters.
list of ParameterDescription
pyimfit.descriptions.
ModelDescription
(functionSetsList: Optional[List[pyimfit.descriptions.FunctionSetDescription]] = None, options: Optional[Dict[str, float]] = None)¶Holds information describing an Imfit model, including image-description data.
The main components are a dict containing image-descriptions parameters and their values (e.g., {“GAIN”: 4.5, “ORIGINAL_SKY”: 325.39} and a list of FunctionSetDescription objects, corresponding to the image-function sets/blocks making up the model proper.
optionsDict
¶dict mapping image-description parameters (e.g., “GAIN”) to their corresponding values
dict of {str: float}
options
¶dict mapping image-description parameters (e.g., “GAIN”) to their corresponding values [this is the internal name for the property optionsDict]
dict of {str: float}
_functionSets
¶the individual image-function blocks/sets making up the model
list of FunctionSetDescription
nFunctionSets
¶int
nParameters
¶total number of model parameters
int
- load(fname)
Returns a new instance of this class based on a standard Imfit configuration file (fname).
addFunctionSet
(fs)¶Add a function block/set to the model description
addOptions
(optionDict)¶Add image-description options via a dict
functionSetIndices
()¶Returns a list of int
specifying the function-set start indices
functionList
()¶Retuns a list of FunctionDescription instances for all the image functions in the model
functionNameList
()¶Returns a list of names for the image-functions in the function set
functionLabelList
()¶Returns a list of labels for the image-functions in the function set
parameterList
()¶Returns a list of ParameterDescription instances corresponding to all the parameters in the model
addFunctionSet
(fs: pyimfit.descriptions.FunctionSetDescription)¶Add a function set to the model description.
fs (FunctionSetDescription
) – Function set description instance.
functionLabelList
()¶List of labels for the image functions making up this model.
func_list – List of the function labels.
list of str
functionList
()¶List of the FunctionDescription objects making up this model.
func_list
list of FunctionDescription objects
functionNameList
()¶List of names of the image functions making up this model.
func_list – List of the function names.
list of str
functionSetIndices
()¶Returns the indices in the full parameters list corresponding to the starts of individual function sets/blocks.
functionSetNameList
()¶List of the function sets composing this model, as strings.
func_set_list – List of the function sets: [[functions_in_set1], [functions_in_set2], …]
list of list of string
getParameterLimits
()¶Returns a list containing lower and upper limits for all parameters in the model.
parameterLimits – [(lower_limit, upper_limit)_1, (lower_limit, upper_limit)_2, …]
list of 2-element tuples of float
getRawParameters
()¶Returns a Numpy array of the ModelDescription’s current parameter values
paramValues
ndarray of float
getStringDescription
(noLimits=False, errors: Optional[Sequence[float]] = None, saveOptions=False)¶Returns a list of strings suitable for inclusion in an imfit/makeimage config file.
noLimits (bool, optional) – if True, then only parameter values (no limits or “fixed” indicators) are output
errors (sequence float, optional) – errors on parameter values (e.g., from Levenberg-Marquardt minimization)
saveOptions (bool, optional) – if False, then image-description options (GAIN, READNOISE, etc.) are not output
outputStrings – list of newline-terminated strings describing the model. If errors is supplied, then parameter strings will contain “# +/- <error>” at end
list of string
load
(fileName: str)¶This is a convenience method to generate a ModelDescription object from a standard Imfit configuration file.
fileName (string) – Path to the Imfit configuration file.
model – The model description.
See also
parse_config_file()
numberedParameterNames
¶List of parameter names for the current model, annotated by function number. E.g., [“X0_1”, “Y0_1”, “PA_1”, “ell_1”, “I_0_1”, “h_1”, …]
optionsDict
¶Image-description options, as a dict E.g., {“GAIN”: 2.75, “READNOISE”: 103.43}
parameterList
()¶A list of the parameters (ParameterDescription objects) making up this model.
param_list – List of the parameters.
list of ParameterDescription
replaceOptions
(optionsDict: Dict[str, float])¶Replaces the current image-descriptions dict. This differs from updateOptions() in that it will completely replace the current image-descriptions dict, discarding any key-value pairs with keys not in the replacement dict.
optionDict (dict) –
updateOptions
(optionsDict: Dict[str, float])¶Updates the internal image-descriptions dict, replacing current values for keys already in the dict and added key-value pairs for keys not already present.
optionDict (dict) –
pyimfit.descriptions.
ParameterDescription
(name: str, value: float, limits: Optional[Sequence[float]] = None, fixed=False)¶Holds information for a single parameter of an Imfit image function, or the X0 or Y0 parameter of a function block/set (corresponding to what is encoded in a single parameter line of an Imfit configuration file).
It holds the name, current value (e.g., a suggested initial value), possible lower and upper limits for fitting purposes, and whether or not the value is to be held fixed during a fit.
name
¶label of the parameter (e.g., “X0”, “sigma”)
str
value
¶current value of the parameter
float
limits
¶lower and upper limits for parameter when fitting
2-element tuple of float
fixed
¶whether a parameter should be held fixed during fitting
bool
_name
¶label of the parameter (e.g., “X0”, “sigma”)
str
_value
¶current value of the parameter
float
_limits
¶lower and upper limits for parameter when fitting
2-element tuple of float
_fixed
¶whether a parameter should be held fixed during fitting
bool
setValue
(value, limits=None, fixed=False)¶Set the value (and limits, fixed state) of the parameter
setTolerance
(tol)¶Set the limits as +/- fraction of parameter value
setLimitsRel
(i1, i2)¶Set the limits as -i1,+i2 relative to parameter value
setLimits
(v1, v2)¶Set the limits directly
getStringDescription
(noLimits=False, error=none)¶Returns a string containing parameter name and value (and optionally limits or 1-sigma uncertainty)
fixed
¶Whether or not this parameter is to be held fixed, as a bool.
getStringDescription
(noLimits=False, error: Optional[float] = None)¶Returns a string with parameter name, value, limits, suitable for inclusion in an imfit/makeimage config file.
noLimits (bool, optional) – if True, then only parameter values (no limits or “fixed” indicators) are output
error (float, optional) – error on parameter value (e.g., from Levenberg-Marquardt minimization); if supplied then no limit info is output, but “# +/- <error>” is appended
outputString
string
limits
¶The low and upper limits for the parameter, as a tuple.
name
¶“x0”, “I_e”.
The label of the parameter. Examples
setLimits
(v1: float, v2: float)¶Set the parameter limits using specified values: [v1, v2]
v1 (float) – Lower limit.
v2 (float) – Upper limit.
setLimitsRel
(i1: float, i2: float)¶Set the parameter limits using relative intervals. The limits will be [value - i1, value + i2]
i1 (float) – Lower limit interval.
i2 (float) – Upper limit interval.
setTolerance
(tol: float)¶Set the parameter limits using a fractional “tolerance” value, so that the lower limit = (1 - tol)*value and the upper limit = (1 + tol)*value. For example, a tolerance of 0.2 for a property of value 1.0 sets the limits to [0.8, 1.2].
tol (float) – Fractional offset for lower and upper limits
Must lie between 0.0
and 1.0
.
setValue
(value: float, limits: Optional[Sequence[float]] = None, fixed: bool = False)¶Set the value and (optionally) constraints of the parameter.
value (float) – Value of the parameter.
limits (2-element sequence of float, optional) – Lower and upper limits of the parameter.
Default: None
(= no limits).
fixed (bool, optional) – Flag the parameter as fixed. Default: False
.
value
¶The value of the parameter.
pyimfit.descriptions.
SimpleModelDescription
(inst=None)¶Simple version of ModelDescription with only one function set.
x0
¶ParameterDescription object for the x-coordinate of the model center
y0
¶ParameterDescription object for the y-coordinate of the model center
addFunction
(f: pyimfit.descriptions.FunctionDescription)¶Add a function created using function_description()
.
f (FunctionDescription
.) – Function description to be added to the model.
x0
¶X coordinate of the center of the model.
Instance of ParameterDescription
.
y0
¶Y coordinate of the center of the model.
Instance of ParameterDescription
.