This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Definitions: | |
SIP forward transformation: | |
''' | |
foc_X = (px_x - crpix1) + Forward_SIP_X((px_x - crpix1), (px_y - crpix2)) | |
foc_Y = (px_y - crpix2) + Forward_SIP_Y((px_x - crpix1), (px_y - crpix2)) | |
# SIP inverse transformation: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from astropy.modeling.fitting import (_validate_model, _fitter_to_model_params, Fitter, _convert_input) | |
from astropy.modeling.optimizers import * | |
def chi_line(measured_vals, updated_model, x_sigma, y_sigma, x): | |
""" | |
Chi^2 statistic for fitting a straight line with uncertainties in x and y. | |
Parameters | |
---------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astropy.modeling.core import Model | |
from astropy.modeling.parameters import Parameter | |
class MyModel1(Model): | |
param_names = ['a'] | |
def __init__(self, a): | |
self._a = Parameter('a', a, self, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astropy.modeling import models, fitting | |
import numpy as np | |
from scipy.optimize import leastsq | |
def gaussian2d(p, x, y): | |
amplitude, x_mean, y_mean, x_stddev, y_stddev, theta = p[:] | |
a = 0.5 * ((np.cos(theta) / x_stddev) ** 2 + (np.sin(theta) / y_stddev) ** 2) | |
b = 0.5 * (np.cos(theta) * np.sin(theta) * (1. / x_stddev ** 2 - 1. / y_stddev ** 2)) | |
c = 0.5 * ((np.sin(theta) / x_stddev) ** 2 + (np.cos(theta) / y_stddev) ** 2) | |
return amplitude * np.exp(-a * (x - x_mean) ** 2 - b * (x - x_mean) * (y - y_mean) - c * (y - y_mean) ** 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astropy.models.fitting import Fitter | |
import numpy as np | |
from scipy import optimize | |
class SLSQPFitter(Fitter): | |
def __init__(self): | |
super().__init__(optimizer=SLSQP, statistic=leastsquare) | |
def errorfunc(self, fps, *args): | |
model = args[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This page lists features to be added to astropy.models. It was compiled from suggestions in the initial astropy.models PR#493. Feel free to add to this list. Please make a note if you are interested in working on any of them. This list is not prioritized. | |
* Add spline models and fitters. | |
* Write a general `Model.inverse()` method. | |
This is intended to be used in models for which an analytical inverse is not available. | |
* Add a `CompositeModel.simplify` method, similar to AST. | |
NewerOlder