Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Backed Veered wind direction


Makada Oct 8, 2020 06:15 PM

Hi all,

I am looking for an crbasic instruction to have backed and veered wind direction.

I need a 12 second average direction and most backed most veered from those 12 second samples.

Anyone able to show me an example?

With kind regards.


Makada Oct 9, 2020 05:11 PM

 Hi,

I found this piece of code in the RTMC Pro help files.

But i dont know how i can adjust it to have the most backed and veered values for five 12 seconds average direction and fifty 12 seconds average direction.

Public WD_val, AvgRunWindD, mostbacked, mostveered
Public deltawind, deltaD, WindD, MaxD(2), MinD(2), AvgWindD, lastwind
Dim WindDHist(60)
Public change

DataTable (testalgorithm,True,-1)
  DataInterval (0,1,min,10)
  WindVector (1,1,WD_val,IEEE4,False,0,0,0)
  Sample (1,AvgRunWindD,IEEE4)
  Sample (1,mostbacked,IEEE4)
  Sample (1,mostveered,IEEE4)
EndTable

AngleDegrees

'Main Program
BeginProg
  change=0.5
  Scan (1,Sec,0,0)
    VoltDiff(WD_val,1,mV2500,2,True,0,250,0.1795,-0)    
    'The wind direction in the range of 0-360 needs to be written to a variable called
    'WD_val for this example.
    'The following code was written for test purposes and simulates a slowly altering
    'wind direction.  The change variable allows the user to vary the drift of
    'direction.
    If RND > 0.5 Then
      WD_val = WD_val + RND*20
    Else
      WD_val=WD_val - RND*20
    EndIf
    If WD_val < 0 Then WD_val = 360 + WD_val
    WD_val = WD_val + change
    WD_val = WD_val MOD 360
    '-------------------Wind veering and backing---------------------------------
    'Convert to a running wind direction using a modified version of the Mitsuta (EPA)
    'method.
    'That wind direction avoids the problems with the North transition so
    'standard statistics can be applied to it (Max and Min in this case)
    'see http://www.epa.gov/scram001/guidance/met/mmgrma.pdf
    'First work out the change since the last reading - use the current and previous
    'wind on a 0-360 scale.  This is the main difference from most similar EPA style
    'algorithms.
    'This was needed to allow for rolling averaging.
    deltawind = WD_val - lastwind
    lastwind = WD_val
    'Work out the change in the continuous direction by adding or subtracting 360 to
    'avoid the discontinuity issue.
    deltaD = deltawind 'Default for Normal variation not crossing North
    If deltawind < -180 Then deltaD=deltawind+360 'Gone through North from West to East.
    If deltawind > 180 Then deltaD=deltawind-360 'Gone through North from East to West.
    'Work out Wind_D, the continuous representation of wind direction (with no 0-360
    'transition). Use a double precision addition as we will be adding to WindD forever
    'and need to avoid rounding errors.
    AddPrecise (WindD,deltaD)
    'Shift and update the buffer of wind directions (60 values in this case).
    Move (WindDHist(2),59,WindDHist(1),59)
    WindDHist(1)= WindD
    'Find the min and max values in the buffer which will be the most backed and veered
    'values. Note the buffer needs to have filled fully before sensible values are
    'returned.
    MaxSpa (MaxD,60,WindDHist())
    MinSpa (MinD,60,WindDHist())
    'Optional running average of direction using the same buffered data (saves on
    'memory.
    AvgSpa (AvgWindD,60,WindDHist())
    'Work out the directions by adding on a big multiple of 360 (to correct for
    'directions < 0). Then MOD by 360 to give degrees.
    mostbacked = (MinD(1)+36000) MOD 360
    mostveered = (MaxD(1)+36000) MOD 360
    AvgRunWindD = (AvgWindD+36000) MOD 360
    'Check if the value of WindD is getting too big or too small. In the very unlikely
    'event that the wind direction has gone around 95 times in one direction reset
    'the virtual direction to the current reading to keep within +/-100 turns of zero.
    'This will cause a glitch on the backed and veered but is unavoidable and should not
    'happen often, if at all in practice.
    If ABS(WindD)>34200 Then WindD = WD_val
  CallTable testalgorithm  'Stores data for test in this case
  NextScan
EndProg

 


Makada Oct 10, 2020 12:19 PM

Hi,

I came up with this piece of code.

I dont know if this is the way to accomplish what i want.

Maybe someone can shine a light on it?  :)

 

