TypeError: make_interp_spline() got an unexpected keyword argument 'bounds_error'

I was trying to implement the BSplineInterpolation and I got this error:

Error

Traceback (most recent call last):
 File "/usr/local/lib/python3.6/dist-packages/eolearn/core/eotask.py", line 72, in _execute_handling
   return_value = self.execute(*eopatches, **kwargs)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/features/interpolation.py", line 426, in execute
   feature_data = self.interpolate_data(feature_data, times, resampled_times)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/features/interpolation.py", line 335, in interpolate_data
   interp_func = self.get_interpolation_function(input_x, input_y)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/features/interpolation.py", line 354, in get_interpolation_function
   return self.interpolation_object(times, series, **self.interpolation_parameters)
TypeError: make_interp_spline() got an unexpected keyword argument 'bounds_error'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "/usr/local/lib/python3.6/dist-packages/eolearn/core/eoexecution.py", line 192, in _execute_workflow
   results = workflow.execute(input_args, monitor=True)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/core/eoworkflow.py", line 172, in execute
   results = WorkflowResults(self._execute_tasks(input_args=input_args, out_degs=out_degs, monitor=monitor))
 File "/usr/local/lib/python3.6/dist-packages/eolearn/core/eoworkflow.py", line 210, in _execute_tasks
   monitor=monitor)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/core/eoworkflow.py", line 243, in _execute_task
   return task(*inputs, **kw_inputs, monitor=monitor)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/core/eotask.py", line 59, in __call__
   return self._execute_handling(*eopatches, **kwargs)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/core/eotask.py", line 85, in _execute_handling
   raise extended_exception.with_traceback(traceback)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/core/eotask.py", line 72, in _execute_handling
   return_value = self.execute(*eopatches, **kwargs)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/features/interpolation.py", line 426, in execute
   feature_data = self.interpolate_data(feature_data, times, resampled_times)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/features/interpolation.py", line 335, in interpolate_data
   interp_func = self.get_interpolation_function(input_x, input_y)
 File "/usr/local/lib/python3.6/dist-packages/eolearn/features/interpolation.py", line 354, in get_interpolation_function
   return self.interpolation_object(times, series, **self.interpolation_parameters)
TypeError: During execution of task BSplineInterpolation: make_interp_spline() got an unexpected keyword argument 'bounds_error'

I can’t seem to figure out the source of error. This is the code I used:

# TASK TO LOAD EXISTING EOPATCHES

load1 = LoadTask('./6.CloudFree_eopatch_folder')

resampled_range = ('2018-12-01', '2019-08-31', 10)       

Spline_interp1 =BSplineInterpolation(                                                                                         

   'BANDS', # name of field to interpolate                                                                                                                                                                                                                                                                                               

   mask_feature=(FeatureType.MASK, 'VALID_DATA'), # mask to be used in interpolation

   copy_features=[(FeatureType.MASK_TIMELESS, 'LULC'),

                  (FeatureType.MASK_TIMELESS, 'VALID_COUNT'), 

                  (FeatureType.DATA, 'CLP'),  

                  (FeatureType.DATA, 'NDVI'), 

                  (FeatureType.DATA, 'NORM'), 

                  (FeatureType.DATA, 'NDWI'), 

                  (FeatureType.DATA_TIMELESS, 'ARGMAX_B4'), 

                  (FeatureType.DATA_TIMELESS, 'ARGMAX_NDVI'), 

                  (FeatureType.DATA_TIMELESS, 'ARGMAX_NDVI_SLOPE'),

                  (FeatureType.DATA_TIMELESS, 'ARGMIN_NDVI'), 

                  (FeatureType.DATA_TIMELESS, 'ARGMIN_B4'), 

                  (FeatureType.DATA_TIMELESS, 'ARGMIN_NDVI_SLOPE'),

                  (FeatureType.DATA_TIMELESS, 'STF'),

                  (FeatureType.MASK, 'CLM'), 

                  (FeatureType.MASK, 'IS_DATA'), 

                  (FeatureType.MASK, 'VALID_DATA')], # features to keep 

   resample_range=resampled_range, # set the resampling range

   bounds_error=False # extrapolate with NaN's

)

fill_extrapolate1 = ValueFilloutTask(feature=(FeatureType.DATA,'BANDS'), operations='fb', value=np.nan, axis=0)

# TASK FOR SAVING TO OUTPUT 

save1 = SaveTask('./7.Spline_Interpolated_BANDS',overwrite_permission=OverwritePermission.OVERWRITE_PATCH)

# Define the workflow

workflow = LinearWorkflow(

   load1,

   Spline_interp1,

   fill_extrapolate1,

   save1

)

%%time

execution_args = []

execution_args.append({

   load1: {'eopatch_folder': f'eopatch_{8}'},

   save1: {'eopatch_folder': f'eopatch_{8}'}

   })

executor = EOExecutor(workflow, execution_args, save_logs=True)

executor.run(workers=12, multiprocess=True)

executor.make_report()

Hi @rim.sleimi

The answer to your question is written in your error message, last line:

TypeError: During execution of task BSplineInterpolation: make_interp_spline() got an unexpected keyword argument 'bounds_error'

You have specified the keyword bounds_error as an argument to BSplineInterpolation. In the documentation for the BSplineInterpolation, it is written that the function “implements eolearn.features.InterpolationTask”. So if we take a look at the detailed documentation of InterpolationTask, we can see that there is no argument bounds_error, hence the error.

Small hint: when I get error messages as you did, I find it helps to read the last line of the error to try and understand what happened (you can read up through the error in a second time if you need more details). The documentation of EoLearn also describes all the functions at this page and has a search bar that is quite useful.

Hope this helps you,

Thanks for the response!
I am still trying to wrap my head around classes. Could you please direct me where there is

no argument bounds_error ?

In this link, you can see the list of parameters written in bold for InterpolationTask, which is the main EOTask class for interpolation and resampling of time-series. Those parameters are the only ones that you can use in this class. And since the parameters for BSplineInterpolation are the same as InterpolationTask (as written in the documentation), you can’t use a parameter name that isn’t in the list.

I see, so all these parameters apply the same way for all types of Interpolation methods? such as the Linear Interpolation, BSplineInterpolation, krigingInterpolation…? .
But I have a very trivial question, please bear with me, in this tutorial I found this:

 bounds_error=False # extrapolate with NaN's

as an argument to the LinearInterpolation

I understand your confusion: the bounds_error parameter used to be valid, but then the code was updated and doesn’t use the parameter anymore.

Thank you for pointing this out, the example script will be soon updated, so that the bounds_error parameter is removed.

Ok, this makes sense now ! thank you for your explanation. One last thing I want to make sure of is the interpolation (regardless of its type: linear, spline, krigging…) here is performed on a pixel level? and if so is it performed with respect to the time ? in other words the value of the pixel at date t is interpolated using the pixel (at the same location) of the date t+1 (image after) and t-1 (image before)?

Yes, that is correct. The interpolation you are doing in this step is a per-pixel temporal interpolation.

The task takes from EOPatch the specified data feature and timestamps. For each pixel in the spatial grid it creates an interpolation model using values that are not NaN or masked with eopatch.mask[‘VALID_DATA’]. Then it replaces invalid values using interpolation model. If resample_range parameter is used the values in time series will be resampled to new timestamps.
In the process the interpolated feature is overwritten and so are the timestamps. After the execution of the task the feature will contain interpolated and resampled values and corresponding new timestamps.

1 Like

Thank you very much for the clarification ! this is really helpful !

Hey, I tried this and it didn’t work.

# TASK FOR LINEAR INTERPOLATION
# linear interpolation of full time-series and date resampling
resampled_range = ('2018-12-01', '2019-08-31', 10)       
linear_interp1 =BSplineInterpolation(                                                         #LinearInterpolation(                                 
    'BANDS', # name of field to interpolate                                                                                                                                                                                                                                                                                               
    mask_feature=(FeatureType.MASK, 'VALID_DATA'), # mask to be used in interpolation
    copy_features=[(FeatureType.MASK_TIMELESS, 'LULC'),
                   (FeatureType.MASK_TIMELESS, 'VALID_COUNT'), 
                   (FeatureType.DATA, 'CLP'),  
                   (FeatureType.DATA, 'NDII'),
                   (FeatureType.DATA, 'GNDVI'),
                   (FeatureType.DATA, 'NDVI'),
                   (FeatureType.DATA, 'NDRE'), 
                   (FeatureType.DATA, 'NORM'), 
                   (FeatureType.DATA, 'NDWI'), 
                   (FeatureType.DATA_TIMELESS, 'ARGMAX_B4'), 
                   (FeatureType.DATA_TIMELESS, 'ARGMAX_NDVI'), 
                   (FeatureType.DATA_TIMELESS, 'ARGMAX_NDVI_SLOPE'),
                   (FeatureType.DATA_TIMELESS, 'ARGMIN_NDVI'), 
                   (FeatureType.DATA_TIMELESS, 'ARGMIN_B4'), 
                   (FeatureType.DATA_TIMELESS, 'ARGMIN_NDVI_SLOPE'),
                   (FeatureType.DATA_TIMELESS, 'STF'),
                   (FeatureType.MASK, 'CLM'), 
                   (FeatureType.MASK, 'IS_DATA'), 
                   (FeatureType.MASK, 'VALID_DATA')], # features to keep 

    interpolate_pixel_wise=True,
    resample_range=resampled_range, # set the resampling range
)

fill_extrapolate1 = ValueFilloutTask(feature=(FeatureType.DATA,'BANDS'), operations='fb', value=np.nan, axis=0)

# TASK FOR SAVING TO OUTPUT 
save1 = SaveTask('./7.TEST_BSpline_Interpolated_NDVI',overwrite_permission=OverwritePermission.OVERWRITE_PATCH)

This is what the execution report shows:

I got the same report for all the features (NDVI, NDWI, GNDVI…). I would have used .squeeze() but I am not sure where to add it.

On the other hand when using LinearInterpolation with and without the bounds_error=False it worked . I don’t know what did I do wrong here.