4Subsea / waveresponse-python

Vessel motion and wave utilities
https://docs.4insight.io/waveresponse/python/latest/
MIT License
12 stars 4 forks source link

_check_dirs fails if largest direction >= 2.0*pi but according error message this should be 360 #63

Open RubendeBruin opened 2 months ago

RubendeBruin commented 2 months ago

_check_dirs fails if largest direction >= 2.0*pi but according error message this should be 360

    def _check_dirs(self, dirs):
        """
        Check direction bins.
        """
        if np.any(dirs[:-1] >= dirs[1:]) or dirs[0] < 0 or dirs[-1] >= 2.0 * np.pi:
            raise ValueError(
                "Directions must be positive, monotonically increasing, and "
                "be [0., 360.) degs (or [0., 2*pi) rads).\n"
                f"Got provided {dirs}"
            )
heidi-holm-4ss commented 2 months ago

Hi, can you explain a bit more?

RubendeBruin commented 2 months ago

sorry, updated the comment.

If a the dirs are defined in degrees then this function fails because it checks if dirs[-1] >= 2.0 * pi.

I think the function should check whether the definition is in degrees or radians and then check the maximum value accordingly.

heidi-holm-4ss commented 2 months ago

I believe that we always convert to radians, even though the user provides directions in degrees, see the init method. Hence I don't think that is necessary. We should probably remove the degrees part of the error message