TomasBeuzen / pybeach

A Python package for locating the dune toe on cross-shore beach profile transects.
MIT License
18 stars 12 forks source link

When creating classifier, docstring is incorrect regarding required shape of z #12

Closed conlin-matt closed 3 years ago

conlin-matt commented 3 years ago

Hi Tom,

Small issue here, but I've noticed that when using pybeach.support.classifier_support.create_classifier to create a classifier from multiple profiles, the shape of z needs to be (n,m) rather than (m,n) as stated in the docstring. This can be seen by running the following in an interpreter:

import numpy as np
from numpy import matlib
from pybeach.support import classifier_support as cs
from scipy.interpolate import interp1d

# Create dummy profile #
x = np.arange(0,10)
z = [9.8,10,9,8,7,6,5.8,5.6,5.4,5.2]

# Create dummy x and z data (with 100 of the same profile) based on dummy profile #
xi = np.arange(0,100,0.1)
f = interp1d(x,z,fill_value=np.nan,bounds_error=False);zi = f(xi)
zi = np.transpose(matlib.repmat(zi,100,1))
toes = np.tile(50,100)
print('x shape:'+str(np.shape(xi)),'z shape:'+str(np.shape(zi)),'toes shape:'+str(np.shape(toes)))

# Try to create the classifier #
clf = cs.create_classifier(xi, zi, toes, window=2, min_buffer=40, max_buffer=200)
# Note IndexError about boolean index not matching indexed array #
clf = cs.create_classifier(xi, np.transpose(zi), toes, window=2, min_buffer=40, max_buffer=200)
# Note that this worked with transposed z #

I suppose just changing the docstring here would be the way to go. Thanks for putting together such a helpful and easy-to-use package!

TomasBeuzen commented 3 years ago

Thanks @conlin-matt! I've actually been out of the coastal space for 2 years or so but glad to see this package is still getting used! I'm about to have some time off between jobs and it's been on my list to come back and update things around here so thanks for raising this issue and for the motivation! 🚀