WxSim Temperature Forecast Comparison Script

Ok, I just had my morning run and the logging part went fine the old way, but the display part did not. So, Pinto is right … as always and here’s what we have to do. These assume that properly named log files are in place.

For logging

forecast-compare-include.php?log - will log to forecast.log by default
forecast-compare-include.php?log&config=am - to log to forecastAM.log
forecast-compare-include.php?log&config=pm - to log to forecastPM.log

For display in your web page

include(“forecast-compare-include.php”); - will show forecast.log in the default English

$_REQUEST[‘config’] = ‘am’;
include(“forecast-compare-include.php”); - will show forecastAM.log

$_REQUEST[‘config’] = ‘pm’;
$_REQUEST[‘lang’] = ‘xx’; - optional language
include(“forecast-compare-include.php”); - will show forecastPM.log

Hopefully I have this right now and I’ll change the readme and test file later in the day. Thanks Pinto and sorry Jack. This is what happens when a non-programmer makes changes without fully testing, I should know better by now.

  • Jim

No need to be sorry Jim this is a great script and working bugs out is actually fun, plus slowly I learn a little bit more! So I have changed my page to your new script and wiped the log files. Ran the new ‘am’ script and it seems to have worked OK. I’ll run another forecast this afternoon for the pm and we’ll see what happens but this seems to be the answer so far!

Thanks for all your hard work!

Jack

Sorry Jack,
Was in a hurry, you are right,must be(like Jim says)

forecast-compare-include.php?log&config=am
forecast-compare-include.php?log&config=pm

Edit: now i did it again:copy & paste the same(wrong) code #-o
now it’s better

I have this working… as it was/is in the original package… using the test-fc.php page…

Could somebody post, exacly, what I need to do to get a page that displays a morning and afternoon comparison on the same page? I’ve used AutoIT to create a script that is scheduled, so I can update a log once a day… won’t be hard to run the same script twice a day… but I assume I have to change it a tad to create two forecast logs?

Anyhow, if somebody could post a ‘new’ test-fc.php page that containst two forecasts, as well as post how to generate them individually, I’d love to give this a try! Adding it to the templates will be a must, once I get it working… and I believe Ken said he is working on that too! Fantastic!!!

Thanks all!

Stuntman,

Glad it’s kind of working for you and sorry that I didn’t get a chance to update the readme yet. I have to work every Thursday and that’s today. For the logging you’d use:

forecast-compare-include.php?log&config=am - in one of your autoit scripts
forecast-compare-include.php?log&config=pm - and this in the other.

forecastAM.log and forecastPM.log must be on the server write enabled.

In your web page you’d have something like this

$_REQUEST[‘config’] = ‘am’;
include(“forecast-compare-include.php”);

$_REQUEST[‘config’] = ‘pm’;
include(“forecast-compare-include.php”);

Now since you already had it running and logging to forecast.log, you can replace one of the above with

forecast-compare-include.php?log - will default to logging to forecast.log

Then to display, replace either the am or pm above with

include(“forecast-compare-include.php”);

I’m kind of thinking I should have left the default option out of the equation, but it’s there now.

Let us know how it goes.

  • Jim

Wow… that really confused me! Not much of a web programmer I guess! Can you package one that has this all configured… an am/pm and a test-fc.php page that shows both? All I’d need to change is timezone… I’ve tried what you posted but I get either an error stating the config doesn’t exist or that it has already logged… neither of which should be the case as I do have the log files and it has never logged…

I’m sure I’m just missing something simple, but not being a coder, I don’t see it!

Thanks… and sorry to be a pain!

Stuntman,

I’ve just put a new readme.txt and test-fc.php in the .zip file along with a new language file that has a minor change to it. I’m hesitant to clutter up the .zip file with extraneous configs and logs because that will probably confuse things further.

Make two copies of forecast.log and name one forecastAM.log, the other forecastPM.log and upload those to the server. They will overwrite any old ones that you might have on there.

Then make two copies of fc-config.php and name one fc-configAM.php and the other fc-configPM.php. In fc-configAM.php change $fcstLog = “forecast.log”; to $fcstLog = “forecastAM.log”; and in fc-configPM.php do the same, but make it “forecastPM.log”.

Upload those then use the new code in test-fc.php to put in your web page and all should work.

