Murry Conarroe of Wildwood Weather (http://weather.wildwoodnaturist.com/) has graciously developed a nice script to calculate the “Year to Date” and “Month to Date” rainfall differential (departure from average) totals that utilizes the dailynoaareport files created by Weather Display. The script will update these differential totals on a daily basis and utilize your entire historical data archive.
To use the script, download the raintodate.php file (there are a couple of adjustable settings at the top) and add the following line to your dashboard file.
include_once('raintodate.php'); // for ytd/mtd rain calculations
It needs to be somewhere after the
“include_once($WXtags); // for the bulk of our data”
line to ensure that the variables in the testtags.php file are available.
The two variables created by the raintodate.php file that you can use anywhere in the dashboard are $avg_ytd_rain and $avg_mtd_rain.
I know that this has been a desirable variable that many of us want! Many thanks to Murry! :occasion5:
mth
Can you please explain how to implement this? I am unclear what you mean by “add the following line to your dashboard file.” What is the dashboard file?
As Jack stated, you place this line of code into the file. (preferrably at the top of the file but below the call for the WXtags or testtags)
include_once(‘raintodate.php’);
This then allows you to have use of the two tags that the raintodate.php script creates.
Year to Date Rain Difference from Average: $avg_ytd_rain
Month to Date Rain Difference from Average: $avg_mtd_rain
Not sure It working correctly for me
I believe that I have all the testtags added correctly.
For march I only have 0.01 in. We had 5.57 inches of rain March.
Something is not right there…do you have the path set correctly for the dailynoaareport files?
I believe yours should be set like this:
$loc = “./”; // set to path of dailynoaareport files
For the averages column, the following tags are required:
$avrainjan
$avrainfeb
$avrainmar
$avrainapr
$avrainmay
$avrainjun
$avrainjul
$avrainaug
$avrainsep
$avrainoct
$avrainnov
$avraindec
Checking now, your climate report for March 2011 shows 4.20 in of rain, but your wxraintrending.php shows 0.00 for March 2011.?
Maybe I’m confused about how it works.
Yes my dailynoaareport is at $loc = “./”; // set to path of dailynoaareport files
You’re correct, something is wrong with my March tag ($avrainmarnow) in WD. I just got the old script out (been a while) and these are the tags that are required. Notice my March total is 0.00. I need to look into that.
How did you correct March?. Testtags, not sure what happened. This time I deleted them in my webfiles folder, then they were overwritten w/the new ones.
ED
Currently, you’re only displaying the average month to date rainfall. You need to change your code. Basically, based on all of your data since station inception, you’ve averaged 3.08" of rain from April 1 to April 19. Then you compare this value to the current month rain to come up with a “+” or “-” value from normal. Same applies for the year to date rain but starts from Jan 1. I hope this makes sense.
Yes it makes sense. Unfortunately I don’t know how to write the code. I copied and pasted yours and it is working perfectly.
Much appreciated! :hello1: