Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6990225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:19:11+00:00 2026-05-27T19:19:11+00:00

Averaging scalar wind direction data yields inaccurate values due to the compass headings ranging

  • 0

Averaging scalar wind direction data yields inaccurate values due to the compass headings ranging from 0-360 degrees, so I have converted my list to u and v components from the magnitude and wind direction angles already.

In order to back out the proper wind direction, for averaging purposes, I need to develop some sort of apply, ifelse, function for the 3 following scenarios:

V > 0...((180 / pi) * atan((Ucomp/Vcomp)) + 180)
U and V < 0...((180 / pi) * atan((Ucomp/Vcomp)) + 0)
U > 0 and V < 0...((180 / pi) * atan((Ucomp/Vcomp)) + 360)

In the data set I am looking to analyze, Ucomp is greater than 0 and Vcomp is less than zero, but there will undoubtedly be scenarios where all 3 will pan out, so I need a function to parse through and calculate iteratively and applying the correct formula for each time step. I have not used lapply or functions before, so me playing around with them has not worked.

I provide a sample of data below…

  DateTime Wind.Spd Wind.Direction Air.Density   Temp.C GEP.GE16XLE GCF.GE16XLE    Ucomp      Vcomp
1     1981 7.662370       248.3395   0.9148207 11.28967    597.7513    37.35946 5.253453 -0.7404972
2     1982 8.199412       251.6763   0.9172176 10.12751    678.8595    42.42872 5.867979 -0.6191475
3     1983 8.188782       251.7889   0.9162767 10.30619    667.9461    41.74663 5.777208 -1.0473982
4     1984 7.942632       246.7908   0.9174074 10.05093    642.6374    40.16484 5.415773 -0.6796723
5     1985 8.016558       252.7305   0.9171721 10.38414    654.2588    40.89117 5.649406 -0.9999082
6     1986 7.739984       249.6431   0.9158740 10.99859    607.0542    37.94089 5.305971 -0.9118965
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:19:11+00:00Added an answer on May 27, 2026 at 7:19 pm

    First define the function to do the calculation:

    windDir <- function(u, v) {
      if(v > 0)         ((180 / pi) * atan(u/v) + 180)
      if(u < 0 & v < 0) ((180 / pi) * atan(u/v) + 0)
      if(u > 0 & v < 0) ((180 / pi) * atan(u/v) + 360)
    }
    

    Then apply it to each row. Here I’m using ddply, which is a nice “apply” variety for data frames:

    > library(plyr)
    > ddply(data, 'DateTime', summarize, windDir=windDir(Ucomp, Vcomp))
      DateTime  windDir
    1     1981 278.0232
    2     1982 276.0232
    3     1983 280.2760
    4     1984 277.1531
    5     1985 280.0370
    6     1986 279.7517
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a program that parses data from a file and imports it into
I use the following to visualize the range of means when averaging n coin
I have large amounts of data (a few terabytes) and accumulating... They are contained
I'm trying to write a function in matlab for averaging images (all of the
I want to write a generic averaging algorithm. That is, for any type T
How does one find the rank of each element of an array, averaging in
Suppose I have a data array, dat <- array(NA, c(115,45,248)) Q1: What I do
Basically I want is to aggregate some values in a table according to a
I am currently working on a function for averaging images in MATLAB . But
I have vertex and triangle data which contains a color for each triangle (face),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.