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.

Winddirection from degrees to N, E, S, W


Mavada Jan 25, 2011 03:40 PM

How do i convert the values from the winddirection from degrees to North, East, South, West in CRBasic?


IslandMan Jan 26, 2011 11:17 AM

I would use If/Then statements to define the string of north, east, south or west. You could also use Case statements. I would think you might want them broken up into smaller segments as well, say the typical 16 compass points. If you need this in a report, SPLIT which is in Loggernet, has a built in feature to do this.

http://www.adamsenvsys.com/MetData/ADAMSENVDAILY.HTM

* Last updated by: IslandMan on 1/26/2011 @ 4:17 AM *


Mavada Jan 26, 2011 11:51 AM

If i use this:

If Windr < 90 Then Windroos = N
If Windr < 180 Then Windroos = E

CRBasic doesnt recognize N or E, only numbers...

Im not that good at crbasic, can you give me an example of it?


Mavada Jan 26, 2011 11:54 AM

This is my total crbasic programm, maybe you can see im not that experienced with crbasic, but i got it working....

'CR1000
'Created by Short Cut (2.8)

'Declare Variables and Units
Public BattV
Public Windr
Public Temp
Public Vocht
Public Windskm
Public Rain_mm
Public BP_mbar
Public SlrW
Public SlrkJ
Public Tot24
Public Windskn
Public Beaufort

Units BattV=Volts
Units Windr=mV
Units Temp=mV
Units Vocht=mV
Units Windskm=mV
Units Rain_mm=mm
Units BP_mbar=mbar
Units SlrW=W/m^2
Units SlrkJ=kJ/m^2

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,10,Min,10)
Average(1,Windr,IEEE4,False)
Average(1,Temp,IEEE4,False)
Maximum(1,Temp,IEEE4,False,True)
Minimum(1,Temp,IEEE4,False,True)
Average(1,Vocht,IEEE4,False)
Maximum(1,Vocht,IEEE4,False,True)
Minimum(1,Vocht,IEEE4,False,True)
Average(1,Windskm,IEEE4,False)
Maximum(1,Windskm,IEEE4,False,True)
Maximum(1,Windskn,IEEE4,False,True)
Average(1,SlrW,IEEE4,False)
Average(1,Windskn,IEEE4,False)
Average(1,Beaufort,IEEE4,False)
Maximum(1,Beaufort,IEEE4,False,True)
Sample(1,BP_mbar,IEEE4)
EndTable

DataTable(Table2,True,-1)
DataInterval(0,1,Min,10)
Minimum(1,BattV,FP2,False,False)
Sample(1,BP_mbar,IEEE4)
Sample(1,Windr,IEEE4)
Sample(1,SlrW,IEEE4)
Sample(1,Windskn,IEEE4)
Sample(1,Vocht,IEEE4)
Sample(1,Temp,IEEE4)
EndTable

DataTable(Table3,True,-1)
DataInterval(0,1,sec,10)
Sample(1,BP_mbar,IEEE4)
Sample(1,Windr,IEEE4)
Sample(1,Temp,IEEE4)
Sample(1,SlrW,IEEE4)
Sample(1,Windskn,IEEE4)
Sample(1,Windskm,IEEE4)
Sample(1,Beaufort,IEEE4)
Sample(1,Tot24,IEEE4)
Sample(1,Vocht,IEEE4)
EndTable

