Author Topic: Replace Yesterday with Normal Hi/Lo for Day  (Read 1122 times)

0 Members and 1 Guest are viewing this topic.

Offline greggw

  • Member
  • *
  • Posts: 15
    • ValleWeather
Replace Yesterday with Normal Hi/Lo for Day
« on: January 09, 2023, 07:36:25 PM »
I am using the Saratoga PHP Template (Base-USA) with the Ambient Weather Network (AWN) plug-in. Everything is working fine. However, on the Home Page that reports current conditions, I would like to replace the "Yesterday" temperature with the "Normal High and Low" for the current day. Since I think normals are now fixed until 2030, the data could be read from a manually-created txt file without having to make a daily request to a NOAA website. Can anyone offer advice on how to do that? Thanks.

Offline uziom

  • Member
  • *
  • Posts: 7
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #1 on: April 05, 2023, 01:26:22 PM »
To replace the "Yesterday" temperature with the "Normal High and Low" for the current day on the Home Page of your Saratoga PHP Template (Base-USA) with the Ambient Weather Network (AWN) plug-in, you would need to modify the PHP code that generates the weather data display.

Here are the general steps you can follow to achieve this:

Create a text file that contains the normal high and low temperatures for the current day. This file should be updated manually whenever there is a change in the normal temperatures.

Modify the PHP code that generates the weather data display on the Home Page to read the normal temperatures from the text file and display them in place of the "Yesterday" temperature.

To ensure that the normal temperatures are only displayed for the current day, you can use PHP's date functions to check the current date and only display the normal temperatures if they correspond to the current date.

Test the modified PHP code to ensure that it displays the normal temperatures correctly.

Here is an example code snippet that you can modify to read the normal temperatures from a text file:

Code: [Select]
// Check if today's normal temperatures are available
$normal_temps_file = 'normal_temps.txt';
if (file_exists($normal_temps_file)) {
  $normal_temps = file($normal_temps_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  $normal_high = $normal_temps[0];
  $normal_low = $normal_temps[1];
} else {
  // Fall back to displaying yesterday's temperature if normal temps are not available
  $normal_high = $yesterday_high;
  $normal_low = $yesterday_low;
}

// Display the normal high and low temperatures
echo 'Normal High: ' . $normal_high . '&deg;F<br>';
echo 'Normal Low: ' . $normal_low . '&deg;F<br>';

Note: This is just an example code snippet and may need to be modified to fit the specific structure of your PHP code. It's also important to ensure that the text file containing the normal temperatures is accessible by the PHP script and that the file path is correct in code.

Offline greggw

  • Member
  • *
  • Posts: 15
    • ValleWeather
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #2 on: April 06, 2023, 09:15:13 AM »
Thank you very much. I am new to all of this, as you can probably tell, since my post should have referenced my website at https://valleweather.com. The information you provided is very helpful and gives me a place to start. Thanks again for your help.

Offline scudwatcher

  • Billy T. Forecaster Webmaster csraweather.net
  • Senior Contributor
  • ****
  • Posts: 157
  • Amateur Radio KC4SRA csraweather.net
    • CSRA Weather
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #3 on: April 28, 2023, 10:52:31 AM »
Since I could not get alt-dashboard 6.95h to configure and upload to my site in three attempts, I would LOVE to change my Saratoga base-USA TODAY and YESTERDAY High and Low Temps to NORMALS and RECORDS High and Low Temps.  I am aware that I would have to modify ajax-dashboard php and some WD testtags in some fashion....any suggestions?  I was successful in modifying my ajax-dashboard to change ALMANAC to SOIL TEMPS AND MOISTURES @ https://csraweather.org  Thank You in advance!   

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #4 on: April 28, 2023, 03:06:44 PM »
You could always ditch going through the dashboard and have a section under the dashboard.

https://www.wxforum.net/index.php?topic=37220.0

The temps on my site for "National Weather Service History" section is using this simple PHP program noaarec.php.

The rain part on my site is custom.

https://www.bismarckweather.net
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline scudwatcher

  • Billy T. Forecaster Webmaster csraweather.net
  • Senior Contributor
  • ****
  • Posts: 157
  • Amateur Radio KC4SRA csraweather.net
    • CSRA Weather
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #5 on: April 28, 2023, 03:16:48 PM »
Hey 92merc!  Thanks for your response!  I will give it a second try.  Can I PM you for questions?  I was unfortunate with my initial attempt configuring noaarec.php to work on my site….

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #6 on: April 28, 2023, 03:32:15 PM »
Not a whole lot to configure.  Just figuring out your wfo location and edit the noaarec.php file.

In your ajaxdashboard.php file, at the top you add in include_once("noaarec.php");
I put mine right after the $ADBversion line.

Then way down the same file, I had a <?php } // end $haveSolar  ?> line.  Jut go after those two closing </table> commands.  Add in:

Code: [Select]
<table width="630" border="0" cellpadding="0" cellspacing="0" style = "font-weight: normal";>
<th style="text-align:center" colspan="2">National Weather Service History</th>
<tr style="text-align:center">
<td>Normal High: &nbsp;<?php echo $thisDayMaxAvg?>&deg;F</td>
<td>Normal Low: &nbsp;<?php echo $thisDayMinAvg?>&deg;F</td>
</tr>
<tr style="text-align:center">
<td>Record High: &nbsp;<?php echo $thisDayMax?>&deg;F &nbsp;<?php echo $thisDayMaxYear?></td>
<td>Record Low: &nbsp;<?php echo $thisDayMin?>&deg;F &nbsp;<?php echo $thisDayMinYear?></td>
</tr>
</table>


