Skip to content

Commit 98cd05b

Browse files
committed
Add 'what's new' section for modeling; should address that portion of astropy#2935
1 parent e46ef26 commit 98cd05b

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎docs/modeling/models.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. include:: links.inc
2+
.. _modeling-instantiating:
23

34
***********************************
45
Instantiating and Evaluating Models
@@ -63,6 +64,7 @@ error::
6364
with parameter 'stddev' of shape (3,). All parameter arrays must have
6465
shapes that are mutually compatible according to the broadcasting rules.
6566

67+
.. _modeling-model-sets:
6668

6769
Model Sets
6870
==========

‎docs/modeling/new.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _modeling-new-classes:
2+
13
Defining New Model Classes
24
==========================
35

‎docs/whatsnew/1.0.rst‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,38 @@ For full details including extensive performance testing, see :ref:`fast_ascii_i
149149
New features in :ref:`astropy-modeling`
150150
---------------------------------------
151151

152-
.. Compound models and other changes
152+
New subclasses of `~astropy.modeling.Model` are now a bit easier to define,
153+
requiring less boilerplate code in general. Now all that is necessary to
154+
define a new model class is an `~astropy.modeling.Model.evaluate` method that
155+
computes the model. Optionally one can define :ref:`fittable parameters
156+
<modeling-parameters>`, a `~astropy.modeling.FittableModel.fit_deriv`, and/or
157+
an `~astropy.modeling.Model.inverse`. The new, improved
158+
`~astropy.modeling.custom_model` decorator reduces to boilerplate needed for
159+
many models even more. See :ref:`modeling-new-classes` for more details.
160+
161+
Array broadcasting has also been improved, enabling a broader range of
162+
possibilities for the values of model parameters and inputs. Support has also
163+
been improved for :ref:`modeling-model-sets` (previously referred to as
164+
parameter sets) which can be thought of like an array of models of the same
165+
class, each with different sets of parameters, which can be fitted
166+
simultaneously either to the same data, or to different data sets per model.
167+
See :ref:`modeling-instantiating` for more details.
168+
169+
It is now possible to create *compound* models by combining existing models
170+
using the standard arithmetic operators such as ``+`` and ``*``, as well as
171+
functional composition using the ``|`` operator. This provides a powerful
172+
and flexible new way to create more complex models without having to define
173+
any special classes or functions. For example::
174+
175+
>>> from astropy.modeling.models import Gaussian1D
176+
>>> gaussian1 = Gaussian1D(1, 0, 0.2)
177+
>>> gaussian2 = Gaussian1D(2.5, 0.5, 0.1)
178+
>>> sum_of_gaussians = gaussian1 + gaussian2
179+
180+
The resulting model works like any other model, and also works with the
181+
fitting framework. See the
182+
:ref:`introduction to compound models <compound-models-intro>` and full
183+
:ref:`compound models documentation <compound-models>` for more examples.
153184

154185
Support for 'mixin' columns in :ref:`astropy-table`
155186
---------------------------------------------------

0 commit comments

Comments
 (0)