Page 1 of 2

Possible problem with wind direction range web tags

Posted: Fri 13 Jan 2012 7:04 pm
by mcrossley
Steve

I just noticed my wind gauge, over 'longer than' the last 10 minutes the wind speed has been varying between zero and not a lot, but the average is non-zero. The wind direction has been constant at 135 degrees. But the range from/to10 tags are reading 310-320, which is 180 degrees out?

From the realtime file:
"BearingRangeFrom10":"310","BearingRangeTo10":"320"
Capture.PNG

Re: Possible problem with wind direction range web tags

Posted: Fri 13 Jan 2012 7:38 pm
by steve
I suspect it's connected with the zero wind speeds, which of course never happens here. I was outside just now, thinking how amazingly calm and quiet it was, and it's actually F2.

The contents of the <#wspddata> and <#wdirdata> (and <#nextwindindex>) tags would be useful, and whether or not you have 'use bearing zero when calm' set. I don't know when I'll get chance to look at this, though.

Edit: But I see you're now completely becalmed as far as the average goes, so it'll need to be when it manifests itself again, obviously.

Re: Possible problem with wind direction range web tags

Posted: Fri 13 Jan 2012 7:42 pm
by steve
steve wrote:whether or not you have 'use bearing zero when calm' set
Actually, I think you probably have, and I think this is the reason for the problem. I'll have to have a think about what to do about that.

Re: Possible problem with wind direction range web tags

Posted: Fri 13 Jan 2012 8:26 pm
by steve
I've been thinking about this some more, and I think 'use bearing zero when calm' is a red herring, because the 'range' code uses the 'raw' bearing. But it must be something to do with what happens when it's calm.

Re: Possible problem with wind direction range web tags

Posted: Fri 13 Jan 2012 11:02 pm
by mcrossley
steve wrote:Actually, I think you probably have
Correct, I did not capture the wind arrays at the time -if I notice it again I will.

Re: Possible problem with wind direction range web tags

Posted: Fri 13 Jan 2012 11:04 pm
by steve
I'll try to do some experimenting when I get chance, with my WMR200, whose anemometer is sitting on a desk, so I can easily get zero wind speeds from it.

Re: Possible problem with wind direction range web tags

Posted: Sat 14 Jan 2012 12:16 am
by beteljuice
BTW Mark - why does the compass gauge use N for calm ?

Re: Possible problem with wind direction range web tags

Posted: Sat 14 Jan 2012 9:50 am
by mcrossley
beteljuice wrote:BTW Mark - why does the compass gauge use N for calm ?
Well actually I use 000 for calm and 360 for N :lol: but calm is a problem to represent on a 0-360 gauge isn't it? The only other thing I can think of is to not draw the pointer at all?

Re: Possible problem with wind direction range web tags

Posted: Sat 14 Jan 2012 11:28 am
by gemini06720
mcrossley wrote:The only other thing I can think of is to not draw the pointer at all?
Mark, rather than completely removing the pointer (which I would not want), how about 'dimming' (or changing) the colour of the pointer? The pointer would still be pointing at 000° (or 360° depending how you look at it) and be either semi-transparent (if that is possible) or of a lighter colour.

Re: Possible problem with wind direction range web tags

