def __init__(self, radius_in, width, **kwargs): radius_out = radius_in + width self._model = models.Ring2D(1. / (np.pi * (radius_out ** 2 - radius_in ** 2)), 0, 0, radius_in, width) self._default_size = _round_up_to_odd_integer(2 * radius_out) super().__init__(**kwargs) self.normalize()
def fit_sky(self): """Fit the sky using a Ring2D model in which all parameters but the amplitude are fixed.""" min_value = self.data.min() ring_model = models.Ring2D(min_value, self.x, self.y, self._box * 0.4, width=self._box * 0.4) ring_model.r_in.fixed = True ring_model.width.fixed = True ring_model.x_0.fixed = True ring_model.y_0.fixed = True fit_p = fitting.LevMarLSQFitter() return fit_p(ring_model, self._XGrid, self._YGrid, self.data).amplitude
def test_Ring2D_rout(): # Test with none of r_in, r_out, width specified m = models.Ring2D(amplitude=1, x_0=1, y_0=1) assert m.amplitude.value == 1 assert m.x_0.value == 1 assert m.y_0.value == 1 assert m.r_in.value == 1 assert m.width.value == 1 # Test with r_in specified only m = models.Ring2D(amplitude=1, x_0=1, y_0=1, r_in=4) assert m.amplitude.value == 1 assert m.x_0.value == 1 assert m.y_0.value == 1 assert m.r_in.value == 4 assert m.width.value == 1 # Test with r_out specified only m = models.Ring2D(amplitude=1, x_0=1, y_0=1, r_out=7) assert m.amplitude.value == 1 assert m.x_0.value == 1 assert m.y_0.value == 1 assert m.r_in.value == 1 assert m.width.value == 6 # Error when r_out is too small for default r_in with pytest.raises(InputParameterError) as err: models.Ring2D(amplitude=1, x_0=1, y_0=1, r_out=0.5) assert str(err.value) == "r_in=1 and width=-0.5 must both be >=0" # Test with width specified only m = models.Ring2D(amplitude=1, x_0=1, y_0=1, width=11) assert m.amplitude.value == 1 assert m.x_0.value == 1 assert m.y_0.value == 1 assert m.r_in.value == 1 assert m.width.value == 11 # Test with r_in and r_out specified only m = models.Ring2D(amplitude=1, x_0=1, y_0=1, r_in=2, r_out=5) assert m.amplitude.value == 1 assert m.x_0.value == 1 assert m.y_0.value == 1 assert m.r_in.value == 2 assert m.width.value == 3 # Error when r_out is smaller than r_in with pytest.raises(InputParameterError) as err: models.Ring2D(amplitude=1, x_0=1, y_0=1, r_out=1, r_in=4) assert str(err.value) == "r_in=4 and width=-3 must both be >=0" # Test with r_in and width specified only m = models.Ring2D(amplitude=1, x_0=1, y_0=1, r_in=2, width=4) assert m.amplitude.value == 1 assert m.x_0.value == 1 assert m.y_0.value == 1 assert m.r_in.value == 2 assert m.width.value == 4 # Test with r_out and width specified only m = models.Ring2D(amplitude=1, x_0=1, y_0=1, r_out=12, width=7) assert m.amplitude.value == 1 assert m.x_0.value == 1 assert m.y_0.value == 1 assert m.r_in.value == 5 assert m.width.value == 7 # Error when width is larger than r_out with pytest.raises(InputParameterError) as err: models.Ring2D(amplitude=1, x_0=1, y_0=1, r_out=1, width=4) assert str(err.value) == "r_in=-3 and width=4 must both be >=0" # Test with r_in, r_out, and width all specified m = models.Ring2D(amplitude=1, x_0=1, y_0=1, r_in=3, r_out=11, width=8) assert m.amplitude.value == 1 assert m.x_0.value == 1 assert m.y_0.value == 1 assert m.r_in.value == 3 assert m.width.value == 8 # error when specifying all with pytest.raises(InputParameterError) as err: models.Ring2D(amplitude=1, x_0=1, y_0=1, r_in=3, r_out=11, width=7) assert str(err.value) == "Width must be r_out - r_in"
astmodels.Gaussian1D(amplitude=10., mean=5., stddev=3.), astmodels.Gaussian2D(amplitude=10., x_mean=5., y_mean=5., x_stddev=3., y_stddev=3.), astmodels.KingProjectedAnalytic1D(amplitude=10., r_core=5., r_tide=2.), astmodels.Logarithmic1D(amplitude=10., tau=3.5), astmodels.Lorentz1D(amplitude=10., x_0=0.5, fwhm=2.5), astmodels.Moffat1D(amplitude=10., x_0=0.5, gamma=1.2, alpha=2.5), astmodels.Moffat2D(amplitude=10., x_0=0.5, y_0=1.5, gamma=1.2, alpha=2.5), astmodels.Planar2D(slope_x=0.5, slope_y=1.2, intercept=2.5), astmodels.RedshiftScaleFactor(z=2.5), astmodels.RickerWavelet1D(amplitude=10., x_0=0.5, sigma=1.2), astmodels.RickerWavelet2D(amplitude=10., x_0=0.5, y_0=1.5, sigma=1.2), astmodels.Ring2D(amplitude=10., x_0=0.5, y_0=1.5, r_in=5., width=10.), astmodels.Sersic1D(amplitude=10., r_eff=1., n=4.), astmodels.Sersic2D(amplitude=10., r_eff=1., n=4., x_0=0.5, y_0=1.5, ellip=0.0, theta=0.0), astmodels.Sine1D(amplitude=10., frequency=0.5, phase=1.), astmodels.Cosine1D(amplitude=10., frequency=0.5, phase=1.), astmodels.Tangent1D(amplitude=10., frequency=0.5, phase=1.), astmodels.ArcSine1D(amplitude=10., frequency=0.5, phase=1.), astmodels.ArcCosine1D(amplitude=10., frequency=0.5, phase=1.), astmodels.ArcTangent1D(amplitude=10., frequency=0.5, phase=1.), astmodels.Trapezoid1D(amplitude=10., x_0=0.5, width=5., slope=1.),
def test_Ring2D_rout(): m = models.Ring2D(amplitude=1, x_0=1, y_0=1, r_in=2, r_out=5) assert m.width.value == 3