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

0 Members and 1 Guest are viewing this topic.

Offline WX1N

  • Senior Member
  • **
  • Posts: 51
    • East Unity, NH Weather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #125 on: March 18, 2015, 07:11:25 AM »
Thanks!  I've had Cumulus running for almost 3 years, and I've been using the Saratoga templates for probably about a year now, but I'm just now starting to do some customization.
I can probably find the answer to this by reading through some of the documentation, but maybe you wouldn't mind saving me a little time (plus I learn better looking at a specific example, than by reading about a concept).  Let's say I make a new page on the website, let's call it new_page.php.  On this page, I want to display "Yesterday's low temp was " xxx degrees.
I'm imagining the code would look something like:
Yesterday's low temp was<&nbsp><?php echo $WX[TtempYL] ?>

 - Is the variable for this supposed to be $WX[TtempYL] ?
 - In order to use this variable, does new_page.php need to use the command "include("cutags.php")"?
Rob
Amateur Radio: WX1N
NWS Spotter: SU04
CWOP ID: AU482
Website: http://www.eastunitynhweather.com

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #126 on: March 18, 2015, 07:22:34 AM »
OK, I see... well I guess this is exactly something someone else has to answer you, because I dont use Cumulus at all and have no clue how it handles the data, from PHP perspective it looks correct

Offline WX1N

  • Senior Member
  • **
  • Posts: 51
    • East Unity, NH Weather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #127 on: March 18, 2015, 07:28:24 AM »
Lol... reading this I have no clue what are you guys talking about :D And Im thinking it was a good idea I actually started from scratch writing everything myself, because then you know exactly which part of your script does what and have a complete control over how you want your data to be interpreted, analyzed and displayed... What I do is basically just work with raw data sent by Meteobridge.

Anyway, back to topic though, I still dont really understand what you are trying to achieve in terms of those labels for units of measurement...
Cumulus is software that runs on your local computer.  It monitors your weather station, logs the data into files, provides the data to various weather services, and it can also create web pages and graphs automatically, and upload them and the data files to your web server.

The Saratoga templates are a pre-designed PHP website that can be modified to meet your needs.  It is designed to work with Cumulus, so it has variables for use in PHP that represent the various information coming from Cumulus.

On the labels, he's trying to display a label with the unit of measure for the wind run, but it is not provided by Cumulus, so he needs to generate his own.  So if the wind run was "75", he wants to display "miles" or "kilometers" to label what the "75" represent.
Rob
Amateur Radio: WX1N
NWS Spotter: SU04
CWOP ID: AU482
Website: http://www.eastunitynhweather.com

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #128 on: March 18, 2015, 07:52:45 AM »
Aha  :grin:

well that should be very very simple.... at least I think from how I understand it now...

so lets say we have the windrun saved in variable "windrun" and it has a value of lets say 75. And we know its in miles.

So we just do:
Code: [Select]
echo $windrun." miles";

Offline WX1N

  • Senior Member
  • **
  • Posts: 51
    • East Unity, NH Weather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #129 on: March 18, 2015, 07:54:35 AM »
Aha  :grin:

well that should be very very simple.... at least I think from how I understand it now...

so lets say we have the windrun saved in variable "windrun" and it has a value of lets say 75. And we know its in miles.

So we just do:
Code: [Select]
echo $windrun." miles";
I think he was trying to make it universal - he wanted to detect whether miles or kilometers was being used, and display the appropriate label.  I think he needs an IF statement to evaluate the label for the wind SPEED (mph or km/h), and based on that, display either "miles" or "kilometers".
« Last Edit: March 18, 2015, 07:56:23 AM by WX1N »
Rob
Amateur Radio: WX1N
NWS Spotter: SU04
CWOP ID: AU482
Website: http://www.eastunitynhweather.com

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #130 on: March 18, 2015, 08:00:37 AM »
I see, well and how do you know which one is used? Is it part of the actual variable? In other words, is the variable value a combination of the number and unit abbreviation? Or is the value of unit saved in some other variable? Like how do you detect this, where in the file is is saved?

Offline WX1N

  • Senior Member
  • **
  • Posts: 51
    • East Unity, NH Weather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #131 on: March 18, 2015, 08:07:15 AM »
