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

DM-38616: Add GSL interpolation for Sersic gaussian mixture #10

Merged
merged 10 commits into from
Dec 8, 2023

Conversation

taranu
Copy link
Collaborator

@taranu taranu commented Dec 5, 2023

No description provided.

Copy link

@fred3m fred3m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor comments.

&g2f::GSLSersicMixInterpolator::correct_final_integral)
.def_property_readonly("final_correction",
&g2f::GSLSersicMixInterpolator::get_final_correction)
.def("integralsizes", &g2f::GSLSersicMixInterpolator::get_integralsizes)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this and other methods with parameters, I recommend including them here to make the interface more user friendly, like you did for your init method.

Comment on lines 16 to 20
if (!((sersicindex >= sersicindex_min) && (sersicindex <= sersicindex_max))) {
throw std::invalid_argument("sersicindex=" + std::to_string(sersicindex)
+ " !(>=" + std::to_string(sersicindex_min)
+ "&& <=" + std::to_string(sersicindex_max));
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rephrase this? Something like "sersicIndex is not between sersicindex_min and sersic index_max."

if (!(integral >= 0)) {
throw std::logic_error(this->str() + ".get_integralsizes(" + to_string_float(sersicindex)
+ ") got correction=" + to_string_float(_final_correction)
+ " from integral=" + to_string_float(integral) + " !>=0");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "... <0" instead of "... !>=0."

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same goes for simplifying the rest of the error messages in this file.

Comment on lines +30 to +35
// It's not so obvious how a polynomial interpolator should behave
// (best not to use them with so few knots in the first place)
if (type != g2f::InterpType::polynomial) {
CHECK(interp_0 > (y[0] + y[1]) / 2.);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could implement a test in python that compares your results to scipy spline results for other splines within a given tolerance. If you don't already have scipy as a dependency then you could just hard code the scipy results just to make sure that you don't accidentally do something wonky (not that I know anything about that).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would not make sense to add scipy as a dependency here, so I added functionality in multiprofit to plot scipy-interpolated values instead. As expected, they're nearly identical for the cubic spline.

You're right that I should add a test against absolute values. I think I will defer doing that until I'm convinced that the default knot values and spline method are optimal. In a sense, changing the interpolator will make it a different profile and change fitted parameter values so I will also discourage doing so in the future.

@taranu taranu merged commit 420d700 into main Dec 8, 2023
1 check passed
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

2 participants