.. include:: links.inc Basics ====== The `astropy.modeling` package defines a number of models that are collected under a single namespace as ``astropy.modeling.models``. Models behave like parametrized functions:: >>> import numpy as np >>> from astropy.modeling import models >>> g = models.Gaussian1D(amplitude=1.2, mean=0.9, stddev=0.5) >>> print(g) Model: Gaussian1D Inputs: ('x',) Outputs: ('y',) Model set size: 1 Parameters: amplitude mean stddev --------- ---- ------ 1.2 0.9 0.5 Model parameters can be accessed as attributes:: >>> g.amplitude Parameter('amplitude', value=1.2) >>> g.mean Parameter('mean', value=0.9) >>> g.stddev # doctest: +FLOAT_CMP Parameter('stddev', value=0.5, bounds=(1.1754943508222875e-38, None)) and can also be updated via those attributes:: >>> g.amplitude = 0.8 >>> g.amplitude Parameter('amplitude', value=0.8) Models can be evaluated by calling them as functions:: >>> g(0.1) 0.22242984036255528 >>> g(np.linspace(0.5, 1.5, 7)) # doctest: +FLOAT_CMP array([0.58091923, 0.71746405, 0.7929204 , 0.78415894, 0.69394278, 0.54952605, 0.3894018 ]) As the above example demonstrates, in general most models evaluate array-like inputs according to the standard `Numpy broadcasting rules`_ for arrays. Models can therefore already be useful to evaluate common functions, independently of the fitting features of the package.