Skip to content
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

starlight sub_model error #252

Open
cwhitco opened this issue Dec 21, 2022 · 2 comments
Open

starlight sub_model error #252

cwhitco opened this issue Dec 21, 2022 · 2 comments

Comments

@cwhitco
Copy link

cwhitco commented Dec 21, 2022

using dev branch version, there is an error when trying to get single component sub_models like the starlight continuum
my code, after fitting a spectrum spec with model:
starspec = model.sub_model(instrumentname=spec.meta['instrument'], redshift=spec.redshift, kind='starlight') PAHFITModelError: Fewer than 2 features! Single component models are no allowed!

@drvdputt
Copy link
Contributor

drvdputt commented Jan 4, 2023

Thank you for reminding me of this restriction I put in. I did this because there is some code that can't deal with a single-component model. (The resulting astropy model is no longer a multi-component model, so loops "over the components" won't work).

I would like a workaround for this, we also need to consider that

  1. We will remove sub_model and replace it with tabulate. See Tabulate model spectrum #249. (This will still have the same issue though...)
  2. A different fitting backend is being developed (not based on astropy). But this will take a while before it gets merged.

As a temporary workaround, you can go head and comment out these lines in the source code of model.py, in Model.__init__()

        # if len(features) < 2:
        #     raise PAHFITModelError(
        #         "Fewer than 2 features! Single component models are not allowed!"
        #     )

I did a quick test, and sub_model() will work for single components if you do this. It's just guess() and fit() that will fail, when those functions try to parse the components of the astropy model.

@drvdputt
Copy link
Contributor

sub_model does not exist anymore, and its replacement tabulate() works for a single component (as tested with the current state of the dev branch). This issue can therefore be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants