ModelFitting#

class jdaviz.configs.default.plugins.model_fitting.model_fitting.ModelFitting(*args, **kwargs)[source]#

Bases: PluginTemplateMixin, DatasetSelectMixin, SpectralSubsetSelectMixin, DatasetSpectralSubsetValidMixin, NonFiniteUncertaintyMismatchMixin, AddResultsMixin, TableMixin

See the Model Fitting Plugin Documentation for more details.

Only the following attributes and methods are available through the public plugin API:

Public constructor

Attributes Summary

comp_label

A trait for unicode strings.

comp_label_auto

A boolean (True, False) trait.

comp_label_default

A trait for unicode strings.

comp_label_invalid_msg

A trait for unicode strings.

component_models

An instance of a Python list.

cube_fit

A boolean (True, False) trait.

dialog

A boolean (True, False) trait.

display_order

A boolean (True, False) trait.

eq_error

A boolean (True, False) trait.

equation_components

List of the labels of model components in the current equation

fitted_models

Dictionary of all previously fitted models.

form_valid_model_component

A boolean (True, False) trait.

model_comp_items

An instance of a Python list.

model_comp_selected

A trait for unicode strings.

model_components

List of the labels of existing model components

model_equation

A trait for unicode strings.

model_equation_auto

A boolean (True, False) trait.

model_equation_default

A trait for unicode strings.

model_equation_invalid_msg

A trait for unicode strings.

poly_order

Mixin to handle empty integer field.

residuals_calculate

A boolean (True, False) trait.

residuals_label

A trait for unicode strings.

residuals_label_auto

A boolean (True, False) trait.

residuals_label_default

A trait for unicode strings.

residuals_label_invalid_msg

A trait for unicode strings.

template_file

user_api

valid_model_components

List of the labels of existing valid (due to display units) model components

Methods Summary

calculate_fit([add_data])

Calculate the fit.

create_model_component([model_component, ...])

Add a new model component to the list of available model components

get_model_component(model_component_label[, ...])

Get a (read-only) dictionary representation of an existing model component.

get_model_parameters([model_label, x, y])

Convert each parameter of model inside models into a coordinate that maps the model name and parameter name to a astropy.units.Quantity object.

get_models([models, model_label, x, y])

Loop through all models and output models of the label model_label.

reestimate_model_parameters([...])

Re-estimate all free parameters in a given model component given the currently selected data and subset selections.

remove_model_component(model_component_label)

Remove an existing model component.

set_model_component(model_component_label, ...)

Set the value or fixed attribute of a parameter in an existing model component.

vue_add_model(event)

vue_apply(event)

vue_reestimate_model_parameters([...])

vue_remove_model(event)

Attributes Documentation

comp_label#

A trait for unicode strings.

comp_label_auto#

A boolean (True, False) trait.

comp_label_default#

A trait for unicode strings.

comp_label_invalid_msg#

A trait for unicode strings.

component_models#

An instance of a Python list.

cube_fit#

A boolean (True, False) trait.

dialog#

A boolean (True, False) trait.

display_order#

A boolean (True, False) trait.

eq_error#

A boolean (True, False) trait.

equation_components#

List of the labels of model components in the current equation

fitted_models#

Dictionary of all previously fitted models.

form_valid_model_component#

A boolean (True, False) trait.

model_comp_items#

An instance of a Python list.

model_comp_selected#

A trait for unicode strings.

model_components#

List of the labels of existing model components

model_equation#

A trait for unicode strings.

model_equation_auto#

A boolean (True, False) trait.

model_equation_default#

A trait for unicode strings.

model_equation_invalid_msg#

A trait for unicode strings.

poly_order#

Mixin to handle empty integer field.

residuals_calculate#

A boolean (True, False) trait.

residuals_label#

A trait for unicode strings.

residuals_label_auto#

A boolean (True, False) trait.

residuals_label_default#

A trait for unicode strings.

residuals_label_invalid_msg#

