Reference/API¶
Capabilities¶
astropy.modeling Package¶
This subpackage provides a framework for representing models and performing model evaluation and fitting. It supports 1D and 2D models and fitting with parameter constraints. It has some predefined models and fitting routines.
Functions¶
|
Create a model from a user defined function. |
|
This function creates a compound model with one or more of the input values of the input model assigned fixed values (scalar or array). |
|
A separability test for the outputs of a transform. |
|
Compute the correlation between outputs and inputs. |
Classes¶
|
Base class for compound models. |
|
Base class for one-dimensional fittable models. |
|
Base class for two-dimensional fittable models. |
|
Base class for models that can be fitted using the built-in fitting algorithms. |
Used for incorrect input parameter values and definitions. |
|
|
Base class for all models. |
Used for incorrect models definitions. |
|
|
Wraps individual parameters. |
Generic exception class for all exceptions pertaining to Parameters. |
Class Inheritance Diagram¶
astropy.modeling.mappings Module¶
Special models useful for complex compound models where control is needed over which outputs from a source model are mapped to which inputs of a target model.
Classes¶
|
Allows inputs to be reordered, duplicated or dropped. |
|
Returns inputs unchanged. |
|
Mapper that operates on the units of the input, first converting to canonical units, then assigning new units without further conversion. |
Class Inheritance Diagram¶
astropy.modeling.fitting Module¶
This module implements classes (called Fitters) which combine optimization
algorithms (typically from scipy.optimize
) with statistic functions to perform
fitting. Fitters are implemented as callable classes. In addition to the data
to fit, the __call__
method takes an instance of
FittableModel
as input, and returns a copy of the
model with its parameters determined by the optimizer.
Optimization algorithms, called “optimizers” are implemented in
optimizers
and statistic functions are in
statistic
. The goal is to provide an easy to extend
framework and allow users to easily create new fitters by combining statistics
with optimizers.
There are two exceptions to the above scheme.
LinearLSQFitter
uses Numpy’s lstsq
function. LevMarLSQFitter
uses
leastsq
which combines optimization and statistic in one
implementation.
Classes¶
A class performing a linear least square fitting. |
|
Levenberg-Marquardt algorithm and least squares statistic. |
|
|
This class combines an outlier removal technique with a fitting procedure. |
SLSQP optimization algorithm and least squares statistic. |
|
Simplex algorithm and least squares statistic. |
|
|
Fit models which share a parameter. |
|
Base class for all fitters. |
Class Inheritance Diagram¶
astropy.modeling.optimizers Module¶
Optimization algorithms used in fitting
.
Classes¶
|
Base class for optimizers. |
|
Sequential Least Squares Programming optimization algorithm. |
|
Neald-Mead (downhill simplex) algorithm. |
Class Inheritance Diagram¶
astropy.modeling.statistic Module¶
Statistic functions used in fitting
.
Functions¶
|
Least square statistic with optional weights. |
astropy.modeling.tabular Module¶
Tabular models.
Tabular models of any dimension can be created using tabular_model
.
For convenience Tabular1D
and Tabular2D
are provided.
Examples¶
>>> table = np.array([[ 3., 0., 0.],
... [ 0., 2., 0.],
... [ 0., 0., 0.]])
>>> points = ([1, 2, 3], [1, 2, 3])
>>> t2 = Tabular2D(points, lookup_table=table, bounds_error=False,
... fill_value=None, method='nearest')
Functions¶
|
Make a |
astropy.modeling.separable Module¶
Functions to determine if a model is separable, i.e. if the model outputs are independent.
It analyzes n_inputs
, n_outputs
and the operators
in a compound model by stepping through the transforms
and creating a coord_matrix
of shape (n_outputs
, n_inputs
).
Each modeling operator is represented by a function which
takes two simple models (or two coord_matrix
arrays) and
returns an array of shape (n_outputs
, n_inputs
).
Functions¶
|
A separability test for the outputs of a transform. |
|
Compute the correlation between outputs and inputs. |
Pre-Defined Models¶
astropy.modeling.functional_models Module¶
Mathematical models.
Classes¶
|
Two dimensional Airy disk model. |
|
One dimensional Moffat model. |
|
Two dimensional Moffat model. |
|
One dimensional Box model. |
|
Two dimensional Box model. |
|
One dimensional Constant model. |
|
Two dimensional Constant model. |
|
A 2D Ellipse model. |
|
Two dimensional radial symmetric Disk model. |
|
One dimensional Gaussian model. |
|
Two dimensional Gaussian model. |
|
One dimensional Line model. |
|
One dimensional Lorentzian model. |
|
One dimensional Ricker Wavelet model (sometimes known as a “Mexican Hat” model). |
|
Two dimensional Ricker Wavelet model (sometimes known as a “Mexican Hat” model). |
|
One dimensional redshift scale factor model. |
|
Multiply a model by a quantity or number. |
|
Two dimensional Plane model. |
|
Multiply a model by a dimensionless factor. |
|
One dimensional Sersic surface brightness profile. |
|
Two dimensional Sersic surface brightness profile. |
|
Shift a coordinate. |
|
One dimensional Sine model. |
|
One dimensional Trapezoid model. |
|
Two dimensional circular Trapezoid model. |
|
Two dimensional radial symmetric Ring model. |
|
One dimensional model for the Voigt profile. |
|
Projected (surface density) analytic King Model. |
|
One dimensional exponential model. |
|
One dimensional logarithmic model. |
Class Inheritance Diagram¶
astropy.modeling.physical_models Module¶
Models that have physical origins.
Classes¶
|
Blackbody model using the Planck function. |
|
Drude model based one the behavior of electons in materials (esp. |
|
One dimensional Plummer density profile model. |
Class Inheritance Diagram¶
astropy.modeling.powerlaws Module¶
Power law model variants
Classes¶
|
One dimensional power law model. |
|
One dimensional power law model with a break. |
|
One dimensional smoothly broken power law model. |
|
One dimensional power law model with an exponential cutoff. |
|
One dimensional log parabola model (sometimes called curved power law). |
Class Inheritance Diagram¶
astropy.modeling.polynomial Module¶
This module contains models representing polynomials and polynomial series.
Classes¶
|
Univariate Chebyshev series. |
|
Bivariate Chebyshev series.. |
|
Univariate Hermite series. |
|
Bivariate Hermite series. |
|
Inverse Simple Imaging Polynomial |
|
Univariate Legendre series. |
|
Bivariate Legendre series. |
|
1D Polynomial model. |
|
2D Polynomial model. |
|
Simple Imaging Polynomial (SIP) model. |
|
This is a base class for the 2D Chebyshev and Legendre models. |
|
Base class for polynomial models. |
Class Inheritance Diagram¶
astropy.modeling.projections Module¶
Implements projections–particularly sky projections defined in WCS Paper II [1].
All angles are set and and displayed in degrees but internally computations are performed in radians. All functions expect inputs and outputs degrees.
Classes¶
|
Base class for all sky projections. |
|
Base class for all Pix2Sky projections. |
|
Base class for all Sky2Pix projections. |
|
Base class for all Zenithal projections. |
|
Base class for Cylindrical projections. |
|
Base class for pseudocylindrical projections. |
|
Base class for conic projections. |
|
Base class for pseudoconic projections. |
|
Base class for quad cube projections. |
|
Base class for HEALPix projections. |
|
Perform an affine transformation in 2 dimensions. |
|
Zenithal perspective projection - pixel to sky. |
|
Zenithal perspective projection - sky to pixel. |
|
Slant zenithal perspective projection - pixel to sky. |
|
Zenithal perspective projection - sky to pixel. |
|
Gnomonic projection - pixel to sky. |
|
Gnomonic Projection - sky to pixel. |
|
Stereographic Projection - pixel to sky. |
|
Stereographic Projection - sky to pixel. |
|
Slant orthographic projection - pixel to sky. |
|
Slant orthographic projection - sky to pixel. |
|
Zenithal equidistant projection - pixel to sky. |
|
Zenithal equidistant projection - sky to pixel. |
|
Zenithal equidistant projection - pixel to sky. |
|
Zenithal equidistant projection - sky to pixel. |
|
Airy projection - pixel to sky. |
|
Airy - sky to pixel. |
|
Cylindrical perspective - pixel to sky. |
|
Cylindrical Perspective - sky to pixel. |
|
Cylindrical equal area projection - pixel to sky. |
|
Cylindrical equal area projection - sky to pixel. |
|
Plate carrée projection - pixel to sky. |
|
Plate carrée projection - sky to pixel. |
|
Mercator - pixel to sky. |
|
Mercator - sky to pixel. |
|
Sanson-Flamsteed projection - pixel to sky. |
|
Sanson-Flamsteed projection - sky to pixel. |
|
Parabolic projection - pixel to sky. |
|
Parabolic projection - sky to pixel. |
|
Molleweide’s projection - pixel to sky. |
|
Molleweide’s projection - sky to pixel. |
|
Hammer-Aitoff projection - pixel to sky. |
|
Hammer-Aitoff projection - sky to pixel. |
|
Colles’ conic perspective projection - pixel to sky. |
|
Colles’ conic perspective projection - sky to pixel. |
|
Alber’s conic equal area projection - pixel to sky. |
|
Alber’s conic equal area projection - sky to pixel. |
|
Conic equidistant projection - pixel to sky. |
|
Conic equidistant projection - sky to pixel. |
|
Conic orthomorphic projection - pixel to sky. |
|
Conic orthomorphic projection - sky to pixel. |
|
Bonne’s equal area pseudoconic projection - pixel to sky. |
|
Bonne’s equal area pseudoconic projection - sky to pixel. |
|
Polyconic projection - pixel to sky. |
|
Polyconic projection - sky to pixel. |
|
Tangential spherical cube projection - pixel to sky. |
|
Tangential spherical cube projection - sky to pixel. |
|
COBE quadrilateralized spherical cube projection - pixel to sky. |
|
COBE quadrilateralized spherical cube projection - sky to pixel. |
|
Quadrilateralized spherical cube projection - pixel to sky. |
|
Quadrilateralized spherical cube projection - sky to pixel. |
|
HEALPix - pixel to sky. |
|
HEALPix projection - sky to pixel. |
|
HEALPix polar, aka “butterfly” projection - pixel to sky. |
|
HEALPix polar, aka “butterfly” projection - pixel to sky. |
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
Class Inheritance Diagram¶
astropy.modeling.rotations Module¶
Implements rotations, including spherical rotations as defined in WCS Paper II [1]
RotateNative2Celestial
and RotateCelestial2Native
follow the convention in
WCS Paper II to rotate to/from a native sphere and the celestial sphere.
The implementation uses EulerAngleRotation
. The model parameters are
three angles: the longitude (lon
) and latitude (lat
) of the fiducial point
in the celestial system (CRVAL
keywords in FITS), and the longitude of the celestial
pole in the native system (lon_pole
). The Euler angles are lon+90
, 90-lat
and -(lon_pole-90)
.
Classes¶
|
Transform from Celestial to Native Spherical Coordinates. |
|
Transform from Native to Celestial Spherical Coordinates. |
|
Perform a 2D rotation given an angle. |
|
Implements Euler angle intrinsic rotations. |
|
Perform a series of rotations about different axis in 3D space. |
|
Perform a sequence of rotations about arbitrary number of axes in spherical coordinates. |
Class Inheritance Diagram¶
-
class
astropy.modeling.tabular.
Tabular1D
(points=None, lookup_table=None, method='linear', bounds_error=True, fill_value=nan, **kwargs)¶ Tabular model in 1D. Returns an interpolated lookup table value.
- Parameters
- pointsarray_like of float of ndim=1.
The points defining the regular grid in n dimensions.
- lookup_tablearray_like, of ndim=1.
The data in one dimensions.
- methodstr, optional
The method of interpolation to perform. Supported are “linear” and “nearest”, and “splinef2d”. “splinef2d” is only supported for 2-dimensional data. Default is “linear”.
- bounds_errorbool, optional
If True, when interpolated values are requested outside of the domain of the input data, a ValueError is raised. If False, then
fill_value
is used.- fill_valuefloat, optional
If provided, the value to use for points outside of the interpolation domain. If None, values outside the domain are extrapolated. Extrapolation is not supported by method “splinef2d”.
- Returns
- valuendarray
Interpolated values at input coordinates.
- Raises
- ImportError
Scipy is not installed.
Notes
-
class
astropy.modeling.tabular.
Tabular2D
(points=None, lookup_table=None, method='linear', bounds_error=True, fill_value=nan, **kwargs)¶ Tabular model in 2D. Returns an interpolated lookup table value.
- Parameters
- pointstuple of ndarray of float, with shapes (m1, m2), optional
The points defining the regular grid in n dimensions.
- lookup_tablearray_like, shape (m1, m2)
The data on a regular grid in 2 dimensions.
- methodstr, optional
The method of interpolation to perform. Supported are “linear” and “nearest”, and “splinef2d”. “splinef2d” is only supported for 2-dimensional data. Default is “linear”.
- bounds_errorbool, optional
If True, when interpolated values are requested outside of the domain of the input data, a ValueError is raised. If False, then
fill_value
is used.- fill_valuefloat, optional
If provided, the value to use for points outside of the interpolation domain. If None, values outside the domain are extrapolated. Extrapolation is not supported by method “splinef2d”.
- Returns
- valuendarray
Interpolated values at input coordinates.
- Raises
- ImportError
Scipy is not installed.
Notes