-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite of Model.plot() #281
Conversation
This looks good overall, thanks. I admit I'm still a tad bit confused about what role
|
I see the YAML file as concise instructions for how to generate the Features table. Specific edits that are not easily expressed in the YAML file (e.g. based on logic in your Python code), can be applied afterwards.
That all sounds correct. Model knows how to deal with the Features table, the Spectrum1D data, and manages the Fitter and its inputs and outputs.
Yes, Model initializes and sets up the fitter, according to the information provided by the user and the Features table. At the initialization step, a subclass of Fitter needs to be chosen. I plan to do it as a hackable constant in the In my current implementation, a new Fitter object is constructed whenever it is needed. Every time a fit is performed, Fitter is initialized, and set up. It is then used to perform the fit, after which the results are extracted from the Fitter and written out to the Features table. The Fitter object could then be discarded in principle, but for diagnostic reasons I keep it around. For tabulate, the above logic is reused to set up a temporary Fitter with a subset of the Features table (which now contains the fit results). In fact, the fit() logic already uses a subset as only features within the observed wavelength range are used. Instead of performing a fit, So technically no direct calls to self.fitter.gaussian(params) are needed in tabulate(). But I will still implement such evaluation functions, as they can be used by the different Fitter subclasses for additional consistency.
This is how it currently works. In a few cases, I find this a minor annoyance. E.g. it is not always clear to the user why the instrument information is needed in some cases. Keeping a long-term instrument awareness for Model is a valid choice. But I feel it does not have major implications for the functionality, aside from simplifying some of the function calls. |
I think keep it simple with a string-based keyword with a default (which may change at some point), e.g.
So every fit creates a
That's pretty clever. Then we do need to normalize how
Now that I understand it, I suppose we don't have to; keeps the We can take additional
You can fit a |
Note, I have retargeted this PR to |
Please take a look at the review comments above and let me know what needs addressing. |
I have copied these comments to #280 , and will address some of them there when the Fitter API pull request is up.
If we add more plotting options, like this example, we might eventually want to move the actual plotting code to a separate module. I will now solve the merge conflict, after which we are probably good to merge this. |
Did you see my reviews above @drvdputt? Pending those small changes is this ready to merge to dev? Hack day starting today; if we get dev assembled I can have my student do some testing on it. |
Can't see that? My fault I think (though others find this confusing): https://github.com/orgs/community/discussions/10369 |
No I still can't see anything. I'm not sure if I'm familiar with the feature you're trying to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I neglected to "finish review". Some of these are more "observations" than "do something right now" comments.
pahfit/model.py
Outdated
# total model | ||
model = self._construct_astropy_model( | ||
inst, z, use_instrument_fwhm=use_instrument_fwhm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confused here: why is this called model
? We are in Model
, so shouldn't this be self
? Or perhaps really we should be using self[.features].tabulate()
to get "the full fitted current model to apply to some wavelengths`.
Also, doesn't a Model
know its own redshift? That seems like a "physics detail", not one that is updated by fit
, but certainly a physical piece of information. It's not in the Features
table, but it should be "in the model". One can obviously update the redshift in the model if one wants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is this one of the vestiges that need to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, it is ok to use the underlying astropy model. Will be replaced by Fitter
eventually, or even better, just another tabulate
call. It seems I'm only using this variable in one place, so I will do a quick check to see if there's an obvious simplification, and use tabulate instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we don't want the Model
to "know anything" about the Fitter
it is using.
Sorry I had neglected to "submit" the review, which can't be done from mobile GH. |
Usually I just do ala carte comments, this time (apparently) I "started a review". Note to self: |
Let me know when you think this one is ready. |
Just did some testing. The tests are failing in the expected place (unrelated to these changes, will be fixed once all the rest is done). Everything in the demo notebook is also running. I say we are good to go with this one. |
First pull request for #280