def setup_class(self): """ Create 2 gaussian models and some data with noise. Create a fitter for the two models keeping the amplitude parameter common for the two models. """ self.g1 = models.Gaussian1D(10, mean=14.9, stddev=.3) self.g2 = models.Gaussian1D(10, mean=13, stddev=.4) self.jf = JointFitter([self.g1, self.g2], {self.g1: ['amplitude'], self.g2: ['amplitude']}, [9.8]) self.x = np.arange(10, 20, .1) y1 = self.g1(self.x) y2 = self.g2(self.x) with NumpyRNGContext(_RANDOM_SEED): n = np.random.randn(100) self.ny1 = y1 + 2 * n self.ny2 = y2 + 2 * n self.jf(self.x, self.ny1, self.x, self.ny2)
* `LinearLSQFitter`: `calc_uncertainties=False` * `LevMarLSQFitter`: `calc_uncertainties=False` * `SimplexLSQFitter`, `SLSQPLSQFitter`: N/A * `JointFitter`: `models`, jointparameters`, `initvals` (must be given) """ if fitter_name.lower().startswith("lev") or fitter_name.lower().startswith( "lm"): return LevMarLSQFitter(**kwargs) elif fitter_name.lower().startswith("lin"): return LinearLSQFitter(**kwargs) elif fitter_name.lower().startswith("sl"): return SLSQPLSQFitter(**kwargs) elif fitter_name.lower().startswith("sim"): return SimplexLSQFitter(**kwargs) elif fitter_name.lower().startswith("jo"): return JointFitter(**kwargs) else: return fitter_name(**kwargs) # ^ assume the `fitter_name` is already an astropy fitter def get_model(model_name, *args, **kwargs): """ Finds and returns the model with the given name. For instance, it's customary to put degrees as args/kwargs for polynomial models: `get_model("chebyshev2d", 2, 2)` or `get_model("chebyshev2d", x_degree=2, y_degree=2)` return `Chebyshev2D(x_degree=2, y_degree=2)`. For other cases, it depends: `get_model("gaussian1d")` returns `Gaussian1D`, but sometimes you may want to initialize it with initial values: `get_model("gaussian1d", amplitude=1, mean=0, stddev=1)`. """ # Try to find the model even if there are typos