'Main Program
BeginProg
Scan(1,Sec,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
'Generic 4-20 mA Input measurement Windr
VoltDiff(Windr,1,mV2500,2,True,0,_50Hz,0.18,-89.1)
'Generic 4-20 mA Input measurement Temp
VoltDiff(Temp,1,mV2500,3,True,0,_50Hz,0.05,-65)
'Generic 4-20 mA Input measurement Vocht
VoltDiff(Vocht,1,mV2500,4,True,0,_50Hz,0.05,-25)
'Generic 4-20 mA Input measurement Windskm
VoltDiff(Windskm,1,mV2500,1,True,0,_50Hz,0.081035,-39.9875)
'Generic Tipping Bucket Rain Gauge measurement Rain_mm
PulseCount(Rain_mm,1,1,2,0,0.2,0)
'PTB101B Barometric Pressure Sensor (CSL) measurement BP_mbar
PortSet(1,1)
VoltSe(BP_mbar,1,mV2500,11,1,0,_50Hz,0.184,600)
BP_mbar=BP_mbar*1
'CM3 Pyranometer (CSL) measurements SlrkJ and SlrW
VoltDiff(SlrW,1,mV250,7,True,0,_50Hz,1,0)
If SlrW<0 Then SlrW=0
SlrkJ=SlrW*0.04330879
SlrW=SlrW*43.30879
'24 hour running total calculation Tot24
Tot24=Tot24+Rain_mm
If IfTime(24,1440,Min) Then Tot24=0
'User Entered Calculation
Windr = Windr + 200
If Windr > 360 Then Windr = Windr - 360
If Windr < 0 Then Windr = Windr + 360
If Windr>=360 Then Windr=0
'User Entered Calculation
Windskn=(Windskm/1.852)
'User Entered Calculation
If Windskm<1 Then
'User Entered Calculation
Beaufort=0
'User Entered Calculation
ElseIf Windskm<6 Then
'User Entered Calculation
Beaufort=1
'User Entered Calculation
ElseIf Windskm<12 Then
'User Entered Calculation
Beaufort=2
'User Entered Calculation
ElseIf Windskm<20 Then
'User Entered Calculation
Beaufort=3
'User Entered Calculation
ElseIf Windskm<29 Then
'User Entered Calculation
Beaufort=4
'User Entered Calculation
ElseIf Windskm<39 Then
'User Entered Calculation
Beaufort=5
'User Entered Calculation
ElseIf Windskm<50 Then
'User Entered Calculation
Beaufort=6
'User Entered Calculation
ElseIf Windskm<62 Then
'User Entered Calculation
Beaufort=7
'User Entered Calculation
ElseIf Windskm<75 Then
'User Entered Calculation
Beaufort=8
'User Entered Calculation
ElseIf Windskm<89 Then
'User Entered Calculation
Beaufort=9
'User Entered Calculation
ElseIf Windskm<103 Then
'User Entered Calculation
Beaufort=10
'User Entered Calculation
ElseIf Windskm<117 Then
'User Entered Calculation
Beaufort=11
'User Entered Calculation
ElseIf Windskm>117 Then
'User Entered Calculation
Beaufort=12
'User Entered Calculation
EndIf
'Call Data Tables and Store Data
CallTable(Table1)
CallTable(Table2)
CallTable(Table3)
NextScan
EndProg


IslandMan Jan 26, 2011 02:20 PM

Add:
Public Windroos as String

If Windr > 315 and Windr < 45 then
Windroos = "N"
ElseIf Windr > 45 and Windr < 135 then
Windroos = "E"
ElseIf Windr > 135 and Windr < 225 then
Windroos = "S"
ElseIf Windr > 225 and Windr < 315 then
Windroos = "W"
Endif


Mavada Jan 26, 2011 03:20 PM

it works, thank you very much!!!


IslandMan Jan 26, 2011 03:51 PM

You can fine tune it to more compass directions by modifying the degree variance and adding more statements to get N, NNE, NE, ENE and so on.

http://en.wikipedia.org/wiki/File:Brosen_windrose.svg

* Last updated by: IslandMan on 1/26/2011 @ 8:52 AM *


Mavada Jan 26, 2011 04:09 PM

but how do i get the 10 min. average in N E S W?

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,10,Min,10)
Average(1,Windr,IEEE4,False)
Average(1,Temp,IEEE4,False)
Maximum(1,Temp,IEEE4,False,True)
Minimum(1,Temp,IEEE4,False,True)
Average(1,Vocht,IEEE4,False)
Maximum(1,Vocht,IEEE4,False,True)
Minimum(1,Vocht,IEEE4,False,True)
Average(1,Windskm,IEEE4,False)
Maximum(1,Windskm,IEEE4,False,True)
Maximum(1,Windskn,IEEE4,False,True)
Average(1,SlrW,IEEE4,False)
Average(1,Windskn,IEEE4,False)
Average(1,Beaufort,IEEE4,False)
Maximum(1,Beaufort,IEEE4,False,True)
Average(1,Windroos,String,False)
Sample(1,BP_mbar,IEEE4)
EndTable

Like this wont work...

* Last updated by: Mavada on 1/26/2011 @ 9:09 AM *


IslandMan Jan 27, 2011 02:23 AM

Let me make some corrections to your basic program then we can address the storage of the wind text. I need a little time :-)

Can you identify these variables a little better for me?
Public Vocht ??
Public Windskm Wind Speed in kph?
Public Windskn Wind Speed in Knots?

