Page 1 of 1
Cloud base information
Posted: Wed 12 May 2010 8:09 pm
by Palmyweather
I created a javaScript for my website that would detect fog or low cloud based upon the data from humidity and the cloud base figures. After prototyping it and putting it into practice, I found that that cloud base web tag actually has the unit built in. E.g. 1000 m. This completely throws my script out as I cannot use letters in the way I compiled my IF statement.
Does anyone know of a way I can remove the M from the cloud base web tag in JavaScript? Or is there another tag I can use to gain the cloud base information without the unit of measure?
I think that this tag is the only one which has the unit of measure built into the figures. All the others that I have used have their own separate unit tags.
I'm also in the process of developing (hopefully) one which will detect frost and provide a frost alert on my site. Just need to find time to do it.
Matt.
Re: Cloud base information
Posted: Wed 12 May 2010 9:08 pm
by Synewave
Hi Matt,
Co-incidentaly, I've also been trying to use the cloudbase variable today to see if I could describe the sky conditions i.e. overcast, clear skies etc.
I initially had the same problem with the measurement being included.
In my .js file, I added the following. It reads from my 'extras' realtime file that gets processed and FTP'd by Cumulus.
var realtime_location_extras="realtimeextras.txt";
if (realdataextras.indexOf(realtime_location_extras) == -1 ) {
var rawdataextras=realdataextras.split(" ");
var skycondition = rawdataextras[0];
if (skycondition < 1000) {
skycondition_text = "overcast";
}
if (skycondition >= 1000) {
skycondition_text = "scattered clouds";
}
if (skycondition >= 1201) {
skycondition_text = "clear skies";
}
$("#currentskycondition").html(skycondition_text);
}
It all works fine (as far as getting the cloudbase value without the measurement), but I don't think my values currently really reflect the sky conditions. I never thought it would be this easy!
But, anyway, the code to read the cloudbase without the 'm' works fine!
Hope this helps,
Re: Cloud base information
Posted: Wed 12 May 2010 9:14 pm
by Palmyweather
My script was going to be a little more simple.
<script type="text/javascript">
var humidity = 74;
var cloudbase = 603 m;
if ((humidity>=97) && (cloudbase<=75))
document.write('<div style="width:100%;" class="warnings"><img src="weather/warning/warning.png" width="10" height="15" align="top" border="0" /> <b>WEATHER WARNING:</b> <i>Fog or Low Cloud</i> has been detected.</div>');
else
document.write("");
</script>
I was going to use this means as the page it is on is being prosessed by the program anyway before being uploaded. Therefore all I needed to do was add the web tags in without needing to retreave any other data.
Re: Cloud base information
Posted: Wed 12 May 2010 10:59 pm
by beteljuice
Code: Select all
...
var cloudbase = <#cloudbase>.replace('m', '') *1; // turn into a 'real' number
...
Fog is actually very difficult to predict, especially when your hygro won't go to 100% !
... and cloudbase is the lowest height at which a cloud may form - there are other conditions involved before a cloud may / may not form.
Re: Cloud base information
Posted: Thu 13 May 2010 7:04 am
by steve
An alternative if using javascript to do it, would be to calculate it yourself. The formula is very simple:
cloudbase = ((temp-dewpoint) / 4.4) * 1000
cloudbase in ft, temps in F.
You could then go on to tweak the formula...
To add to beteljuice's caveat, this theoretical value only applies to the formation of one type of cloud - cumulus.