ContactEngineering / topobank

Create, visualize, analyze, share, and publish digital surface twins
https://contact.engineering
MIT License
8 stars 3 forks source link

Only run average analyses for surfaces if at least 2 measurements #616

Open mcrot opened 3 years ago

mcrot commented 3 years ago

So far analyses for surfaces are only shown if there are more than one topography. The system still attempts to run them which can lead to unexpected error messages like

Traceback (most recent call last):
  File "/app/topobank/taskapp/tasks.py", line 127, in perform_analysis
    result = analysis.function.eval(subject, **kwargs)
  File "/app/topobank/analysis/models.py", line 278, in eval
    return self._implementation(subject_type).eval(subject, **kwargs)
  File "/app/topobank/analysis/models.py", line 330, in eval
    return pyfunc(subject, **kwargs)
  File "/app/topobank/analysis/functions.py", line 750, in variable_bandwidth_for_surface
    result = average_results_for_surface(surface, topo_analysis_func=variable_bandwidth,
  File "/app/topobank/analysis/functions.py", line 580, in average_results_for_surface
    result_series.append(average_series_list(series_list, num_points=num_points, xscale='log'))
  File "/app/topobank/analysis/functions.py", line 489, in average_series_list
    interpol = interp1d(s['x'], s['y'], bounds_error=False)  # inserts NaN outside of boundaries
  File "/opt/conda/lib/python3.8/site-packages/scipy/interpolate/interpolate.py", line 536, in __init__
    raise ValueError("x and y arrays must have at "
ValueError: x and y arrays must have at least 2 entries

Solution: Only trigger the average analyses if there is more than one measurement.

mcrot commented 3 years ago

This is not needed for v0.10.0, because in general this is invisible to the user, since only surface analyses are shown if there is more than one topography.