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

Add Spline1D to modeling #7522

Closed
eteq opened this issue Jun 1, 2018 · 4 comments
Closed

Add Spline1D to modeling #7522

eteq opened this issue Jun 1, 2018 · 4 comments

Comments

@eteq
Copy link
Member

eteq commented Jun 1, 2018

I notice there's no spline-based model in astropy.modeling.models. To give a specific use case, in some of the specutils planned functions one might want to use a spline as a continuum model. But if that machinery uses astropy models to do the fitting, it's not possible to say "use a spline as the continuum". So that suggests that at least a 1D spline model should be an option.

The catch here is that splines are a rather strange kind of model as far as the modeling API is concerned. You can't really initialize them without data (although they could be initialized as just all-0s), and the parameter list is rather confusing because there's several parameters per-knot, and they aren't really exposed that way in scipy's UnivariateSpline (probably the most natural underlying implementation). Additionally, you really want to always use them with a custom fitter, given that spline-optimized fitters are far more performant than any generic fitter would be. So a new fitter would also need to be implemented and users would have to know they should use that fitter if the model is a spline.

None of those are necessarily roadblocks, though. Personally I think the functionality is worth it... But I'd be interested what @nden @perrygreenfield @astrofrog, or any others might think?

@nden
Copy link
Contributor

nden commented Jun 1, 2018

The Tabular model is an example of a model initialized with data. It'd be great to have splines. 👍

@jehturner
Copy link
Member

FYI, @chris-simpson has used the spline fitting from scipy.interpolate in our code at https://github.com/GeminiDRSoftware/DRAGONS/blob/master/geminidr/core/primitives_ccd.py, if that's in any way useful. He was also working on adjusting the knots to deal with rejected points. But indeed it looks like the spline case is not using the modeling machinery, which would make it more awkward for us to write some code that propagates its solution as a Model (perhaps a read-only model).

At a glance, it looks like it might be feasible to split that scipy code into a model representation and a special fitter as @eteq mentions, since UnivariateSpline & LSQUnivariateSpline are just wrapper classes for several underlying FITPACK spline routines.

@jehturner
Copy link
Member

See also #11634.

@WilliamJamieson
Copy link
Contributor

This has been in since #11634

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

No branches or pull requests

4 participants