Repository navigation
Renamed parameters in Gaussian and added a cov_matrix kwarg - #1022
Conversation
There was a problem hiding this comment.
cov_matrix appears to be missing from this list.
|
I like the name changes - more PEP8 compliant and easier to read. Now in the As for the generic nd-gaussian, I suggest you implement that as a separate class ( Also, there's a sphinx build failure - looks like you didn't update things that are in the docs for the new name. |
|
I agree with @eteq that NDGaussian should be a separate model, there are plenty of use cases for simple 1D and 2D gaussians. I have no objections to changing the parameter names in the gaussian models. I needed a test case for non-linear fitters, picked gaussian and looked up the names IRAF is using. Although 'center' is clearer to me than 'mu' I'll agree to calling it 'mu'. You are right, no particular reason to keep 'ratio', an "irafism" again. But I am surprised 'fwhm' is not favored here as it seems to be the natural choice in some fields of astronomy. Anyway, I'll leave it to real users to decide. No objection to the param_* changes either. This makes it a bit harder to work with in an interactive session but they are more descriptive this way. The examples in the docs need to be changed as well. |
|
Another reference point: gauss1d and gauss2d parameter names in Sherpa. As a user I'm +1 on using And -1 on |
|
I don't think we need to choose which is the "best" between I'm +0 on |
|
Personally, I prefer |
|
In fact, what I really prefer is |
|
@eteq I am not sure I understand your suggestion about handling the parameters through properties. If we take I think @adrn would like to see them as: If I understand you correctly, you are proposing to keep the latter signature but allow users to get/set the Also, it may not be obvious, so I'll mention it here. All model parameters (those that are in the |
|
I've been thinking more about this. My intention from the start was to be able to create models for which one or more parameters may be of type array. However it is not clear to me what it means to fit a parameter which is an array. What I had in mind is something similar to what @adrn has done with With that in mind and this
or
or
How does this sound? Is it flexible enough? |
|
@nden - yes, that's what I was thinking (although I think the third one shouldn't have I think I was being confusing because I was mostly talking about the properties, rather than the initializer. I was saying that we should accept all of the options as possible initializer arguments (as you are showing above), but they should also all be accessible (or settable) as properties. But I agree that that any non-overdetermined combination should be acceptable in the initializer (including e.g. |
|
By the way, @adrn, once the initializer plan is finalized, given that you'll be changing the docstrings anyway, can you also add to the documentation which direction |
|
These changes touch every file in the package, we should merge this PR first to minimize future work. So to sum up, I think there's agreement on changing these names:
The Internally the model works with the parameters listed in Is this acceptable to everyone? And finally, two options for the parameter names emerged: [ or [ Either of these looks good to me. Any final votes? What needs to be done before this is merged is minor fixes to the documentation and adding the properties. |
|
I think using It's a non-linear relationship My argument for using |
|
I have a strong preference for |
|
Ok, fine by me. But I don't think |
|
@adr I think I argued against |
|
Travis failure seems unrelated... |
|
Just restarted the travis failed build - probably that will fix it (as @adrn said, it looked like just a timeout, nothing real). Assuming it passes after that, this looks good to merge to me. |
|
Cool, build passed! |
Renamed parameters in Gaussian and added a cov_matrix kwarg
Gaussian1D, changed xsigma, xcen -> sigma, muGaussian2D, changed xsigma, ysigma -> x_sigma, y_sigma and xcen,ycen -> x_mu, y_muGaussian2D, removed the 'ratio' parameter -- too many ways to specify the same thing. Is this really necessary?Gaussian2D, added x_fwhm and y_fwhm to be consistent...but I would be in favor of removing the fwhm option entirely from both models and just requiring the standard deviation.Gaussian2D, but this is kind of klugy...I think the more general way to think about Gaussians is as a quadratic form -- it naturally generalizes to many dimensions -- so I think the definition ineval()should change. But then there's the issue of how to treat the covariance matrix as aParameter(see notes below).Notes:
When I added the cov_matrix option I realized that there is room here for a single
GaussianModelobject that accepts a scalar or vectormu, and eithersigmaorcov_matrix.sigmacould be a scalar or vector, in which case the Gaussian is assumed to be aligned with the coordinates, e.g. sqrt of each value along the diagonal of the covariance matrix. This would be a good way to support N-dimensional Gaussians.I started implementing the above, but got stuck on some weirdness that was going on with the
Parameterclass. I made the covariance matrix 2-dimensional, but it ends up becoming a list of arrays, so::array([[0.2,0.],
[0.,0.3]])
becomes
when I define it as a
Parameter...Then the fitting all fails because obviously you can't treat the cov. matrix like other parameters when feeding in to a NL fitting algorithm. We should think about this a bit more...