Public WS_KPH, WD_val, AvgRunWindD, AvgRunWindD50, twaalf_sec_avg_WindDir, mostbacked, mostveered, mostbacked50, mostveered50
Public deltawind, deltaD,  MaxD(2), MinD(2),MaxD50(2), MinD50(2), AvgWindD, AvgWindD50, lastwind
Public WindDHist(5)
Public WindDHist50(50)

DataTable (table_12_sec,True,-1)
DataInterval (0,12,Sec,10)
WindVector (1,WS_KPH,WD_val,IEEE4,False,0,0,0)
FieldNames("WS_KPH_S_WVT,WindDir_D1_WVT,WindDir_SD1_WVT")
Sample (1,AvgRunWindD,IEEE4)
Sample (1,mostbacked,IEEE4)
Sample (1,mostveered,IEEE4)
EndTable

DataTable (table_one_min,True,-1)
DataInterval (0,1,Min,10)
WindVector (1,WS_KPH,WD_val,IEEE4,False,0,0,0)
FieldNames("WS_KPH_S_WVT,WindDir_D1_WVT,WindDir_SD1_WVT")
Sample (1,AvgRunWindD,IEEE4)
Sample (1,mostbacked,IEEE4)
Sample (1,mostveered,IEEE4)
EndTable

DataTable (table_ten_min,True,-1)
DataInterval (0,10,Min,10)
WindVector (1,WS_KPH,WD_val,IEEE4,False,0,0,0)
FieldNames("WS_KPH_S_WVT,WindDir_D1_WVT,WindDir_SD1_WVT")
Sample (1,AvgRunWindD50,IEEE4)
Sample (1,mostbacked50,IEEE4)
Sample (1,mostveered50,IEEE4)
EndTable

AngleDegrees
'Main Program
BeginProg
Scan (1,Sec,0,0)
VoltDiff(WD_val,1,mV2500,2,True,0,250,0.1795,-0)
WD_val = WD_val + 140
If WD_val > 360 Then WD_val = WD_val - 360
If WD_val>=360 Then WD_val=0
If WD_val < 0 Then WD_val = 360 + WD_val
WD_val = WD_val MOD 360

VoltDiff(WS_KPH,1,mV2500,1,True,0,250,0.09,-45)

If table_12_sec.output Then
twaalf_sec_avg_WindDir = table_12_sec.WindDir_D1_WVT(1)

deltawind = twaalf_sec_avg_WindDir - lastwind
lastwind = twaalf_sec_avg_WindDir
deltaD = deltawind 'Default for Normal variation not crossing North
If deltawind < -180 Then deltaD=deltawind+360 'Gone through North from West to East.
If deltawind > 180 Then deltaD=deltawind-360 'Gone through North from East to West.

AddPrecise (twaalf_sec_avg_WindDir,deltaD)

Move (WindDHist(2),4,WindDHist(1),4)
Move (WindDHist50(2),49,WindDHist50(1),49)
WindDHist(1)= twaalf_sec_avg_WindDir
WindDHist50(1)= twaalf_sec_avg_WindDir
AvgSpa (AvgWindD,5,WindDHist())
AvgSpa (AvgWindD50,50,WindDHist50())
MaxSpa (MaxD,5,WindDHist())
MaxSpa (MaxD50,50,WindDHist50())
MinSpa (MinD,5,WindDHist())
MinSpa (MinD50,50,WindDHist50())

mostbacked = (MinD(1)+36000) MOD 360
mostbacked50 = (MinD50(1)+36000) MOD 360
mostveered = (MaxD(1)+36000) MOD 360
mostveered50 = (MaxD50(1)+36000) MOD 360
AvgRunWindD = (AvgWindD+36000) MOD 360
AvgRunWindD50 = (AvgWindD50+36000) MOD 360

If ABS(twaalf_sec_avg_WindDir)>34200 Then twaalf_sec_avg_WindDir = twaalf_sec_avg_WindDir
endif
CallTable table_12_sec
CallTable table_one_min
CallTable table_ten_min
NextScan
EndProg

 


Makada Oct 12, 2020 01:13 PM

I see its not properly working, specific when winddirection is in the north area.

The "averagerunwindd" doesnt match the windvector direction when it is north oriëntated. 

I see in order to have it right: left of north data should be - , right of north should be +.


Makada Oct 14, 2020 07:06 PM

Hi,

I tried the above code but i cant get it to work.

I cant find a way to get it working.

Log in or register to post/reply in the forum.