I see, well and how do you know which one is used? Is it part of the actual variable? In other words, is the variable value a combination of the number and unit abbreviation? Or is the value of unit saved in some other variable? Like how do you detect this, where in the file is is saved?
Looking over his script, it looks like he has gotten as far as extracting the label for wind speed.  It's in the variable $unitS.  If I'm understanding what he wants to do correctly, he needs a statement that will set variable $unitD to equal "miles" if $unitS = "MPH", or set it to equal "kilometers" if $unitS = "km/h".
Does this look correct?
if($unitS=="MPH"){
   $unitD = "miles";
}
if($unitS=="km/h"){
   $unitD = "kilometers";
}
Rob
Amateur Radio: WX1N
NWS Spotter: SU04
CWOP ID: AU482
Website: http://www.eastunitynhweather.com

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #132 on: March 18, 2015, 08:26:43 AM »
 =D&gt;

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #133 on: March 18, 2015, 08:27:09 AM »
I am not at home at my computer, just finished my usual 5 day weekends ;) but this discussion is good and I think I now understand how to make the Wind Run label and will try that tonight.   Thanks Rob.

For now it is on my Cumulus based site so not fully PHP and that is why I have used realtime.txt.  I will look at adding it to my Saratoga template site later, and thanks for mentioning CUtags as I might not have thought of that.  Possibilities are just about endless...


Enjoying,
Paul

Offline WX1N

  • Senior Member
  • **
  • Posts: 51
    • East Unity, NH Weather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #134 on: March 18, 2015, 08:29:46 AM »
I am not at home at my computer, just finished my usual 5 day weekends ;) but this discussion is good and I think I now understand how to make the Wind Run label and will try that tonight.   Thanks Rob.

For now it is on my Cumulus based site so not fully PHP and that is why I have used realtime.txt.  I will look at adding it to my Saratoga template site later, and thanks for mentioning CUtags as I might not have thought of that.  Possibilities are just about endless...


Enjoying,
Paul