A trait for unicode strings.

template_file = ('/home/docs/checkouts/readthedocs.org/user_builds/jdaviz/envs/latest/lib/python3.11/site-packages/jdaviz/configs/default/plugins/model_fitting/model_fitting.py', 'model_fitting.vue')#
user_api#
valid_model_components#

List of the labels of existing valid (due to display units) model components

Methods Documentation

calculate_fit(add_data=True)[source]#

Calculate the fit.

Parameters:
add_databool

Whether to add the resulting spectrum/cube to the app as a data entry according to add_results.

Returns:
fitted model
fitted spectrum/cube
residuals (if residuals_calculate is set to True)
create_model_component(model_component=None, model_component_label=None, poly_order=None)[source]#

Add a new model component to the list of available model components

Parameters:
model_componentstr

Type of model component to add. If not provided, will default according to model_component.

model_component_labelstr

Name of the model component to add. If not provided, will default according to model_component_label (if model_component_label.auto is True and model_component is passed as an argument, then the default label will be recomputed rather than applying the current value).

poly_orderint

Order of the polynomial if model_component is (or defaults to) “Polynomial1D”. Will raise an error if provided and model_component is not “Polynomial1D”. If not provided, will default according to poly_order.

get_model_component(model_component_label, parameter=None)[source]#

Get a (read-only) dictionary representation of an existing model component.

Parameters:
model_component_labelstr

The label given to the existing model component

parameterstr

Optional. The name of a valid parameter in the model component, in which case only the information on that parameter is returned.

get_model_parameters(model_label=None, x=None, y=None)[source]#

Convert each parameter of model inside models into a coordinate that maps the model name and parameter name to a astropy.units.Quantity object.

Parameters:
model_labelstr

Get model parameters for a particular model by inputting its label.

xint

The x coordinate of the model spaxels that will be returned from get_models.

yint

The y coordinate of the model spaxels that will be returned from get_models.

Returns:
dict:

a dictionary of the form {model name: {parameter name: [[astropy.units.Quantity]]}} for 3d models or {model name: {parameter name: astropy.units.Quantity}} where the Quantity object represents the parameter value and unit of one of spaxel models or the 1d models, respectively.

get_models(models=None, model_label=None, x=None, y=None)[source]#

Loop through all models and output models of the label model_label. If x or y is set, return model_labels of those (x, y) coordinates. If x and y are None, print all models regardless of coordinates.

Parameters:
modelsdict

A dict of models, with the key being the label name and the value being an astropy.modeling.CompoundModel object. Defaults to fitted_models if no parameter is provided.

model_labelstr

The name of the model that will be found and returned. If it equals default, every model present will be returned.

xint

The x coordinate of the model spaxels that will be returned.

yint

The y coordinate of the model spaxels that will be returned.

Returns:
selected_modelsdict

Dictionary of the selected models.

reestimate_model_parameters(model_component_label=None)[source]#

Re-estimate all free parameters in a given model component given the currently selected data and subset selections.

Parameters:
model_component_labelstr or None.

The label given to the existing model component. If None, will iterate over all model components.

remove_model_component(model_component_label)[source]#

Remove an existing model component.

Parameters:
model_component_labelstr

The label given to the existing model component

set_model_component(model_component_label, parameter, value=None, fixed=None)[source]#

Set the value or fixed attribute of a parameter in an existing model component.

Parameters:
model_component_labelstr

The label given to the existing model component

parameterstr

The name of a valid parameter in the model component.

valuefloat

Optional. The new initial value of the parameter. If not provided or None, will remain unchanged.

fixedbool

Optional. The new state of the fixed attribute of the parameter. If not provided or None, will remain unchanged.

Returns:
updated dictionary of the parameter representation
vue_add_model(event)[source]#
vue_apply(event)[source]#
vue_reestimate_model_parameters(model_component_label=None, **kwargs)[source]#
vue_remove_model(event)[source]#