Skip to content

Conversation

@egiovan
Copy link

@egiovan egiovan commented Jan 30, 2025

I added the possibility to create a derivative of a fitpack_grid_surface. In order to do that I decided to split the original fitpack_grid_surface in two different user defined type, one the original but having eliminated from it the information about the knots. The other one contains the results of the fit or of the interpolation.
This was necessary because it would be senseless to fit again with the method fit or the method interpolate the derivative of a spline.
I think the code is better this way with two separate class, one that is basically a fitter and the other one the is the resulting spline.
We may think of other method that can be applied to a resulting spline. But let's see.
In the way I corrected a bug. The original sizes of the work arrays were calculated in advance and depended on the size of the arrays used in the fitting. But when evaluating a 2D spline the sizes of the work arrays should depend on the size of the x and y arrays where one want the spline calculated. For example if one use to fit a spline with array long NX and NY but want the resulting spline on array long 10NX and 10NY, well, the size of the pre-calculated work array is not enough.
So while I keep the work arrays in the fitpack_grid_surface I added other work arrays in fitpack_grid_result.
I also added some procedure to increase the size of the work arrays when needed.
The could be other things that may be done, like returning the variable ier in the fitpack_grid_result, or change its name or apply the same concept to the other surface splines.
So it is still a work in progress. But I would like your comments.
Cheers

…n user defined type in two, one, like the original, is devoted to fit the data. The other (fitted_grid_result) contains the result of the fitting and can be used to evaluate the spline at different x and y position. This last can be derived and one can get anothe spline which contains the derivative. This is as before a fitpack_grid_result user defined type.
@perazz
Copy link
Owner

perazz commented Jan 31, 2025

Thank you! Much appreciated.

I'm trying to understand how pardtc works (never used it myself).
If we look at the corresponding functionality in SciPy, it looks like it should be possible to return a new whole spline object:

https://github.com/scipy/scipy/blob/fe8900953b4c7a623967c5ced8aec7cd0f8c5e09/scipy/interpolate/_fitpack2.py#L1096-L1143

They create a new "DerivedBspline" class just for pardtc:

https://github.com/scipy/scipy/blob/fe8900953b4c7a623967c5ced8aec7cd0f8c5e09/scipy/interpolate/tests/test_fitpack2.py#L1342-L1392

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.

2 participants