Created
August 8, 2017 13:16
-
-
Save nden/987d3315a8deaf0a62fcbdea4628d786 to your computer and use it in GitHub Desktop.
parameters can be models
This file contains 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.models import Polynomial2D, Polynomial1D | |
from astropy.modeling.parameters import Parameter | |
class MyModel(Model): | |
inputs = ('x', 'y', 't') | |
outputs = ('z',) | |
def __init__(self, c0, c1, **kwargs): | |
''' | |
c0, c1 are Poly models | |
''' | |
self.c0 = c0 # poly1d(degree=1) | |
self.c1 = c1 # deg = 2 | |
super(MyModel, self).__init__(**kwargs) | |
def evaluate(self, x, y, t): | |
""" | |
x, y = coordinates | |
t - order | |
""" | |
p2 = Polynomial2D(1, c0_0=self.c0(t), c0_1=self.c1(t), c1_0=1) | |
return p2(x,y) | |
c0 = Polynomial1D(1, c0=1, c1=2) | |
c1 = Polynomial1D(2, c0=1, c1=2, c2=3) | |
m = MyModel(c0, c1) | |
m(1, 2, 1) | |
# 16 | |
m(1, 2, 2) | |
#40 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment