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

snfit compatibility and testing #171

Merged
merged 13 commits into from
Jan 4, 2017
Merged

Conversation

kbarbary
Copy link
Member

@kbarbary kbarbary commented Dec 28, 2016

The goal of this PR is to test the SALT2 model against the implementation in snfit and to make modifications to the sncosmo implementation where necessary.

Interpolation

Although the snfit codebase has some code for basis splines, it doesn't appear to actually be used in the SALT2 model. The components of the model are actually backed by Grid2DFunction objects. This class performs bicubic convolution, except when the input value is within one knot of any boundary, in which case it performs bilinear interpolation.

Although this is generally a worse interpolator than scipy's RectBivariateSpline, I've implemented an equivalent in cython (the BicubicInterpolator class, which can be found in sncosmo/salt2utils.pyx in this PR), and intend to use it in sncosmo's SALT2 model (not yet done). Here's why I say it is a worse interpolator:

cubic_interpolator_comparison

I do wish the snfit implementation had just used splines, but for now we're valuing consistency.

As an aside, the implementation of the interpolator here is likely to be faster than the C++ implementation in snfit because this version operates on arrays of points whereas the C++ version operates one point at a time. Because we're often evaluating the interpolator on a grid of points (in wavelength and time), there are savings to be had in lookups and reusing coefficients between points on the grid.

SALT2 color law

This PR also implements the SALT2 color law in cython (SALT2ColorLaw in sncosmo/salt2utils.pyx). Formerly we had an exact Python implementation and then used a spline approximation to it for speed. The cython implementation allows us to skip the approximation. Additionally, it actually turns out to be faster than the spline evaluation.

Testing

This PR adds a small C++ program (misc/test_salt2model.cc) that links to a built snfit to output some results from the salt2 model that we can test against in sncosmo. (Testing not yet done.) The C++ program is there for provenance, but won't actually be used in running sncosmo tests. Rather, the output from the C++ program is included in the repo under test data (sncosmo/tests/data).

@kbarbary kbarbary changed the title WIP: snfit compatibility and testing snfit compatibility and testing Jan 4, 2017
@kbarbary kbarbary merged commit 9e4d996 into sncosmo:master Jan 4, 2017
@kbarbary kbarbary deleted the snfit-compat branch January 4, 2017 23:05
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

Successfully merging this pull request may close these issues.

None yet

1 participant