* Last updated by: IslandMan on 1/26/2011 @ 7:27 PM *


Mavada Jan 27, 2011 07:19 AM

Public Vocht ??= humidity
Public Windskm Wind Speed in kph?yes
Public Windskn Wind Speed in Knots?yes


IslandMan Jan 27, 2011 11:44 AM

Try this program. I've added a running average wind direction over a 10 minute period so the sample in the 10 minute table will grab the 10 minute "average" Windroos. I also changed Table1 to correctly average the wind direction with the WindVector instruction and added a few labels. These will show up in your data files and make them much easier to interpret. I also fixed your units instructions. I assumed that Temp was in DegC. I would suggest you not store the 1 second samples in Table3. The logger memory will fill up in 1 day and 4 hours. If you leave that table out, the logger will store 120 days of 10 minute and 1 minute data. I hope this gives you some examples and ideas.

'CR1000
'Created by Short Cut (2.8)

'define all angles in degrees not radians
AngleDegrees

'Declare Variables and Units
Public BattV
Public Windr
Public Temp
Public Vocht
Public Windskm
Public Rain_mm
Public BP_mbar
Public SlrW
Public SlrkJ
Public Tot24
Public Windskn
Public Beaufort
Public Windroos As String

Public SinWindr
Public CosWindr
Public AvgSinWindr
Public AvgCosWindr
Public AvgWindr

Units BattV=Volts
Units Windr=Deg
Units Temp=DegC
Units Vocht=%
Units Windskm=kph
Units Windskn=kts
Units Rain_mm=mm
Units BP_mbar=mbar
Units SlrW=W/m^2
Units SlrkJ=kJ/m^2

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,10,Min,10)
WindVector (1,Windskm,Windr,FP2,False,0,0,1)
FieldNames ("Windskm,Windr")
Sample(1,Windroos,String)
FieldNames ("Windroos")
Maximum(1,Windskm,FP2,False,True)
FieldNames ("MaxWindskm")
Average(1,Temp,FP2,False)
FieldNames ("Temp")
Maximum(1,Temp,FP2,False,True)
FieldNames ("MaxTemp")
Minimum(1,Temp,FP2,False,True)
FieldNames ("MinTemp")
Average(1,Vocht,FP2,False)
FieldNames ("Vocht")
Maximum(1,Vocht,FP2,False,True)
FieldNames ("MaxVocht")
Minimum(1,Vocht,FP2,False,True)
FieldNames ("MinVocht")
Average(1,SlrW,FP2,False)
FieldNames ("SlrW")
Average(1,Windskn,FP2,False)
FieldNames ("Windskn")
Average(1,Beaufort,FP2,False)
FieldNames ("Beaufort")
Maximum(1,Beaufort,FP2,False,True)
FieldNames ("MaxBeaufort")
Sample(1,BP_mbar,FP2)
FieldNames ("BaroP")
EndTable

DataTable(Table2,True,-1)
DataInterval(0,1,Min,10)
Minimum(1,BattV,FP2,False,False)
Sample(1,BP_mbar,FP2)
Sample(1,Windr,FP2)
Sample(1,SlrW,FP2)
Sample(1,Windskn,FP2)
Sample(1,Vocht,FP2)
Sample(1,Temp,FP2)
EndTable

'DataTable(Table3,True,-1)
'DataInterval(0,1,sec,10)
'Sample(1,BP_mbar,FP2)
'Sample(1,Windr,FP2)
'Sample(1,Temp,FP2)
'Sample(1,SlrW,FP2)
'Sample(1,Windskn,FP2)
'Sample(1,Windskm,FP2)
'Sample(1,Beaufort,FP2)
'Sample(1,Tot24,FP2)
'Sample(1,Vocht,FP2)
'EndTable