Let’s see how that goes.

  • Jim

Stuntman,

I changed my mind and added those files to the .zip, and test-fc.php (or the code in it) should work along with them.

  • Jim

Hi Jim,

One minor issue I’m trying to overcome, the ole validation problem. On your regular page your site validates, on the sample in the package you get the same errors I’m getting. It appears calling the script in the page twice screws things up. I’ve actually found a work around which validates but it involves uploading the forecast-compare-include script just with a different name, but I think this will be confusing to others as it changes the log call too! So anyway what is your trick on your page that allows it to validate?

Thanks,

Jack

Jack,

I’m not sure, I’ll have to take a look. I’m having some different problems which may be what is happening to Stuntman that I have to figure out too. I tried to add two more forecasts, and am now having trouble getting any other than the very first to display. I suspect all of this may be related. Might need a little sleep first, but we’ll get it.

Thanks. - Jim

Hi Jim

Im not sure the script is working correct - it seems that WXSIM (SL) and Wunderground (WU) MAX and MIN are in the wrong place.

MAX should be MIN and vice versa.

Would you take a look here and see if you agree with me:

http://www.silkeborg-vejret.dk/english/sammenlign.php

Thanks

Best regards,

Henrik

Henrik mine is the correct way round, however mine are all positive numbers so I wonder if the script is not correc tly checking the negative values?

On a slightly different thought, I have asked Brian (in suggestions) for a new %mintempovernight% tag which is from 6pm to 6am (the current one if for folks with 9am reset which runs from 9pm to 9am) so we can use it in the compare script. The reason for this is that I do have overall min temps which happen in daytime especially in winter and that’s not a fair comparison with a forecast which is predicting an overnight low…

Stuart

Henrik,

I just looked at your data for today and it appears that the WU highs/lows are correct, but the WxSim ones are backwards. Is that what you’re seeing? Is it possible that you’re running this script before the new plaintext.txt has been uploaded to the server? If that were the case, the first item found from plaintext-parser would be a low and things would be out of sync. The differences from actual seem to be calculated correctly with the negative temps, so that is good.

That makes me realize something though, right now this is a “daytime forecast only” script.

Thanks. - Jim

Hi Jim

Thanks for your reply.

You are right - its my WXSIM that are backwards.

I upload plaintext.txt 6 times a day - and I have setup a cronjob to run the compare script every night at 23.11 (1 hour after last upload of plaintext.txt)

I upload plaintext.txt at 04,07,10,13,16,19 and 22 hour.

Am I doing something wrong?

Best regards,

Henrik

Jack,

I figured out what this problem is, we can’t use the selectors more than once on a page, so you’ll have to turn them off in one of your configs. That’s ok because both of the scripts will react to the selector values anyway. Another possibility might be to put each of them in a different iframe. I haven’t tried that, but then they should be discreet I would think. The fixed size of the iframe might be a problem though unless you want scroll bars to show up.

  • Jim

Hi Jim,

Ok, I might use my “other” solution which is to rename the forecast compare include and then I just changed the id on the selectors. I’ll have to try your solution too. Thanks.

Jack

Henrik,

That won’t work because this script will only look at the current forecasts that the two systems are showing at that partucular time. You should set this logging to happen shortly after one of your plaintext.txt files has been uploaded. You can, however, set up to track more than one of these forecasts and we’re getting the bugs worked out of that. I hope to have an update out soon after I review the changes that I’ve made which are mostly documentation.

  • Jim

Hi Henrik,
May I say, it is not correct to do so.
First thing you have to know is: When is the forecast made for your location by WU.
Then you know at what time you have to run WXSIM and after that make the log.
Otherwise you are comparing a forecast made at say 01:00 with one made at 13:00
You have to make sure the two are made around the same time, else your comparison is not correct.

Hi Jim and Josef

Thanks for your replies - I will find a time that WU is updated and adjust my WXSIM to that time and then shortly after -I will run the cronjob.

In that way if should work - right?

Best regards,

Henrik

in my opinion, yes
BTW I’m trying to find the correct time to do so myself.

I set up a second logfile that logs everything every hour, so I can see when WU changes, then I will run WXSIM at that time and make the logfile

And you can also see that if I pick the right time, I can easily cheat 8O