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

Inconsistent spline boundary conditions #243

Open
ado8 opened this issue Oct 11, 2024 · 1 comment
Open

Inconsistent spline boundary conditions #243

ado8 opened this issue Oct 11, 2024 · 1 comment
Labels

Comments

@ado8
Copy link

ado8 commented Oct 11, 2024

Issue

The spline evaluation in shapes._curve_F99_method uses scipy.interpolate.splrep and splev, where the splrep documentation states

The default boundary condition is ‘not-a-knot’, i.e. the first and second segment at a curve end are the same polynomial. More boundary conditions are available in CubicSpline.

This is inconsistent with Fitzpatrick's IDL routine which uses CSPLINE, which uses SPL_INIT with default YP0 and YP1 arguments, which ultimately results in a spline with 'natural' boundary conditions (second derivative is 0 at ends) rather than 'not-a-knot' boundary conditions.

Severity of issue

The _curve_F99_method is called in the F99 and F04 dust laws.
The differences due to the boundary conditions is on the order of millimags, but varies with RV and wavelength as shown in the attached figure.
image

Proposed change

This can be fixed by replacing

spline_rep = interpolate.splrep(spline_x, spline_y)
axav[indxs_opir] = interpolate.splev(x[indxs_opir], spline_rep, der=0)

with

axav[indxs_opir] = interpolate.CubicSpline(spline_x, spline_y, bc_type='natural')(x[indxs_opir])
@karllark karllark added the bug label Oct 11, 2024
@karllark
Copy link
Owner

Thanks for raising this issue! This is a detail I was not aware of. I'll have a look and evaluate in a week or so. Hope this is soon enough.

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

No branches or pull requests

2 participants