'Main Program
BeginProg
Scan(1,Sec,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
'Generic 4-20 mA Input measurement Windr
VoltDiff(Windr,1,mV2500,2,True,0,_50Hz,0.18,-89.1)
'Generic 4-20 mA Input measurement Temp
VoltDiff(Temp,1,mV2500,3,True,0,_50Hz,0.05,-65)
'Generic 4-20 mA Input measurement Vocht
VoltDiff(Vocht,1,mV2500,4,True,0,_50Hz,0.05,-25)
'Generic 4-20 mA Input measurement Windskm
VoltDiff(Windskm,1,mV2500,1,True,0,_50Hz,0.081035,-39.9875)
'Generic Tipping Bucket Rain Gauge measurement Rain_mm
PulseCount(Rain_mm,1,1,2,0,0.2,0)
'PTB101B Barometric Pressure Sensor (CSL) measurement BP_mbar
PortSet(1,1)
VoltSe(BP_mbar,1,mV2500,11,1,0,_50Hz,0.184,600)
BP_mbar=BP_mbar*1
'CM3 Pyranometer (CSL) measurements SlrkJ and SlrW
VoltDiff(SlrW,1,mV250,7,True,0,_50Hz,1,0)
If SlrW<0 Then SlrW=0
SlrkJ=SlrW*0.04330879
SlrW=SlrW*43.30879

'24 hour running total calculation Tot24
Tot24=Tot24+Rain_mm
If IfTime(24,1440,Min) Then Tot24=0

'User Entered Calculation
Windr = Windr + 200
If Windr > 360 Then Windr = Windr - 360
If Windr < 0 Then Windr = Windr + 360
If Windr>=360 Then Windr=0

'Calculate 10 Minute Running average for Wind Direction
SinWindr = SIN(Windr)
CosWindr = COS(Windr)
AvgRun (AvgSinWindr,1,SinWindr,600)
AvgRun (AvgCosWindr,1,CosWindr,600)
AvgWindr = ATN(AvgSinWindr/AvgCosWindr)
If AvgCosWindr < 0 Then
AvgWindr = 180 + AvgWindr
ElseIf AvgSinWindr < 0 Then
AvgWindr = 360 + AvgWindr
EndIf

If AvgWindr > 315 AND AvgWindr < 45 Then
Windroos = "N"
ElseIf AvgWindr > 45 AND AvgWindr < 135 Then
Windroos = "E"
ElseIf AvgWindr > 135 AND AvgWindr < 225 Then
Windroos = "S"
ElseIf AvgWindr > 225 AND AvgWindr < 315 Then
Windroos = "W"
EndIf

'User Entered Calculation
Windskn=(Windskm/1.852)

'User Entered Calculation
If Windskm<1 Then
'User Entered Calculation
Beaufort=0
'User Entered Calculation
ElseIf Windskm<6 Then
'User Entered Calculation
Beaufort=1
'User Entered Calculation
ElseIf Windskm<12 Then
'User Entered Calculation
Beaufort=2
'User Entered Calculation
ElseIf Windskm<20 Then
'User Entered Calculation
Beaufort=3
'User Entered Calculation
ElseIf Windskm<29 Then
'User Entered Calculation
Beaufort=4
'User Entered Calculation
ElseIf Windskm<39 Then
'User Entered Calculation
Beaufort=5
'User Entered Calculation
ElseIf Windskm<50 Then
'User Entered Calculation
Beaufort=6
'User Entered Calculation
ElseIf Windskm<62 Then
'User Entered Calculation
Beaufort=7
'User Entered Calculation
ElseIf Windskm<75 Then
'User Entered Calculation
Beaufort=8
'User Entered Calculation
ElseIf Windskm<89 Then
'User Entered Calculation
Beaufort=9
'User Entered Calculation
ElseIf Windskm<103 Then
'User Entered Calculation
Beaufort=10
'User Entered Calculation
ElseIf Windskm<117 Then
'User Entered Calculation
Beaufort=11
'User Entered Calculation
ElseIf Windskm>117 Then
'User Entered Calculation
Beaufort=12
'User Entered Calculation
EndIf
'Call Data Tables and Store Data
CallTable(Table1)
CallTable(Table2)
'CallTable(Table3)
NextScan
EndProg


Mavada Jan 27, 2011 01:51 PM

Great you spend some time on this programm, very nice!!!
When i dont store the 1 second data, then it isnt possible to show the 1 sec data in my rtmc screen i think...

Also i would like to reset the rainfall value for the day.
I dont know how i can automatically reset these values at let say on 20.00 every day and amke a report for that day with these data. Maybe that is possible with some other programm in Loggernet...
I think i will have that for maybe all my data.. Is that possible to?

I will have a look on it asap.

Again thank you so very much!


Mavada Jan 27, 2011 06:46 PM

it works perfect.
Is there a way to round the beaufort value in the programm?
Because now the avg beaufort is for example 3.7 instead of 4


IslandMan Jan 27, 2011 09:30 PM

"When i dont store the 1 second data, then it isnt possible to show the 1 sec data in my rtmc screen i think..."

Assuming you have a direct connection from the PC to the Data logger, In the Setup Screen under Data Files, include the Public table for collection then point to the public table instead of the 1 second file in RTMC. Modify the Schedule to collect the data once per second.

"Also i would like to reset the rainfall value for the day."
The rainfall is being totaled manually in the program and is reset every day at 24 minutes past midnight.
You don't store it anywhere though, is this just for RTMC?

'24 hour running total calculation Tot24
Tot24=Tot24+Rain_mm
If IfTime(24,1440,Min) Then Tot24=0

You could add either of these to the 10 minute table to sample the total rainfall for that 10 minute period.
Sample(1,Tot24,FP2)
or
Totalize(1,Rain_mm,FP2,False)

"make a report for that day with these data."
SPLIT is the report generation software that's included in Loggernet.

* Last updated by: IslandMan on 1/27/2011 @ 2:31 PM *


Mavada Jan 27, 2011 10:33 PM

ok thanks.
Do you know how to round the Beaufort value in the programm?


Mavada Jan 28, 2011 12:11 PM

ive added some more detailed winddirections.
But when the avg winddirection is eg 53 degrees, it shows ONO instead of NO in table 1.
In public it works well....
Am i doing something wrong here?
i also added the n e s w to show in my public realtime values.


'define all angles in degrees not radians
AngleDegrees
'Declare Variables and Units
Public BattV
Public Windr
Public Temp
Public Vocht
Public Windskm
Public Rain_mm
Public BP_mbar
Public SlrW
Public SlrkJ
Public Tot24
Public Windskn
Public Beaufort
Public Windroos As String
Public SinWindr
Public CosWindr
Public AvgSinWindr
Public AvgCosWindr
Public AvgWindr
Units BattV=Volts
Units Windr=Deg
Units Temp=DegC
Units Vocht=%
Units Windskm=kph
Units Windskn=kts
Units Rain_mm=mm
Units BP_mbar=mbar
Units SlrW=W/m^2
Units SlrkJ=kJ/m^2
'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,10,Min,10)
WindVector (1,Windskm,Windr,IEEE4,False,0,0,1)
FieldNames ("Windskm,Windr")
Sample(1,Windroos,String)
FieldNames ("Windroos")
Maximum(1,Windskm,IEEE4,False,True)
FieldNames ("MaxWindskm")
Average(1,Temp,IEEE4,False)
FieldNames ("Temp")
Maximum(1,Temp,IEEE4,False,True)
FieldNames ("MaxTemp")
Minimum(1,Temp,IEEE4,False,True)
FieldNames ("MinTemp")
Average(1,Vocht,IEEE4,False)
FieldNames ("Vocht")
Maximum(1,Vocht,IEEE4,False,True)
FieldNames ("MaxVocht")
Minimum(1,Vocht,IEEE4,False,True)
FieldNames ("MinVocht")
Average(1,SlrW,IEEE4,False)
FieldNames ("SlrW")
Average(1,Windskn,IEEE4,False)
FieldNames ("Windskn")
Maximum(1,Windskn,IEEE4,False,True)
FieldNames ("MaxWindskn")
Average (1,Beaufort,IEEE4,False)
FieldNames ("Beaufort")
Maximum(1,Beaufort,IEEE4,False,True)
FieldNames ("MaxBeaufort")
Sample(1,BP_mbar,IEEE4)
FieldNames ("BaroP")
EndTable
DataTable(Table2,True,-1)
DataInterval(0,1,Min,10)
Minimum(1,BattV,IEEE4,False,False)
Sample(1,BP_mbar,IEEE4)
Sample(1,Windr,IEEE4)
Sample(1,SlrW,IEEE4)
Sample(1,Windskn,IEEE4)
Sample(1,Vocht,IEEE4)
Sample(1,Temp,IEEE4)
EndTable
'DataTable(Table3,True,-1)
'DataInterval(0,1,sec,10)
'Sample(1,BP_mbar,FP2)
'Sample(1,Windr,FP2)
'Sample(1,Temp,FP2)
'Sample(1,SlrW,FP2)
'Sample(1,Windskn,FP2)
'Sample(1,Windskm,FP2)
'Sample(1,Beaufort,FP2)
'Sample(1,Tot24,FP2)
'Sample(1,Vocht,FP2)
'EndTable
'Main Program
BeginProg
Scan(1,Sec,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
'Generic 4-20 mA Input measurement Windr
VoltDiff(Windr,1,mV2500,2,True,0,_50Hz,0.18,-89.1)
'Generic 4-20 mA Input measurement Temp
VoltDiff(Temp,1,mV2500,3,True,0,_50Hz,0.05,-65)
'Generic 4-20 mA Input measurement Vocht
VoltDiff(Vocht,1,mV2500,4,True,0,_50Hz,0.05,-25)
'Generic 4-20 mA Input measurement Windskm
VoltDiff(Windskm,1,mV2500,1,True,0,_50Hz,0.081035,-39.9875)
'Generic Tipping Bucket Rain Gauge measurement Rain_mm
PulseCount(Rain_mm,1,1,2,0,0.2,0)
'PTB101B Barometric Pressure Sensor (CSL) measurement BP_mbar
PortSet(1,1)
VoltSe(BP_mbar,1,mV2500,11,1,0,_50Hz,0.184,600)
BP_mbar=BP_mbar*1
'CM3 Pyranometer (CSL) measurements SlrkJ and SlrW
VoltDiff(SlrW,1,mV250,7,True,0,_50Hz,1,0)
If SlrW<0 Then SlrW=0
SlrkJ=SlrW*0.04330879
SlrW=SlrW*43.30879
'24 hour running total calculation Tot24
Tot24=Tot24+Rain_mm
If IfTime(24,1440,Min) Then Tot24=0
'User Entered Calculation
Windr = Windr + 200
If Windr > 360 Then Windr = Windr - 360
If Windr < 0 Then Windr = Windr + 360
If Windr>=360 Then Windr=0
'Calculate 10 Minute Running average for Wind Direction
SinWindr = SIN(Windr)
CosWindr = COS(Windr)
AvgRun (AvgSinWindr,1,SinWindr,600)
AvgRun (AvgCosWindr,1,CosWindr,600)
AvgWindr = ATN(AvgSinWindr/AvgCosWindr)
If AvgCosWindr < 0 Then
AvgWindr = 180 + AvgWindr
ElseIf AvgSinWindr < 0 Then
AvgWindr = 360 + AvgWindr
EndIf

If AvgWindr <= 11.25 Then
Windroos = "N"
ElseIf AvgWindr < 33.25 Then
Windroos = "NNO"
ElseIf AvgWindr < 56.25 Then
Windroos = "NO"
ElseIf AvgWindr < 78.75 Then
Windroos = "ONO"
ElseIf AvgWindr < 101.25 Then
Windroos = "O"
ElseIf AvgWindr < 123.75 Then
Windroos = "OZO"
ElseIf AvgWindr < 146.25 Then
Windroos = "ZO"
ElseIf AvgWindr < 168.75 Then
Windroos = "ZZO"
ElseIf AvgWindr < 191.25 Then
Windroos = "Z"
ElseIf AvgWindr < 213.75 Then
Windroos = "ZZW"
ElseIf AvgWindr < 236.25 Then
Windroos = "ZW"
ElseIf AvgWindr < 258.75 Then
Windroos = "WZW"
ElseIf AvgWindr < 281.25 Then
Windroos = "W"
ElseIf AvgWindr < 303.75 Then
Windroos = "WNW"
ElseIf AvgWindr < 326.25 Then
Windroos = "NW"
ElseIf AvgWindr < 348.75 Then
Windroos = "NNW"
EndIf
'User Entered Calculation
If Windr <= 11.25 Then
Windroos = "N"
ElseIf Windr <= 33.25 Then
Windroos = "NNO"
ElseIf Windr <= 56.25 Then
Windroos = "NO"
ElseIf Windr <= 78.75 Then
Windroos = "ONO"
ElseIf Windr <= 101.25 Then
Windroos = "O"
ElseIf Windr <= 123.75 Then
Windroos = "OZO"
ElseIf Windr <= 146.25 Then
Windroos = "ZO"
ElseIf Windr <= 168.75 Then
Windroos = "ZZO"
ElseIf Windr <= 191.25 Then
Windroos = "Z"
ElseIf Windr <= 213.75 Then
Windroos = "ZZW"
ElseIf Windr <= 236.25 Then
Windroos = "ZW"
ElseIf Windr <= 258.75 Then
Windroos = "WZW"
ElseIf Windr <= 281.25 Then
Windroos = "W"
ElseIf Windr <= 303.75 Then
Windroos = "WNW"
ElseIf Windr <= 326.25 Then
Windroos = "NW"
ElseIf Windr <= 348.75 Then
Windroos = "NNW"
EndIf


'User Entered Calculation
Windskn=(Windskm/1.852)
'User Entered Calculation
If Windskm<1 Then
'User Entered Calculation
Beaufort=0
'User Entered Calculation
ElseIf Windskm<6 Then
'User Entered Calculation
Beaufort=1
'User Entered Calculation
ElseIf Windskm<12 Then
'User Entered Calculation
Beaufort=2
'User Entered Calculation
ElseIf Windskm<20 Then
'User Entered Calculation
Beaufort=3
'User Entered Calculation
ElseIf Windskm<29 Then
'User Entered Calculation
Beaufort=4
'User Entered Calculation
ElseIf Windskm<39 Then
'User Entered Calculation
Beaufort=5
'User Entered Calculation
ElseIf Windskm<50 Then
'User Entered Calculation
Beaufort=6
'User Entered Calculation
ElseIf Windskm<62 Then
'User Entered Calculation
Beaufort=7
'User Entered Calculation
ElseIf Windskm<75 Then
'User Entered Calculation
Beaufort=8
'User Entered Calculation
ElseIf Windskm<89 Then
'User Entered Calculation
Beaufort=9
'User Entered Calculation
ElseIf Windskm<103 Then
'User Entered Calculation
Beaufort=10
'User Entered Calculation
ElseIf Windskm<117 Then
'User Entered Calculation
Beaufort=11
'User Entered Calculation
ElseIf Windskm>117 Then
'User Entered Calculation
Beaufort=12
'User Entered Calculation
EndIf
'Call Data Tables and Store Data
CallTable(Table1)
CallTable(Table2)
'CallTable(Table3)
NextScan
EndProg

* Last updated by: Mavada on 1/28/2011 @ 5:54 AM *


Mavada Jan 28, 2011 01:29 PM

Sometimes i see the value in table1 change for 1 second.


IslandMan Jan 28, 2011 01:33 PM

You didn't follow the example I gave you.
You need to select a RANGE not just a fixed value.

If AvgWindr > 315 AND AvgWindr < 45 Then
Windroos = "N"
ElseIf AvgWindr > 45 AND AvgWindr < 135 Then
Windroos = "E"
ElseIf AvgWindr > 135 AND AvgWindr < 225 Then
Windroos = "S"
ElseIf AvgWindr > 225 AND AvgWindr < 315 Then
Windroos = "W"
EndIf


Mavada Jan 28, 2011 06:30 PM

ok thank you.
What is exactly the purpose of a windvector?
ive read it has something to do with speed and direction of the wind, but what is the relation between eachother?

is that why the degrees sometimes doesnt match with the programm in crbasic? eg 53degrees should be no instead of nno...(ive add some winddirection so its a bit more accurate.


IslandMan Jan 28, 2011 06:39 PM

you cannot do a linear average of wind direction because it's a circle, not a line. The Windvector instruction averages Wind direction correctly.

53 Degrees is a little more than North East, which is 45 degrees. I don't understand your problem.

look at this:
http://www.bostonoutrigger.com/images/compass_rose.gif


Mavada Jan 28, 2011 07:02 PM

because my current avg winddirection is 70.6 degrees, with the instruction below it should use ONO, but it shows NO.

Has it to do with eg winddirection between 315 and 45 degrees, thats average 315 + 45 = 360 / 2 =180 degrees, which is Z (180) and not correct.

If AvgWindr > 348.75 AND AvgWindr < 11.25 Then
Windroos = "N"
ElseIf AvgWindr > 11.25 AND AvgWindr < 33.25 Then
Windroos = "NNO"
ElseIf AvgWindr > 33.25 AND AvgWindr < 56.25 Then
Windroos = "NO"
ElseIf AvgWindr > 56.25 AND AvgWindr < 78.75 Then
Windroos = "ONO"
ElseIf AvgWindr > 78.75 AND AvgWindr < 101.25 Then
Windroos = "O"
ElseIf AvgWindr > 101.25 AND AvgWindr < 123.75 Then
Windroos = "OZO"
ElseIf AvgWindr > 123.75 AND AvgWindr < 146.25 Then
Windroos = "ZO"
ElseIf AvgWindr > 146.25 AND AvgWindr < 168.75 Then
Windroos = "ZZO"
ElseIf AvgWindr > 168.75 AND AvgWindr < 191.25 Then
Windroos = "Z"
ElseIf AvgWindr > 191.25 AND AvgWindr < 213.75 Then
Windroos = "ZZW"
ElseIf AvgWindr > 213.75 AND AvgWindr < 236.25 Then
Windroos = "ZW"
ElseIf AvgWindr > 236.25 AND AvgWindr < 258.75 Then
Windroos = "WZW"
ElseIf AvgWindr > 258.75 AND AvgWindr < 281.25 Then
Windroos = "W"
ElseIf AvgWindr > 281.25 AND AvgWindr < 303.75 Then
Windroos = "WNW"
ElseIf AvgWindr > 303.75 AND AvgWindr < 326.25 Then
Windroos = "NW"
ElseIf AvgWindr > 326.25 AND AvgWindr < 348.75 Then
Windroos = "NNW"
EndIf


IslandMan Jan 30, 2011 11:20 AM

An noted earlier, you cannot sum the wind direction values and divide by the number of samples as you show, you arrive at an incorrect average due do to the circular nature of wind direction. The programming below is what is required to calculate wind direction and in essence it's what the WindVector instruction does.

'Calculate 10 Minute Running average for Wind Direction
SinWindr = SIN(Windr)
CosWindr = COS(Windr)
AvgRun (AvgSinWindr,1,SinWindr,600)
AvgRun (AvgCosWindr,1,CosWindr,600)
AvgWindr = ATN(AvgSinWindr/AvgCosWindr)
If AvgCosWindr < 0 Then
AvgWindr = 180 + AvgWindr
ElseIf AvgSinWindr < 0 Then
AvgWindr = 360 + AvgWindr
EndIf

With regard to the programming for the text names for wind direction, sometimes it's best to isolate the problem by creating a small program and manually entering the data to test the program. What I have shown below is such a test where I have found the issue around north and corrected it.
You can manually enter the AvgWindr in the numeric display in the connect screen or through a keypad to test all the points.

'CR1000 Series Datalogger

'Declare Public Variables
Public AvgWindr
Public Windroos As String * 3

'Main Program
BeginProg

Scan (1,Sec,0,0)

If AvgWindr >= 348.75 AND AvgWindr <= 359.9 OR AvgWindr >= 0 AND AvgWindr <= 11.25 Then
Windroos = "N"
ElseIf AvgWindr > 11.25 AND AvgWindr < 33.25 Then
Windroos = "NNE"
ElseIf AvgWindr > 33.25 AND AvgWindr < 56.25 Then
Windroos = "NE"
ElseIf AvgWindr > 56.25 AND AvgWindr < 78.75 Then
Windroos = "ENE"
ElseIf AvgWindr > 78.75 AND AvgWindr < 101.25 Then
Windroos = "E"
ElseIf AvgWindr > 101.25 AND AvgWindr < 123.75 Then
Windroos = "ESE"
ElseIf AvgWindr > 123.75 AND AvgWindr < 146.25 Then
Windroos = "SE"
ElseIf AvgWindr > 146.25 AND AvgWindr < 168.75 Then
Windroos = "SSE"
ElseIf AvgWindr > 168.75 AND AvgWindr < 191.25 Then
Windroos = "S"
ElseIf AvgWindr > 191.25 AND AvgWindr < 213.75 Then
Windroos = "SSW"
ElseIf AvgWindr > 213.75 AND AvgWindr < 236.25 Then
Windroos = "SW"
ElseIf AvgWindr > 236.25 AND AvgWindr < 258.75 Then
Windroos = "WSW"
ElseIf AvgWindr > 258.75 AND AvgWindr < 281.25 Then
Windroos = "W"
ElseIf AvgWindr > 281.25 AND AvgWindr < 303.75 Then
Windroos = "WNW"
ElseIf AvgWindr > 303.75 AND AvgWindr < 326.25 Then
Windroos = "NW"
ElseIf AvgWindr >= 326.25 AND AvgWindr <= 348.75 Then
Windroos = "NNW"
EndIf
NextScan
EndProg


ssanhuezat Oct 4, 2011 03:57 PM

I can put this instruction for a CR200 data logger??


IslandMan Oct 4, 2011 08:56 PM

Cut and paste it into the CR200 editor and see. I'm not sure and I don't have one here to test it on.


Dana Oct 4, 2011 10:14 PM

CR200 dataloggers do not support data types, so there is no support for Strings. Your NESW notation will not work.

Dana W.


IslandMan Oct 5, 2011 09:42 AM

So much for that idea :-)

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