ContactEngineering / topobank-statistics

Plugin for TopoBank that provides statistical analysis functions
MIT License
2 stars 1 forks source link

Remove current implementation of mean slope in slope distribution analysis #23

Open mcrot opened 5 years ago

mcrot commented 5 years ago

The current calculation of mean slope seems to be wrong:

    if topography.dim == 2:
        slope_x, slope_y = topography.derivative(n=1)
        slope = np.sqrt(2) * np.append(np.ma.compressed(slope_x),
                                       np.ma.compressed(slope_y))
    elif topography.dim == 1:
        slope = topography.derivative(n=1)
    else:
        raise ValueError("This analysis function can only handle 1D or 2D topographies.")

    mean_slope = np.mean(slope)

The factor np.sqrt(2) is related to line scans to make the slope distribution comparable to those of maps, but topography.dim==2 is already a map.

mcrot commented 5 years ago

@pastewka I think we need some more discussion here.

1) The value of the slope variable is also used to build the histogram, so the question is still whether how we define the slopes. Can't we just create three different distributions for x, y and for absolut gradients ? 2) The mean_slope value is also used for the gaussian. Should we have gaussians for x and y directions instead? And can't we then calculate the theoretical distribution for the absolute gradient from them?

pastewka commented 5 years ago

Yes this would be possible. Do you want to show x and y gradient in one plot but as separate lines? I guess that would be clearer...

mcrot commented 5 years ago

Yes, distributions for x and y in one plot as separate lines. The distribution for the absolute gradient is probably better placed in a second plot because of the completely different meaning of the x axis.

Btw. do we have topography data for one surface including line scans and maps? That would be nice in order to compare the distributions and to see whether the results are consistent - this is a requirement if I understood correctly.

mcrot commented 5 years ago

@pastewka I think the calculation of the absolute gradient would be easier and more accurate if np.gradient() was used in Pyco, please see my proposal here.

Then np.gradient(topography.heights(), dx, dy) does a similar thing as topography.derivative(n=1) (except handling of periodic boundaries), but then the absolute gradient is easily determined by np.sqrt(slope_x**2+slope_y**2). What do you think?

pastewka commented 5 years ago

Why can't you use the present derivative function?