Yes, the fun is just beginning lol.  Take that line of code from my last post, and put it in where you have $unitD = substr ..... etc., and it should do what you want.  Let us know!
Rob
Amateur Radio: WX1N
NWS Spotter: SU04
CWOP ID: AU482
Website: http://www.eastunitynhweather.com

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: Help with creating "warmest since" or "coolest since" data
« Reply #135 on: March 18, 2015, 04:40:08 PM »
A little of the basics on the Saratoga templates (forgive me Ken if I don't get any of this right!).

The CUtags.txt file that gets processed in Cumulus and sent to the website as CUtags.php replaces the Cumulus variable (e.g. <#TtempYL>) with its actual current value. At the bottom of the CUtags.php file, there is additional code which puts all the variables in the file into an ARRAY $WX[] thus using the form;
Code: [Select]
Yesterday's low temp was<&nbsp><?php echo $WX[TtempYL?>uses the data item directly from the array.

However, if the relevant variable is also added to CU-defs.php (which is called by CUtags.php) then there will be a 'WD' variable $mintempyestt which is created by the line $mintempyestt = $WX['TtempYL']; in CU-defs.php.
Why $mintempyestt instead of TtempYL? Well the WD tag is %mintempyestt% not <#TtempYL> and the Saratoga template started with WD. So the XX-defs.php mechanism not only provides $vars for the webpages but also provides a 'translation' service so each different weather software system can be 'translated' to the common WD 'language' so the templates can work unchanged with multiple weather softwares (is softwares a valid word?).
So, you can see this is the process and format indicated in my previous post.

If you want to do any customising or creating new pages, then you will not get far without having the wiki pages from Cumulus explaining these variables (so you know what is available and how to apply them), along with a similar webpage from Saratoga and the CU-defs.php file at hand.

I have a local copy of the files from the Cumulus Wiki for realtime, webtags, and Dayfile (plus others) handy as references.

So Jachym, this is no more complicated than what you do and is the same process for all Saratoga template Weather software including meteobridge. It is just that you have done all the work yourself rather than utilising a ready-made solution. This may have suited you but for may of us without the coding skills to begin with, using a ready-made solution and working with it is a great way to get a website up and running , and to learn how to do it by making changes and adding pages to suit our personal preferences.

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Help with creating "warmest since" or "coolest since" data
« Reply #136 on: March 18, 2015, 05:58:47 PM »
Hi, 
I think you have probably misunderstood what I wanted to say.  I am by no means saying Kens templates are not good,  in fact I think the exact opposite and I  admire the unbelievable amount of time and effort he puts into all this.

The reason I decided not to use it was first because in fact a year ago I knew absolutely nothing about PHP,  CSS,  jQuery etc.  And I wanted to learn it purely during my free time.  I also think that in terms of programming the best way to learn is not to buy books and read them from a to z but rather just try and anytime there is something you want to do but don't know how,  look It up...

Second reason was that  I use the raw data differently than Saratoga or leuven templates and thirdly I have more than just info from my station on my webpage so making my own scripts made it possible to better integrate it and use unified design.

So basically the reason I was actually saying that above was just because I wanted to help but needed some information about cumulus and Saratoga in order to get an idea of how to go about solving the problem.

Once again I want to emphasize that no one has probably done more for others here than Ken and I already wrote it to him long time ago  and in the end it was his work that inspired me to start rewriting the scripts in such a way they could be used by others and offer them for free hoping some might find some of them useful.

Right now I am working on a next one which I am sure some of you will like and it is something that I haven't seen anywhere in this form and could well be used thanks to many customization options with various existing templates.

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #137 on: March 18, 2015, 09:09:27 PM »
Quote
and it should do what you want.  Let us know!
I have made the change as Rob suggested, and it works so now it should give the correct label for whatever unit of measure you use with your station and Cumulus.  Previous attached file is updated.
 
Note: it will give the UoM label for the station's data, not what a web viewer may normally use.
 
Thanks again Rob and Jachym.
Paul
www.komokaweather.com/weather/maxmin.php

Offline WX1N

  • Senior Member
  • **
  • Posts: 51
    • East Unity, NH Weather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #138 on: March 18, 2015, 09:38:30 PM »
A little of the basics on the Saratoga templates (forgive me Ken if I don't get any of this right!).

Thanks so much for the run down on this.  I was pretty familiar with the Cumulus tags from using them in local files for various projects, but wasn't sure how they worked in the Saratoga website.

I have made the change as Rob suggested, and it works so now it should give the correct label for whatever unit of measure you use with your station and Cumulus.  Previous attached file is updated.

Great, glad it worked!

The reason I decided not to use it was first because in fact a year ago I knew absolutely nothing about PHP,  CSS,  jQuery etc.  And I wanted to learn it purely during my free time.  I also think that in terms of programming the best way to learn is not to buy books and read them from a to z but rather just try and anytime there is something you want to do but don't know how,  look It up...

Thanks so much for your work on this script Jachym, and for your help in learning the basics of PHP!

If any of you are interested, I took Jachym's script and made some modifications.  I added variables for the previous day's high and low, I have it run through the loop twice, once to compare today's high and low to all previous highs and lows, and once to compare yesterday's.  I added a variable for how many days back a higher/lower reading needs to be before it's worth mentioning, and builds a text string to display any data that exceeds that variable.  (I originally did this to eliminate the display of warmest/coldest since yesterday, but decided to lengthen it to a week).  I modified my ajax_dashboard on the website to display the generated text string below the thermometer.
Rob
Amateur Radio: WX1N
NWS Spotter: SU04
CWOP ID: AU482
Website: http://www.eastunitynhweather.com

Offline jay_hoehn

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 656
    • Jay's Woodcrafts
Re: Help with creating "warmest since" or "coolest since" data
« Reply #139 on: March 19, 2015, 12:49:22 AM »
Rob,

It looks like you need mph not MPH on your fix for UOM.  Should look like this

if($unitS=="mph"){
   $unitD = "miles";
}
if($unitS=="km/h"){
   $unitD = "kilometers";
}

Jay
Davis Vantage Pro2 Plus
VVP
Weather Display


Offline mcrossley

  • Forecaster
  • *****
  • Posts: 1137
    • Wilmslow Astro
Re: Help with creating "warmest since" or "coolest since" data
« Reply #140 on: March 19, 2015, 05:40:03 AM »
Rob,

It looks like you need mph not MPH on your fix for UOM.  Should look like this

if($unitS=="mph"){
   $unitD = "miles";
}
if($unitS=="km/h"){
   $unitD = "kilometers";
}

Jay
Or even more general (for Cumulus)...
Code: [Select]
if ($unitS === 'mph') {
    $unitD = 'miles';
} else if ($unitS === 'km/h' || $unitS === 'm/s') {
    $unitD = 'kilometers';
} else if ($unitS === 'kts') {
    $unitD = 'n.miles';
} else {
    $unitD = '???';
}
« Last Edit: March 19, 2015, 07:32:48 AM by mcrossley »
Mark

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #141 on: March 19, 2015, 07:22:59 AM »
Thanks for the suggestions, and for confirming "mph", and Mark for mentioning "kts"
 
Paul

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #142 on: March 21, 2015, 02:00:32 PM »
I now have it working with my Saratoga template www.komokaweather.ca/wxmaxmin.php  \:D/   Now to eliminate the W3C CSS Validation errors.
 
Paul
 

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5519
    • KomokaWeather
Re: Help with creating "warmest since" or "coolest since" data
« Reply #143 on: March 22, 2015, 08:00:30 PM »
Hi Randy (ValentineWeather)
Quote
Would someone post the finished code with any instructions needed when all done for us cumulus users. I prefer the North American Date format.
Thanks
Where you able to download the script?  It should be a simple plug and play other than setting the path to your realtime.txt and dayfile.txt files and changing the name.
 
Enjoy,
Paul
www.komokaweather.ca/wxmaxmin.php