Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display issue with time series of directional data #75

Open
dotis opened this issue Apr 15, 2024 · 1 comment
Open

Display issue with time series of directional data #75

dotis opened this issue Apr 15, 2024 · 1 comment
Assignees

Comments

@dotis
Copy link
Collaborator

dotis commented Apr 15, 2024

There is an issue with the display of data that goes from 0 to 360 degrees in grafana. An arithmetic mean does not work, as the mean of 1 degree and 360 degrees will be around 180 degrees. According to NDBC, the only thing that changed at this station is "We did a service visit in mid-June 2023 that converted the station from once per hour transmissions to every 10 minutes (twice per hour waves)."

Here is the wave direction from NDBC for the buoy at Gray's reef:
image

Here is the same data from grafana for roughly the same time period.
image

@dotis dotis assigned 7yl4r and dotis Apr 15, 2024
@7yl4r
Copy link
Member

7yl4r commented Apr 17, 2024

This one will be an interesting challenge. We might look into alternative visualization panels for display, but I don't see any built-in to deal with polar data.

To deal with the averaging issue at the database level we may be able to use functions in InfluxQL.

Step-by-step Process

  1. Convert degrees to radians
  2. Convert each angle to its Cartesian coordinates (x, y) using COS() and SIN().
  3. Average the x and y coordinates separately using the MEAN() function.
  4. Compute the angle from the averaged x and y values using the ATAN2() function.

PI/180 ~= 0.0174532925199 so step 1 will look something like:

SELECT 0.0174532925199 * "value" FROM "selector"

conceptual example of steps 2-4:

SELECT ATAN2(MEAN(SIN(radians)), MEAN(COS(radians))) AS mean_angle
FROM your_measurement
WHERE time >= 'start_time' AND time <= 'end_time'
GROUP BY time_group

This is going to take some fiddling around in the grafana interface to get right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants