Author Topic: Help with creating "warmest since" or "coolest since" data  (Read 24086 times)

0 Members and 1 Guest are viewing this topic.

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #50 on: March 13, 2015, 02:20:34 PM »
In theory probably yes, but I cannot tell you because I dont use any weather software and I have no idea what this text file looks like (structure of it). Attach it here so that I can have a look at it.

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #51 on: March 13, 2015, 02:29:54 PM »
Hi Jachym,
Attached is my Cumulus dayfile.txt
I had just opened it in notepad++ and then saved as dayfile.csv for uploading and testing your script.
 
I am really impressed with your work and have followed several of your posts here.
Regards,
Paul

Offline ValentineWeather

  • Forecaster
  • *****
  • Posts: 6366
    • Valentine Nebraska's Real-Time Weather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #52 on: March 13, 2015, 02:39:44 PM »
Hi Jachym,
Attached is my Cumulus dayfile.txt
I had just opened it in notepad++ and then saved as dayfile.csv for uploading and testing your script.
 
I am really impressed with your work and have followed several of your posts here.
Regards,
Paul

=D>
X2

Don't know if you need it but here is the dayfile structure. http://wiki.sandaysoft.com/a/Dayfile.txt
« Last Edit: March 13, 2015, 02:42:19 PM by ValentineWeather »
Randy

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #53 on: March 13, 2015, 02:41:39 PM »
Hi,
yes I guess little changes in the script would do the trick, but the file obviously has no headers for the columns, so please find which number corresponds to the max and which to the min. In other words, tell me the column numbers where the values for these parameters are so that I know what to import.

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #54 on: March 13, 2015, 02:45:04 PM »
Hi Jachym,
I have attached the header description file.
 
Paul

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #55 on: March 13, 2015, 02:50:36 PM »
Hi Jachym,
I should have read your full message :oops: .  The Temperature Minimum is column 5 and the Maximum is column 7.  A screen shot attached.
 
Thanks again,
Paul

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #56 on: March 13, 2015, 03:20:16 PM »
Thanks, I just arrived home, so I will look at it after dinner :D I think it should be possible to do.

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: Help with creating "warmest since" or "coolest since" data
« Reply #57 on: March 13, 2015, 03:45:30 PM »
I have an issue with both original and updated versions.
They both produce the same html output but along the way they throw errors at line 24 and 39 (latest version).
The error is the same in both areas $last_min and $last_max are flagged as Undefined variables.
Remming these lines out along with the corresponding closing } removes the error and the output is the same.

Can confirm there is no need to re-copy or rename dayfile.txt to .csv.
just change the file name (at line 14 of the latest script) to dayfile.txt.


Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #58 on: March 13, 2015, 03:50:55 PM »
Yes, I just realized that, since the structure of both is exactly the same, all that is necessary is to change the extension from csv to txt.

With regards to your errors, put this below $myfile =...

$last_min = "";
$last_max = "";

And be careful with removing those lines, it will work only at some situations depending on the actual dates, but at others it wont work and throw an error. So rather then deleting it, put the above two lines below the $myfile =...

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #59 on: March 13, 2015, 03:59:19 PM »
Thanks Brian.  I had tried that with the original script where that didn't fix it.  But had not tried it with Jachym's latest revision.  Now working as www.komokaweather.com/weather/maxmin3.php using the dayfile.txt file.
Edit: Just saw your confirmation Jachym, thanks.
 
Now to find a good place to put it.
Paul
« Last Edit: March 13, 2015, 04:00:51 PM by PaulMy »

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #60 on: March 13, 2015, 04:01:29 PM »
Great :-)

This just shows how much more stuff can be done. You see I made quite a lot of scripts on my own webpage, but for example never thought about this one particularly.... once one has the data the possibilities as to what can be calculated and how to interpret and visualize it, are endless...

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #61 on: March 13, 2015, 04:04:18 PM »
A bit off topic BUT:
The last time a higher temperature was measured was on  24th December 2014  when it was 11.5 F (1.5 F difference).
 
I hadn't realized going on to 3 months since we've had temperature as today...  Hope many more to come.
 
Thanks for the script to point this out!
Paul

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #62 on: March 13, 2015, 04:07:03 PM »
Well on the other hand... it is now almost spring (according to us meteorologists, it is actually spring already since 1st March...), so it will probably be getting only warmer now. What is interesting though is that it was actually on Christmas Eve :D I would imagine it to be even earlier than that as this is already in the middle of winter

And make sure to check it manually, just to make sure this is not just what the script thinks, but that it really is correct  :grin: :grin: :grin:

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: Help with creating "warmest since" or "coolest since" data
« Reply #63 on: March 13, 2015, 07:04:45 PM »
With regards to your errors, put this below $myfile =...
$last_min = "";
$last_max = "";
Well that makes sense - I did consider doing something like that but had not got around to working out where to put those lines.
With $last_min and $last_max established before they are tested there are no more errors.

Quote
// GET TODAY'S DATA
$myfile = fopen("realtime.txt", "r") or die("Unable to open file!");
$last_min = "";
$last_max = "";

$current = fread($myfile,filesize("realtime.txt"));

Shouldn't all users add these lines?

Offline mcrossley

  • Forecaster
  • *****
  • Posts: 1137
    • Wilmslow Astro
Re: Help with creating "warmest since" or "coolest since" data
« Reply #64 on: March 14, 2015, 10:41:33 AM »
Good idea, and simple with MySQL  :grin:
Mark

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #65 on: March 14, 2015, 12:17:25 PM »
You are absolutely right Mark,
I use something similar on my page and I use MySQL. I even suggested it but if you dont use MySQL, then I agree that doing it just for this purpose would be unnecessary and can be easily done just by importing the text/csv files.

But you are absolutely right, that this is not only easier, but also offers other possibilities, I will think about what else could be done. On my page in the section I mentioned earlier in this thread, I do it slightly differently, rather than comparing current min/max and finding last date when it was warmer/cooler, I have a page that for example finds the last time it was -5 C, 0 C, 10 C, 15 C, etc etc. and same for rain - the last time it rained more than 5mm, 10 mm etc. Categories of course you can choose yourself. ANd it then also gives you the difference in time compared to today, so for example you get a table with the corresponding dates and times and next column something like "which was XY months, XY days, XY hours, XY minutes, XY seconds ago).

FUnctional demo:
http://meteopage.com/eng/console/console.php
on the right, click the icon for "Past weather"

Offline mcrossley

  • Forecaster
  • *****
  • Posts: 1137
    • Wilmslow Astro
Re: Help with creating "warmest since" or "coolest since" data
« Reply #66 on: March 14, 2015, 12:36:15 PM »
Interesting use of the data, and I see you have got to grips with the SteelSeries gauges  :-) I have just added warmest/etc in <month> for today and yesterday to the page linked in the other thread.
Mark

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #67 on: March 14, 2015, 01:01:56 PM »
Hi Jachym and Mark,
Taking your ideas I am now trying to get additional data comparison and use my MySQL source with Mark's code but can't get past the error -
 www.komokaweather.com/mysql/since1.php
   Fatal error:  Call to a member function query() on a non-object in /home/content/96/5379896/html/mysql/since1.php on line 188
Line 188 is $result = $mysql->query($query);
 
I have used the mysql connect code from my Top 10 script changing your $mysqli to $mysql and removing your "includes" and that part seems to work.  Any suggestion what I may have missed or done wrong?
 
Thanks,
Paul

Offline mcrossley

  • Forecaster
  • *****
  • Posts: 1137
    • Wilmslow Astro
Re: Help with creating "warmest since" or "coolest since" data
« Reply #68 on: March 14, 2015, 03:23:10 PM »
Hi Paul, if you are using the old mysql calls then I don't think you can use the object->reference type syntax. You need to look it up, but it would be better to get your host to support mysqli as the php mysql calls have been depreciated.
Mark

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #69 on: March 14, 2015, 03:53:36 PM »
I highly recommend not using mysql calls, it will cause problems and there will be only more of them in the future.

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #70 on: March 14, 2015, 11:10:13 PM »
I called my host, GoDaddy, and they say that they only list MySQL as supported but that if I were to change my existing database to mysqli it should work on my hosting plan.  They forwarded some links on the differences and how I could do that.   As I am still mostly unfamiliar with MySQL and the change would most likely affect my existing MySQL scripts I won't make the change at this time.  Instead I will add to Jachym's dayfile.txt source script.  I am making progress and learning http://www.komokaweather.com/weather/maxmin2a.php but very slow and need to improve the row appearances, etc..
 
Thanks for your ideas and guidance.
Paul

Offline mcrossley

  • Forecaster
  • *****
  • Posts: 1137
    • Wilmslow Astro
Re: Help with creating "warmest since" or "coolest since" data
« Reply #71 on: March 16, 2015, 11:31:33 AM »
Hi Paul, adding mysqli does not affect the underlying MySQL database, it is just the library that PHP uses to access it. Adding mysqli does not (normally) mean the mysql library is removed, the two can co-exist, and you can use either in your PHP code.

The mysql library has been depreciated and I guess will be removed at some point in the future.
Mark

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #72 on: March 16, 2015, 12:19:11 PM »
Thanks Mark.  I will read up a bit more on MySQL in general and maybe talk to our son-in-law who is with MS and a MySQL something - I've got many boxes of MySQL text and other books he gave me to donate (but I haven't opened any yet and likely all together different than what we are talking about here).  My knowledge of MySQL is only from using some of your and Kerry's templates and applying that for my site, on a hit and miss basis ;)   I'd like to use the MySQL database more but just too difficult for now.
 
So I have continued with using dayfile.txt and now at www.komokaweather.com/weather/maxmin2b.php  Took me about 6 hours to get that far and then realize it is not producing the correct results for everything so back to scrutinising the code ](*,)

Regards,
Paul
 
 
 

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #73 on: March 16, 2015, 02:14:01 PM »
Warmest day since 30th November 2014!
I think I got the formula sorted out.  www.komokaweather.com/weather/maxmin2b.php
 
Enjoying,
Paul

Offline WX1N

  • Senior Member
  • **
  • Posts: 51
    • East Unity, NH Weather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #74 on: March 17, 2015, 07:19:41 AM »
Warmest day since 30th November 2014!
I think I got the formula sorted out.  www.komokaweather.com/weather/maxmin2b.php
 
Enjoying,
Paul

Was there a problem with Jachym's original forumla, Paul?
Rob
Amateur Radio: WX1N
NWS Spotter: SU04
CWOP ID: AU482
Website: http://www.eastunitynhweather.com

 

anything