File: index.rst

package info (click to toggle)
astropy 5.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 41,972 kB
  • sloc: python: 219,331; ansic: 147,297; javascript: 13,556; lex: 8,496; sh: 3,319; xml: 1,622; makefile: 185
file content (138 lines) | stat: -rw-r--r-- 3,243 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
.. include:: links.inc

.. _astropy-modeling:

***************************************
Models and Fitting (`astropy.modeling`)
***************************************

Introduction
============

`astropy.modeling` provides a framework for representing models and performing
model evaluation and fitting.  A number of predefined 1-D and 2-D models are
provided and the capability for custom, user defined models is supported.
Different fitting algorithms can be used with any model.  For those fitters
with the capabilities fitting can be done using uncertainties, parameters with
bounds, and priors.

.. _modeling-using:

Using Modeling
==============

.. toctree::
   :maxdepth: 2

   Models <models.rst>
   Compound Models <compound-models.rst>
   Model Parameters <parameters.rst>
   Fitting <fitting.rst>
   Using Units with Models and Fitting <units.rst>


.. _getting-started-example:

A Simple Example
================

This simple example illustrates defining a model,
calculating values based on input x values, and using fitting data with a model.

   .. plot::
       :include-source:

       import numpy as np
       import matplotlib.pyplot as plt
       from astropy.modeling import models, fitting

       # define a model for a line
       line_orig = models.Linear1D(slope=1.0, intercept=0.5)

       # generate x, y data non-uniformly spaced in x
       # add noise to y measurements
       npts = 30
       rng = np.random.default_rng(10)
       x = rng.uniform(0.0, 10.0, npts)
       y = line_orig(x)
       y += rng.normal(0.0, 1.5, npts)

       # initialize a linear fitter
       fit = fitting.LinearLSQFitter()

       # initialize a linear model
       line_init = models.Linear1D()

       # fit the data with the fitter
       fitted_line = fit(line_init, x, y)

       # plot the model
       plt.figure()
       plt.plot(x, y, 'ko', label='Data')
       plt.plot(x, fitted_line(x), 'k-', label='Fitted Model')
       plt.xlabel('x')
       plt.ylabel('y')
       plt.legend()

.. _advanced_topics:

Advanced Topics
===============

.. toctree::
   :maxdepth: 2

   Performance Tips <performance.rst>
   Extending Models <new-model.rst>
   Extending Fitters <new-fitter.rst>
   Adding support for units to models <add-units.rst>
   Joint Fitting <jointfitter.rst>


Pre-Defined Models
==================

.. To be expanded to include all pre-defined models

Some of the pre-defined models are listed and illustrated.

.. toctree::
   :maxdepth: 2

   1D Models <predef_models1D.rst>
   2D Models <predef_models2D.rst>
   Physical Models <physical_models.rst>
   Polynomial Models <polynomial_models.rst>
   Powerlaw Models <powerlaw_models.rst>
   Spline Models <spline_models.rst>

Examples
========

.. toctree::
   :maxdepth: 2

   Fitting a line <example-fitting-line>
   example-fitting-constraints
   example-fitting-model-sets

.. TODO list
    fitting with masks
    fitting with priors
    fitting with units
    defining 1d model
    defining 2d model
    fitting 2d model
    defining and using a WCS/gWCS model
    defining and using a Tabular1D model
    statistics functions and how to make your own
    compound models


Reference/API
=============

.. toctree::
   :maxdepth: 1

   reference_api