Mine is the stock ajaxdashboard, so it was line 1056.  With your custom one, not sure where yours would be.  Somewhere above the forecast section of the dashboard.  My forecast has this in the area:

Code: [Select]
<?php langtrans(&#39;Weather Forecast&#39;); ?>&nbsp; -  <?php langtrans(&#39;Outlook&#39;);
So you'd add the table in just above that forecast area table.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline scudwatcher

  • Billy T. Forecaster Webmaster csraweather.net
  • Senior Contributor
  • ****
  • Posts: 157
  • Amateur Radio KC4SRA csraweather.net
    • CSRA Weather
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #7 on: April 28, 2023, 03:45:10 PM »
Thank You, sir!  I had trouble with SID, if I can remember, but I will work on it later this weekend!

Offline scudwatcher

  • Billy T. Forecaster Webmaster csraweather.net
  • Senior Contributor
  • ****
  • Posts: 157
  • Amateur Radio KC4SRA csraweather.net
    • CSRA Weather
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #8 on: April 29, 2023, 06:44:29 AM »
Hey 92merc,
  Thanks for your responses.  Up and running at https://csraweather.org  I will do a little research on reading the message threads on rainfall data and hopefully, implement very soon.

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #9 on: April 29, 2023, 03:51:00 PM »
Hey 92merc,
  Thanks for your responses.  Up and running at https://csraweather.org  I will do a little research on reading the message threads on rainfall data and hopefully, implement very soon.

Here is the start to that rain setup I have.

https://www.wxforum.net/index.php?topic=35922.msg459186#msg459186
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline scudwatcher

  • Billy T. Forecaster Webmaster csraweather.net
  • Senior Contributor
  • ****
  • Posts: 157
  • Amateur Radio KC4SRA csraweather.net
    • CSRA Weather
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #10 on: April 30, 2023, 11:38:01 AM »
92merc,
  Sorry for the delayed response.  When I downloaded the records.xlsm.txt file, I am observing different text characters....could you send me an .xls file? OR can you email to csrawxorg@gmail.com, please?

I have been recording raw climatological data on my "home-brew" generated spreadsheets since 2017 at
 [ You are not allowed to view attachments ]

So, I will not have any issue creating my own records.xls.  I can also pull record data from WD as well from:
https://csraweather.org/wxtempdetail.php

I also generate daily climatological reports at:
https://csraweather.org/cumulus1/dailyalmanac.htm

Monthly Climatological Reports at:
https://csraweather.org/cumulus1/monthlyclimatesummary.htm

I believe I have enough data to create my "home-brew" version of your spreadsheet.....

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #11 on: April 30, 2023, 12:22:33 PM »
The forum doesn't allow Excel files to be posted.  You just need to remove the .txt extension so it's a .xlsm file.

Your almanac has pretty much what I have.  My main 2 goals with the rain data, was to see what's normal rain for the month.  And see what normal rain is year to date.  I didn't want to use my rain data as it's been spread from VWS, Cumulus, and WD.  I decided to make it an "official" comparison to the National Weather Service.

But in my Excel file, if all you want to do is rain, then column D is all you'd enter.  If you go to your local weather city on NWS, look for the NOW Data section.  Pick your city.  Change the dot to "Daily/monthly normals".  Change options to daily.  Change Variable to Precipitation.  that'll return a graph and table.  I basically copy each month column into my spreadsheet.  For February 29th, I manually added 0.00.  Once the year is filled out, it calculates normal month rain and a daily YTD rain total.

The macro RainMonth makes 12 txt files for normal rain for month.  The YTD_Files macro makes 366 for each YTD rain.

Then make a history folder on your website.  Deposit the TXT files in that folder.  This extra TR reads today's date and/or month and pulls the prints the TXT files on the page.

Code: [Select]
<th style="text-align:center" colspan="2">National Weather Service History</th>
<tr style="text-align:center">
<td>Normal Rain Month: &nbsp;<?php $mydate date(&#39;m&#39;); $filename = "./history/rain".$mydate."mo.txt"; include($filename);?>&nbsp; in.</td>
<td>Normal Rain YTD: &nbsp;<?php $mydate date(&#39;md&#39;); $filename = "./history/".$mydate."ytd.txt"; include($filename);?>&nbsp; in.</td>
</tr>

The rest of the Excel I had developed before the NOAAREC.php file was developed.  I started on my own solution, but the new PHP worked better as I didn't have to do upkeep for new records for the year.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #12 on: April 30, 2023, 12:23:04 PM »
Forgot to add the NOW data screenshot I did.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #13 on: April 30, 2023, 12:23:53 PM »
Here's the table I copy from.

https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline scudwatcher

  • Billy T. Forecaster Webmaster csraweather.net
  • Senior Contributor
  • ****
  • Posts: 157
  • Amateur Radio KC4SRA csraweather.net
    • CSRA Weather
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #14 on: April 30, 2023, 02:31:43 PM »
The attached is the text file I downloaded with corrupt digits?

 [ You are not allowed to view attachments ]

I can't convert from .txt to .xlsm.....

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1314
  • BismarckWeather.net
    • BismarckWeather.net
Re: Replace Yesterday with Normal Hi/Lo for Day
« Reply #15 on: April 30, 2023, 04:48:40 PM »
I sent it to your email.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

 

anything