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.
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.
optional label for this image function (e.g., “NSC”, “Outer disk”, etc.)
str
name of the image function (e.g., “Gaussian”, “EdgeOnDisk”)
str
unique (optional) label for this function (e.g., “disk”, “nuclear ring”)
str
the list of ParameterDescription objects for the image-function parameters
list of ParameterDescription
number of parameters for this function
int
Add a ParameterDescription instance for one of the function’s parameter
Returns a list of the ParameterDescription objects
Add a new ParameterDescription object.
p : ParameterDecription
This is a convenience method to generate a FunctionDescription object from a dict specifying the function.
inputDict (dict) –
fDict = {‘name’: “Gaussian”, ‘label’: “blob”, ‘parameters’: p} where p is a dict containing parameter names and values, e.g. p = {‘PA’: 0.0, ‘ell’: 0.5, ‘I_0’: 100.0, ‘sigma’: 10.0} OR p = {‘PA’: [0.0, “fixed”], ‘ell’: [0.5, 0.1,0.8], ‘I_0’: [100.0, 10.0,1e3], ‘sigma’: [10.0, 5.0,20.0]}
fdesc – The function description.
fDict = {‘name’: “Gaussian”, ‘label’: “blob”, ‘parameters’: p} where p is a dict containing parameter names and values, e.g. p = {‘PA’: 0.0, ‘ell’: 0.5, ‘I_0’: 100.0, ‘sigma’: 10.0} OR p = {‘PA’: [0.0, “fixed”], ‘ell’: [0.5, 0.1,0.8], ‘I_0’: [100.0, 10.0,1e3], ‘sigma’: [10.0, 5.0,20.0]}
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
Custom name/label for the function (e.g., “disk”, “nuclear ring”).
A list of the parameters (ParameterDescription objects) of this image function.
param_list – List of the parameters.
list of ParameterDescription
A list of the parameters names (list of str) of this image function.
param_list – List of the parameter names.
list of str
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 an optional label for the function set (e.g., “fs0”, “star 1”, “galaxy 5”, “offset nucleus”, etc.)
label for the function set (”” = default no-name value)
str
label for the function set
str
x-coordinate of the function block/set’s center
y-coordinate of the function block/set’s center
the FunctionDescription objects, one for each image function
list of FunctionDescription
number of functions in the function set
int
total number of parameters for this function set, including X0 and Y0
int
whether or not any of the image functions are PointSource-like (implementing interpolation of a PSF image)
bool
- dict_to_FunctionSetDescription(dict)
Returns a new instance of this class based on a dict
Add a FunctionDescription instance
Returns a list of the FunctionDescription objects in the function set
Returns a list of names for the image-functions in the function set
Returns a list of labels for the image-functions in the function set
Returns a list of ParameterDescription objects corresponding to the function block/set (including X0,Y0)
Add an Imfit image function created using make_image_function()
.
f (FunctionDescription
.) – Function description to be added to the function set.
A convenience method to generate a FunctionSetDescription object from a dict
inputDict (dict) –
dict describing the function set {‘X0’: val-or-list, ‘Y0’: val-or-list, ‘function_list’: [list of dicts describing functions]} {‘label’: str, ‘X0’: val-or-list, ‘Y0’: val-or-list, ‘function_list’: [list of dicts describing functions]}
- where “val-or-list” for X0 and Y0 is one of
value [value, “fixed”] [value, lower-limit, upper-limit]
fset – The function-set description.
A list of labels for the Imfit image-functions making up this function set.
function_list – List of the function types.
list of str
A list of the FunctionDescription objects making up this function set.
function_list – List of the functions.
list of FunctionDescription
A list of the Imfit image-function names making up this function set.
function_list – List of the function types.
list of str
Returns a dict describing the function set (suitable for use in e.g. dict_to_FunctionSetDescription())
{‘X0’: list, ‘Y0’: list, ‘function_list’: [list of dicts describing functions]} OR {‘label’: str, ‘X0’: list, ‘Y0’: list, ‘function_list’: [list of dicts describing functions]}
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
Custom name/label for the function set.
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
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.
dict mapping image-description parameters (e.g., “GAIN”) to their corresponding values
dict of {str: float}
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}
the individual image-function sets making up the model
list of FunctionSetDescription
int
total number of model parameters
int
whether or not any of the image functions are PointSource-like (implementing interpolation of a PSF image)
bool
- load(fname)
Returns a new instance of this class based on a standard Imfit configuration file (fname).
Add a function block/set to the model description
Add image-description options via a dict
Returns a list of int
specifying the function-set start indices
Retuns a list of FunctionDescription instances for all the image functions in the model
Returns a list of names for the image-functions in the function set
Returns a list of labels for the image-functions in the function set
Returns a list of ParameterDescription instances corresponding to all the parameters in the model
Add a function set to the model description.
fs (FunctionSetDescription
) – Function set description instance.
A convenience method to generate a ModelDescription object from a dict.
inputDict (dict) –
dict describing the model, with one required entry – “function_sets” – and one optional entry – “options”
”function_sets” : list of dict, each one specifying a function set, suitable as input to FunctionSetDescription.dict_to_FunctionSetDescription()
”options” : dict of {str: float} specifying image-description options (“GAIN”, “ORIGINAL_SKY”, etc.)
mdesc – The model description.
Get list of labels for the image functions making up this model.
functionLabels – List of the function labels.
list of str
Get list of the FunctionDescription objects making up this model.
functions
list of FunctionDescription objects
Get list of names of the image functions making up this model.
functionNames – List of the function names.
list of str
Get the indices in the full parameters list corresponding to the starts of individual function sets/blocks.
indices
list of int
Get list of the functions composing this model, as strings, grouped by function set.
functionSetList – List of the function names, grouped by function set: [[functions_in_set1], [functions_in_set2], …]
list of list of string
Returns the model in dict form (suitable for use in e.g. dict_to_ModelDescription)
modelDict
dict
Get 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
Get Numpy array of the ModelDescription’s current parameter values
paramValues
ndarray of float
Get 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
outputLines – list of newline-terminated strings describing the model. If errors is supplied, then parameter strings will contain “# +/- <error>” at end
list of string
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
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”, …]
Image-description options, as a dict E.g., {“GAIN”: 2.75, “READNOISE”: 103.43}
Get list of the parameters (ParameterDescription objects) making up this model.
params – List of the parameters.
list of ParameterDescription
Replace 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) –
Update 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) –
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.
label of the parameter (e.g., “X0”, “sigma”)
str
current value of the parameter
float
lower and upper limits for parameter when fitting
2-element tuple of float
whether a parameter should be held fixed during fitting
bool
label of the parameter (e.g., “X0”, “sigma”)
str
current value of the parameter
float
lower and upper limits for parameter when fitting
2-element tuple of float
whether a parameter should be held fixed during fitting
bool
Set the value (and limits, fixed state) of the parameter
Set the limits as +/- fraction of parameter value
Set the limits as -i1,+i2 relative to parameter value
Set the limits directly
Returns a string containing parameter name and value (and optionally limits or 1-sigma uncertainty)
Whether or not this parameter is to be held fixed, as a bool.
[param-value]
[param-value, “fixed”] – if parameter is fixed
[param-value, lower-limit, upper-limit] – if parameter has limits
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
str
The low and upper limits for the parameter, as a tuple of float.
“x0”, “I_e”.
The label of the parameter (str). Examples
Set the parameter limits using specified values: [v1, v2]
v1 (float) – Lower limit.
v2 (float) – Upper limit.
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.
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.
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
.
The value of the parameter (float).
Simple version of ModelDescription with only one function set.
ParameterDescription object for the x-coordinate of the model center
ParameterDescription object for the y-coordinate of the model center
Add a function created using function_description()
.
f (FunctionDescription
.) – Function description to be added to the model.
X coordinate of the center of the model.
Instance of ParameterDescription
.
Y coordinate of the center of the model.
Instance of ParameterDescription
.