Posted: Sat 14 Jan 2012 11:47 am
by beteljuice
Or perhaps truncate the pointer to quarter length (just prove there is data but it's lying :lol: )

Re. <#webtags>, I don't know which logic you presented to Steve in the end, but as far as I can see if a 0deg reading were given for calm that would simply increase the vector difference, it wouldn't give the magic 180deg shift with the correct vector difference ?

Re: Possible problem with wind direction range web tags

Posted: Sat 14 Jan 2012 11:54 am
by steve
I'll post my code later, then we can have a group debugging session :)

Re: Possible problem with wind direction range web tags

Posted: Sat 14 Jan 2012 12:18 pm
by beteljuice
Here's the beteljuice 'rough guide' :lol:

Javascript logic - a little psuedo code

Code: Select all


// ------- Variable Wind check -------------------------
/* from METAR coding
* if direction varies by 60 deg or more and speed greater than 6 knots,
* a Variable wind direction group is reported (eg. 180V240), otherwise omitted.
* If wind direction is variable and speed 6 knots or less, 
* replace wind direction with VRB followed by wind speed in knots.
*
* This emulates that to provide 'degFrom', 'degTo', and 'vectorSize' variables
*
* METAR wind degrees are rounded to nearest 10 - we work 'normal'
* I am assuming the last 10 min. although some dialogues suggest 2 min.
* 
* Also I can find no info on the ORDER of the 180V240 deg. ie. 60 deg clockwise or 300 deg anti-clockwise ?
* So I am assuming (and coded) to read 'clockwise' (ie. 1st figure could be larger than 2nd.)
* eg 330V030 would be 60 deg 'around' North, 150V240 would be 90 deg 'around' South.
* 
*/

/* Philosophy
*  Get last 10 mins worth of CURRENT wind direction degrees
*  Compare each with CURRENT AVG wind direction degrees to get a + / - 'offset'
*  add (absolutely) the max 'offsets' to get wind 'vector' size
*/
 
/* Prerequisites: - names are for easy reference / substitution
* 
* windDeg10 - an array containing the last 10 minutes of current / now wind DIRECTIONS in degrees
* windVarAvg - the CURRENT 10 minute average wind DIRECTION in degrees
*
* wind_kts_ave - could be any CURRENT AVERAGE SPEED unit, used (or maybe not) to give alternate output
*/

 
				windVar_temp_degDiff = new Array(); // new array to store deviation from CURRENT average
				windVarCount = windDeg10.length; 


				// step through 10min values, calculate the differences to CURRENT avg and populate a new array
				y = 0; // initialise windVar_temp_degDiff[] pointer
				for(x = 0; x < windVarCount; x++) { // go through 10min values
					// work out difference between 'then' current and 'now' 10 min average
// Cumulus, in common with some other softwares, returns 0 degrees if zero wind speed 
// if this is true for the 10min array then at this point you need to do a check and 'jump' to next 'x' to be safe
// if required - if(windDeg10[x] == 0) 'jump' check here
					degDiff_temp = windDeg10[x] - windVarAvg;

					if(degDiff_temp >= 180) {
						degDiff_temp = degDiff_temp -360;
					} else {
						if(degDiff_temp <= -180){
							degDiff_temp = degDiff_temp +360;
						}
					}

					windVar_temp_degDiff[y] = degDiff_temp;
					y++; // increment new array pointer
// if required - END 'jump' check

				} // END 10min step through, new Array windVar_temp_degDiff has been populated with difference to average
				
				// find (plus / minus) deviation extremes - arrayMax() and arrayMin() are 'invented' functions
				degHi = arrayMax(windVar_degDiff); // positive values, might NOT be initially, if the (wx) avg period has not been completed ;-)
				degLo = arrayMin(windVar_degDiff); // negative values, might NOT be initially, if the (wx) avg period has not been completed ;-)

				// Belts 'n' Braces - Lo must be lower or equal to avg, Hi must be higher or equal to avg
				if(degLo > 0) {degLo = 0;}
				if(degHi < 0) {degHi = 0;}

// so now we have the max +/- deviation with respect to CURRENT average direction 

				// Now workout max 'vector' size !!
				vectorSize = degHi + Math.abs(degLo);

// FINALLY - workout logical from > to values eg. 350 15 would be straddling North
// average SPEED check is optional, you may also decide eg. a vectorSize < 10 is irrelevant ? - upto you
				if(wind_kts_ave > 0) { // need to build output as [from to]
					degFrom = windVarAvg + degLo; 
					if(degFrom < 0){degFrom = 360 + degFrom;} 
					degTo = windVarAvg + degHi; // 
					if(degTo > 360){degTo=degTo-360;}
				}else{ // NORMAL - I choose to o/p ave, but it could be null or current
					// *** PUT ALTERNATIVE VALUES HERE !!! *************
				}// END if average SPEED 

// END Variable Wind

// So now you have degFrom, degTo, and vectorSize all in integer degrees available for 'output'

Re: Possible problem with wind direction range web tags

Posted: Sat 14 Jan 2012 12:21 pm
by steve
Yes, I've seen that, Mark posted his and yours in the enhancement request. 'My' code uses part of yours, part of Mark's, and a light sprinkling of my own. This is probably why there's a bug in it :lol:

Re: Possible problem with wind direction range web tags

Posted: Mon 16 Jan 2012 5:20 pm
by mcrossley
It's happening again, and there are zero wind speeds. Unfortunately I am still at work and cannot RDP in to the server until I get to the hotel and out from behind our corporate proxy server.

Re: Possible problem with wind direction range web tags

Posted: Mon 16 Jan 2012 6:13 pm
by steve
At least that confirms that zero wind speeds cause the problem. I haven't had chance to experiment yet.