PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Sun 23 Oct 2022 8:58 pm
NOTICE - For existing users already running this php script and finding that any new snow information you entered in CMX 4.2.0 and above has not updated your snow summary on your web page there is now a fix in the snowSumData.php script. Download the file and replace it with the one already installed.
______________________________________________________________________________________________________________________
Updated version: updated 12-03-2024 (Do Not Use with CMX 4.3.0 b4063 and Above)
There is a new version specifically for CMX 4.3 and above. It can be obtained here: viewtopic.php?t=22921
For CMX versions below 4.3
ver 1.1
Fixed issue of not updating snow information on web page from CMX 4.2.0 and above.
Added a new HTML table containing the following items by month; (please see images below)
* Cumulative days with snowfall
* Cumulative snowfall depth
* Average annual snowfall depth
* Probability of snowfall %
* Year with most snowfall and its amount
* Year with least snowfall and its amount
Also re-wrote large portions of the script for better optimization.
Thanks to PaulMy as portions of this script is inspired from komokaweather.com snowfall-log.pdf.
MUST have php installed on the same computer running CumulusMX to use this script. The zip contains the files necessary and a read_me text with install instructions.
Runs successfully in Cumulus MXUI web template and the standard CMX website template. Hasn't been tested on other templates but shouldn't be any reason it wouldn't work. For both templates just add <?php include_once "./snowSummary.php";?> where you where you want it to be displayed. Then for the standard template just change the webpage extension from .htm to .php and update your menu to point the .php page.
PLEASE READ
Since the scripts' function has changed considerably from it's inception, below is a brief explanation of how to enter data so that my scripts will display the desired results.
______________________________________________________________________________________________________________________
In the main CMX program go to "Edit => Weather Diary" where you will find a few fields for entering data. My script does not utilize the comments box section.
--------------------------
Snow Depth text box:
--------------------------
Enter any new snowfall measurement received in a 24 hr period. New snowfall measurements are generally taken once a day usually between 7am and 9am. But use any time you want. The important thing is to try to be consistent for better accuracy. In my script, this text box is only used for recording new measurable snowfall in a 24 hr period. It is not for recording "snow on the ground" or the "snowpack". Since there is only one text box, I had to make a decision. I felt it was more important to know the amount of snow received in a 24 hr period rather than the overall snow on the ground.
----------------------------
SnowFalling check box:
----------------------------
This is used to record days when it snowed but did not amount to any measurable snowfall. This would be considered as Trace snow. When checking this box, nothing is to be entered inside the Snow Depth textbox. This checkbox will record as a snow event and it will add a day to the the Snow Event row in my script.
--------------------------
SnowLying check box:
--------------------------
The only purpose of checking this box is to record a day that there is snow on the ground. This is commonly known as ground cover or snowpack. It's purpose is to keep a count of days that snow was on the ground. This will not count as a snow event and will not be recorded as such. It will however, keep a count of the amount of days snow was on the ground and record it as such in my script as Ground Cover.
This check box may be used with either the SnowFalling check box or the Snow Depth text box. This is because the temps may have been below freezing for several days and there may already be snow on the ground. This allows the ability to record the new snow event, using either the SnowFalling checkbox (if there was only a trace of snow) or the Snow Depth textbox (if there was measurable snow) while at the same time recording the ground cover. Just remember that the Snow Depth textbox is for recording "new snowfall" amounts (events) and not the overall depth of the snow already on the ground (snowpack).
______________________________________________________________________________________________________________________
That's all there is too it. The scripts will do the rest getting it to your website at your website update interval.
snowSummary can be run as a standalone page or as an "include_once" in your template page and it should fire up with minimal effort. Of course your mileage may vary but it should be fairly easy to tweak. This has been tested as best I can but I have no way of testing on public website. If someone wants to try it out on a public site and let me know, I can try to fine tune it as needed.
I am not a programmer. I just fiddle around and sometimes come up with something useful. Anyway, I wanted something to display total snow amounts for each month and total the months up by year. So I began fiddling and came up with this script.
Please feel free to alter it as you see fit and/or improve upon it for simpler adaptability for future CMX upgrades. Feedback is welcome but please remember I am not a programmer. This is a continuing project.
pic of it used as an include in a template showing northern hemisphere:
Same as above but with daily snowfall calendar popup dialog
Updated version: updated 12-03-2024 (Do Not Use with CMX 4.3.0 b4063 and Above)
There is a new version specifically for CMX 4.3 and above. It can be obtained here: viewtopic.php?t=22921
For CMX versions below 4.3
ver 1.1
Fixed issue of not updating snow information on web page from CMX 4.2.0 and above.
Added a new HTML table containing the following items by month; (please see images below)
* Cumulative days with snowfall
* Cumulative snowfall depth
* Average annual snowfall depth
* Probability of snowfall %
* Year with most snowfall and its amount
* Year with least snowfall and its amount
Also re-wrote large portions of the script for better optimization.
Thanks to PaulMy as portions of this script is inspired from komokaweather.com snowfall-log.pdf.
MUST have php installed on the same computer running CumulusMX to use this script. The zip contains the files necessary and a read_me text with install instructions.
Runs successfully in Cumulus MXUI web template and the standard CMX website template. Hasn't been tested on other templates but shouldn't be any reason it wouldn't work. For both templates just add <?php include_once "./snowSummary.php";?> where you where you want it to be displayed. Then for the standard template just change the webpage extension from .htm to .php and update your menu to point the .php page.
PLEASE READ
Since the scripts' function has changed considerably from it's inception, below is a brief explanation of how to enter data so that my scripts will display the desired results.
______________________________________________________________________________________________________________________
In the main CMX program go to "Edit => Weather Diary" where you will find a few fields for entering data. My script does not utilize the comments box section.
--------------------------
Snow Depth text box:
--------------------------
Enter any new snowfall measurement received in a 24 hr period. New snowfall measurements are generally taken once a day usually between 7am and 9am. But use any time you want. The important thing is to try to be consistent for better accuracy. In my script, this text box is only used for recording new measurable snowfall in a 24 hr period. It is not for recording "snow on the ground" or the "snowpack". Since there is only one text box, I had to make a decision. I felt it was more important to know the amount of snow received in a 24 hr period rather than the overall snow on the ground.
----------------------------
SnowFalling check box:
----------------------------
This is used to record days when it snowed but did not amount to any measurable snowfall. This would be considered as Trace snow. When checking this box, nothing is to be entered inside the Snow Depth textbox. This checkbox will record as a snow event and it will add a day to the the Snow Event row in my script.
--------------------------
SnowLying check box:
--------------------------
The only purpose of checking this box is to record a day that there is snow on the ground. This is commonly known as ground cover or snowpack. It's purpose is to keep a count of days that snow was on the ground. This will not count as a snow event and will not be recorded as such. It will however, keep a count of the amount of days snow was on the ground and record it as such in my script as Ground Cover.
This check box may be used with either the SnowFalling check box or the Snow Depth text box. This is because the temps may have been below freezing for several days and there may already be snow on the ground. This allows the ability to record the new snow event, using either the SnowFalling checkbox (if there was only a trace of snow) or the Snow Depth textbox (if there was measurable snow) while at the same time recording the ground cover. Just remember that the Snow Depth textbox is for recording "new snowfall" amounts (events) and not the overall depth of the snow already on the ground (snowpack).
______________________________________________________________________________________________________________________
That's all there is too it. The scripts will do the rest getting it to your website at your website update interval.
snowSummary can be run as a standalone page or as an "include_once" in your template page and it should fire up with minimal effort. Of course your mileage may vary but it should be fairly easy to tweak. This has been tested as best I can but I have no way of testing on public website. If someone wants to try it out on a public site and let me know, I can try to fine tune it as needed.
I am not a programmer. I just fiddle around and sometimes come up with something useful. Anyway, I wanted something to display total snow amounts for each month and total the months up by year. So I began fiddling and came up with this script.
Please feel free to alter it as you see fit and/or improve upon it for simpler adaptability for future CMX upgrades. Feedback is welcome but please remember I am not a programmer. This is a continuing project.
pic of it used as an include in a template showing northern hemisphere:
Same as above but with daily snowfall calendar popup dialog