Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Yet Another Dayfile Reader (PHP)

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Phil23
Posts: 884
Joined: Sat 16 Jul 2016 11:59 pm
Weather Station: Davis VP2+ & GW1000 (Standalone)
Operating System: Win10 Pro / rPi Buster
Location: Australia

Re: Yet Another Dayfile Reader (PHP)

Post by Phil23 »

beteljuice wrote: Mon 01 Jul 2019 12:09 pm
Just one thing missing, & that's a credit to yourself at the bottom of the page.
Add it if you wish ...
credit added, along with a link back to this thread for numb skulls like me that didn't know it existed......
:Now: :Today/Yesterday:

Image

Main Station Davis VP2+ Running Via Win10 Pro.
Secondary Stations, Ecowitt HP2551/GW1000 Via rPi 3 & 4 Running Buster GUI.
:Local Inverell Ecowitt Station: :Remote Ashford Ecowitt Station:
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Yet Another Dayfile Reader (PHP)

Post by beteljuice »

... All lines within the New code block, :geek:

... but

Error, Error ... references to

$tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['sum'].'</th>';

Should be:

$tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['total'].'</th>';

fixed ;)
Image
......................Imagine, what you will KNOW tomorrow !
Phil23
Posts: 884
Joined: Sat 16 Jul 2016 11:59 pm
Weather Station: Davis VP2+ & GW1000 (Standalone)
Operating System: Win10 Pro / rPi Buster
Location: Australia

Re: Yet Another Dayfile Reader (PHP)

Post by Phil23 »

beteljuice wrote: Sun 21 Jul 2019 10:01 pm $tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['sum'].'</th>';

Should be:

$tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['total'].'</th>';
Is that intended to put the word Total here?
Can't see any change on my page when I switched it from sum to total.
Capture.JPG
You do not have the required permissions to view the files attached to this post.
:Now: :Today/Yesterday:

Image

Main Station Davis VP2+ Running Via Win10 Pro.
Secondary Stations, Ecowitt HP2551/GW1000 Via rPi 3 & 4 Running Buster GUI.
:Local Inverell Ecowitt Station: :Remote Ashford Ecowitt Station:
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Yet Another Dayfile Reader (PHP)

Post by beteljuice »

In default It should put the sigma symbol - same as the bottom line ....

In your page(s), very first mod section, you still have:

Code: Select all

// *** NEW for rain
if($dataSet == 'winddir') {
	$tablelayout .= '<th style="width: 80px;">'.$translit[$dayfileLang]['dom'].'</th>';
} else {
	if($dataSet == 'rainfall') {
	    $tablelayout .= '<th style="width: 80px;">'.$translit[$dayfileLang]['sum'].'</th>';
	} else {
	    $tablelayout .= '<th style="width: 80px;">'.$translit[$dayfileLang]['avg'].'</th>';
	}
}	
//		
Image
......................Imagine, what you will KNOW tomorrow !
Phil23
Posts: 884
Joined: Sat 16 Jul 2016 11:59 pm
Weather Station: Davis VP2+ & GW1000 (Standalone)
Operating System: Win10 Pro / rPi Buster
Location: Australia

Re: Yet Another Dayfile Reader (PHP)

Post by Phil23 »

I wasn't going to ask.....
About changing the bottom row back to average; thought I'd brave it myself....
Almost got there....

Achieved the correct values on both the Rain & EVT pages. Just have the Sigma symbol left on the last row.

Capture.JPG

Changed this....

Code: Select all

// *** NEW FOR RAIN TOTALS **
if($dataSet == 'rainfall' || $dataSet == 'evt') {
//	if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]);
    if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
} else {
    if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
}
//

//               if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
Is it one line to get Avg against that row?

Cheers.

Edit:- My entire code block as it stands.

Code: Select all

// START year avg table *** MODIFIED FOR RAIN TOTALS ***
    $tablelayout .= "                <table id='avgTable' style = 'display:".($show_year_averages ? "table" : "none").";'>\n";
    $tablelayout .= "<tr>\n";
//    $tablelayout .= '<th style="width: 80px;">'.($dataSet == 'winddir' ? $translit[$dayfileLang]['dom'] : $translit[$dayfileLang]['avg']).'</th>';

// *** NEW for rain
if($dataSet == 'winddir') {
	$tablelayout .= '<th style="width: 80px;">'.$translit[$dayfileLang]['dom'].'</th>';
} else {
	if($dataSet == 'rainfall' || $dataSet == 'evt') {
	    $tablelayout .= '<th style="width: 80px;">'.$translit[$dayfileLang]['total'].'</th>';
	} else {
	    $tablelayout .= '<th style="width: 80px;">'.$translit[$dayfileLang]['avg'].'</th>';
	}
}	
//		

    $tablelayout .= '<th>'.$translit[$dayfileLang]['mn'][0].'</th><th>'.$translit[$dayfileLang]['mn'][1].'</th><th>'.$translit[$dayfileLang]['mn'][2].'</th><th>'.$translit[$dayfileLang]['mn'][3].'</th><th>'.$translit[$dayfileLang]['mn'][4].'</th><th>'.$translit[$dayfileLang]['mn'][5].'</th><th>'.$translit[$dayfileLang]['mn'][6].'</th><th>'.$translit[$dayfileLang]['mn'][7].'</th><th>'.$translit[$dayfileLang]['mn'][8].'</th><th>'.$translit[$dayfileLang]['mn'][9].'</th><th>'.$translit[$dayfileLang]['mn'][10].'</th><th>'.$translit[$dayfileLang]['mn'][11].'</th>';
    $tablelayout .= "</tr>\n";

    $bert = count($type_year) -1;
    $alltime = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 9 => array(), 10 => array(), 11 => array(), 12 => array());

    $bg_alltime = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 9 => array(), 10 => array(), 11 => array(), 12 => array());

    if($dataSet == 'winddir') {
        for($zz = 1; $zz <= 12; $zz++){
            $alltime[$zz] = array( 0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0);
        }
    }
    $shortMon = array();
    for ($d = $bert; $d >= 0; $d--) { // latest year first
        $shortMon[$d] = array();
        $tablelayout .= '<tr>';
        $tablelayout .=  '<th>'.$type_year[$d].'</th>';

        for ($m = 1; $m <= 12; $m++) {
            $shortMon[$d][$m] = false;
            $windd = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0); // twitch fix
            $tablelayout .=  '<td';
            $thisValue = '';
            $part2 = '';

            if(isset($type_data[$type_year[$d]]) && array_key_exists($m, $type_data[$type_year[$d]])) {
                $turd = array();

                $bg_turd = array(); // hmm ... it's not going to be that simple !!!



               foreach($type_data[$type_year[$d]][$m] as $k => $v){

                    if($v <> ''){ // only take account of non null entries
                       if($dataSet == 'winddir'){
                           if($v[0] >0 && $v[1] >0) $windd[round($v[0] / 45)]++ ; // increment wind dir count
                           $v = '';
                        }

                       if(is_array($v)){ // we are dealing with something that needs calculating
                           $thisValue = $v;
                           formatOP(); // only want to use 'native' result
                           $thisValue = ''; // reset
                           $part2 = ''; // reset
                           $turd[] = $native;
                        } else { // 'normal' single piece of data
                           $turd[] = $v; // a 'normal' single data entry

                            if($dataSet == "HoursSun" && $run_sun) {
                                $bg_y = $type_year[$d];
                                $bg_when = mktime(0,0,0, $m, $k, $bg_y);
                                $bg_turd[] = maxsunhours($bg_when);
                            }

                        }
                    }
                }
                if($turd){
                    if($dataSet == 'winddir'){
                        $workMax = max($windd); // find highest occurrence
                        $found = false;
                        foreach($windd as $k => $v){
                            $alltime[$m][$k] += $v;
                            if($found !== true && $v == $workMax){ // see if number of occurrences = max
                                $thisValue = ($k == 0 ? 44 : $k * 45); // sort of put back into a degree range
                                $found = true; // only looking for first (clockwise) event
                            }
                        }
                    } else { // everything that really needs averages
					
// *** NEW FOR RAIN TOTALS **
if($dataSet == 'rainfall' || $dataSet == 'evt') {
	$thisValue = array_sum($turd);
} else {
	$thisValue = array_sum($turd) / count($turd);
}
//

//                        $thisValue = array_sum($turd) / count($turd);
                        $thatvalue = "";
                        if($dataSet == 'HoursSun' && $run_sun){
                            $bg_value = round(array_sum($bg_turd) / count($bg_turd), 1);
                            $sunAvailable = $bg_value;
                        }
                    }
                }
                if($thisValue || $thisValue == 0){
                    if($dataSet != 'winddir') $alltime[$m][] = $thisValue;
                    if($dataSet == 'HoursSun' && $run_sun) $bg_alltime[$m][] = $bg_value; // ### NEW bargraph stuff
                    formatOP();
                    $short =  (count($turd) < cal_days_in_month(CAL_GREGORIAN, $m, $type_year[$d]) ? "* " : "");
                    if(count($turd) < cal_days_in_month(CAL_GREGORIAN, $m, $type_year[$d])) $shortMon[$d][$m] = true ;
                    $tablelayout .=  " class=\"datacell2\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue."</td>";
                }else {
                    $tablelayout .=  ' class="nondate">&nbsp;</td>';
                }
            }else{
                $tablelayout .=  ' class="nondate">&nbsp;</td>';
            }
        } // END month walk
        $tablelayout .= "</tr>\n";
    } // END year walk
// now do overall month averages
    $tablelayout .= '<tr>';

// *** NEW for rain
if($dataSet == 'winddir') {
	$tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['dom'].'</th>';
} else {
	if($dataSet == 'rainfall' || $dataSet == 'evt') {
	    $tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['total'].'</th>';
	} else {
	    $tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['avg'].'</th>';
	}
}	
//
		
//    $tablelayout .=  '<th class="topborder">'.($dataSet == 'winddir' ? $translit[$dayfileLang]['dom'] : $translit[$dayfileLang]['avg']).'</th>';
    for ($m = 1; $m <= 12; $m++) {
        $tablelayout .=  '<td';
        $thisValue = '';
        $part2 = '';

        if(isset($alltime[$m])) {
            if($dataSet == 'winddir'){
                $workMax = max($alltime[$m]);
                foreach($alltime[$m] as $k => $v){
                    if($v == $workMax){ // see if number of occurences = max
                        $thisValue = ($k == 0 ? 44 : $k * 45); // sort of put back into a degree range
                        break; // only looking for first (clockwise) event
                    }
                }
            } else {
                if(is_array($alltime[$m])) {
					
// *** NEW FOR RAIN TOTALS **
if($dataSet == 'rainfall' || $dataSet == 'evt') {
//	if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]);
    if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
} else {
    if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
}
//

//               if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
                }
            }
            if($thisValue){

                if($dataSet == 'HoursSun' && $run_sun){
                    if(is_array($bg_alltime[$m])) {
                        if(count($bg_alltime[$m]) != 0) $bg_value = round(array_sum($bg_alltime[$m]) / count($bg_alltime[$m]), 1);
                        $sunAvailable = $bg_value;
                    }
                }

                formatOP();
                $short = "";
                for ($d = $bert; $d >= 0; $d--) { // latest year first (not important)
                    if($shortMon[$d][$m]){
                       $short = "* ";
                       break;
                    }
                }
                $tablelayout .=  " class=\"datacell2 topborder\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue."</td>";
            }else {
                $tablelayout .=  ' class="nondate topborder">&nbsp;</td>';
            }
        }else{
            $tablelayout .=  ' class="nondate topborder">&nbsp;</td>';
        }
    } // END month walk
    $tablelayout .= "</tr>\n";
    // END overall year averages
    $tablelayout .= "                </table>\n            </div>\n";
// END year averages table
You do not have the required permissions to view the files attached to this post.
:Now: :Today/Yesterday:

Image

Main Station Davis VP2+ Running Via Win10 Pro.
Secondary Stations, Ecowitt HP2551/GW1000 Via rPi 3 & 4 Running Buster GUI.
:Local Inverell Ecowitt Station: :Remote Ashford Ecowitt Station:
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Yet Another Dayfile Reader (PHP)

Post by beteljuice »

The modified code gives overall totals, so just remove the mods in the last section.
Put it back to the way it used to be ....

Code: Select all

// *** NEW FOR RAIN TOTALS **
if($dataSet == 'rainfall' || $dataSet == 'evt') {
//	if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]);
    if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
} else {
    if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
}
//

//               if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);

Code: Select all

               if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]);
... and in the block above ....

Code: Select all

// now do overall month averages
    $tablelayout .= '<tr>';

// *** NEW for rain
if($dataSet == 'winddir') {
	$tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['dom'].'</th>';
} else {
	if($dataSet == 'rainfall' || $dataSet == 'evt') {
	    $tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['total'].'</th>';
	} else {
	    $tablelayout .= '<th class="topborder">'.$translit[$dayfileLang]['avg'].'</th>';
	}
}	
//
		
//    $tablelayout .=  '<th class="topborder">'.($dataSet == 'winddir' ? $translit[$dayfileLang]['dom'] : $translit[$dayfileLang]['avg']).'</th>';
    for ($m = 1; $m <= 12; $m++) {

Code: Select all

// now do overall month averages
    $tablelayout .= '<tr>';

    $tablelayout .=  '<th class="topborder">'.($dataSet == 'winddir' ? $translit[$dayfileLang]['dom'] : $translit[$dayfileLang]['avg']).'</th>';
    for ($m = 1; $m <= 12; $m++) {
Image
......................Imagine, what you will KNOW tomorrow !
Phil23
Posts: 884
Joined: Sat 16 Jul 2016 11:59 pm
Weather Station: Davis VP2+ & GW1000 (Standalone)
Operating System: Win10 Pro / rPi Buster
Location: Australia

Re: Yet Another Dayfile Reader (PHP)

Post by Phil23 »

beteljuice wrote: Mon 22 Jul 2019 9:31 am Put it back to the way it used to be ....
Head Spin @ 8:00pm Aus time. 2 Beers & a Rum make it hard to get the head around....
Sounds like a 5:00am challenge in another 9 hours time.

Cheers.
:Now: :Today/Yesterday:

Image

Main Station Davis VP2+ Running Via Win10 Pro.
Secondary Stations, Ecowitt HP2551/GW1000 Via rPi 3 & 4 Running Buster GUI.
:Local Inverell Ecowitt Station: :Remote Ashford Ecowitt Station:
Phil23
Posts: 884
Joined: Sat 16 Jul 2016 11:59 pm
Weather Station: Davis VP2+ & GW1000 (Standalone)
Operating System: Win10 Pro / rPi Buster
Location: Australia

Re: Yet Another Dayfile Reader (PHP)

Post by Phil23 »

Not sure I'm getting what you are saying.

If I put it back the way it was I will have totals in the bottom row.
Correct?

What I'm trying to do is have averages of the years in the bottom row, seems more logical than totals of the years....
Have got that to work, but just have the Sigma sign on that last row.

Excuse my ignorance; how the code works is taking a while to sink in.

Just the last Sigma on the bottom row.
Capture.JPG
You do not have the required permissions to view the files attached to this post.
:Now: :Today/Yesterday:

Image

Main Station Davis VP2+ Running Via Win10 Pro.
Secondary Stations, Ecowitt HP2551/GW1000 Via rPi 3 & 4 Running Buster GUI.
:Local Inverell Ecowitt Station: :Remote Ashford Ecowitt Station:
Phil23
Posts: 884
Joined: Sat 16 Jul 2016 11:59 pm
Weather Station: Davis VP2+ & GW1000 (Standalone)
Operating System: Win10 Pro / rPi Buster
Location: Australia

Re: Yet Another Dayfile Reader (PHP)

Post by Phil23 »

Looks good & is very informative on my historic data.

Perfect for comparing with our long term averages.

Hist1.JPG
Even more informative if I splice the live dayfile onto the end of the one in /historic.

Hist2.JPG

Just a shame I don't have EVT data back to 2011. Didn't have Solar & UV sensors for first 6 weeks of my VP2's life & none at all in the Fine Offset.
You do not have the required permissions to view the files attached to this post.
:Now: :Today/Yesterday:

Image

Main Station Davis VP2+ Running Via Win10 Pro.
Secondary Stations, Ecowitt HP2551/GW1000 Via rPi 3 & 4 Running Buster GUI.
:Local Inverell Ecowitt Station: :Remote Ashford Ecowitt Station:
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Yet Another Dayfile Reader (PHP)

Post by beteljuice »

@phil23 - How many rums was it ?

I gave you the bottom two blocks changes in the my previous post.

The one puts back to average values as a one-liner (where you have modified the expanded version)
The other does the same thing for Avg row 'title'

I'm half thinking of putting it in the 'distribution' as an option, but every post increases my despair :groan:
Image
......................Imagine, what you will KNOW tomorrow !
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Yet Another Dayfile Reader (PHP)

Post by beteljuice »

@all

Code snippet changed for rain / evt totals in year table with averages at bottom

viewtopic.php?f=14&t=11397&p=134978#p134978

See working example: http://beteljuice.co.uk/daytest/abasic7 ... a=rainfall

If there is a demand I will modify the distribution file with a hardcoded option of which display to use ...

Replies on a postcard please with your creditcard details :o
Image
......................Imagine, what you will KNOW tomorrow !
Phil23
Posts: 884
Joined: Sat 16 Jul 2016 11:59 pm
Weather Station: Davis VP2+ & GW1000 (Standalone)
Operating System: Win10 Pro / rPi Buster
Location: Australia

Re: Yet Another Dayfile Reader (PHP)

Post by Phil23 »

Latest code uploaded & looking fine.

Thanks for the mod to the code block.
beteljuice wrote: Mon 22 Jul 2019 10:52 pm Replies on a postcard please with your creditcard details :o
No Postcard required.
I freely give my CC number to Scammers on request, so happy to post it here.

5353 5218 6894 3961
Expires 11/2021
CCV 987.

If it doesn't work try 3916, or is it 9316,
Dunno, my eyes always fail me when I provide the numbers for them to email off to the dude with the EFT machine.....


Cheers.
:Now: :Today/Yesterday:

Image

Main Station Davis VP2+ Running Via Win10 Pro.
Secondary Stations, Ecowitt HP2551/GW1000 Via rPi 3 & 4 Running Buster GUI.
:Local Inverell Ecowitt Station: :Remote Ashford Ecowitt Station:
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Yet Another Dayfile Reader (PHP)

Post by beteljuice »

Dear Customer ...

Sorry to say your cc details don't pass our verification checks, but we can determine that the IIN of 535318 indicates that this card was issued by Commonwealth Bank Of Australia.

We feel sure that this was a mistake on your part and look forward to receiving the correct card number shortly.

If not the boys will be round ....

... or you can pass verification checks by ..... https://www.creditcardvalidator.org/generator :shock:
Image
......................Imagine, what you will KNOW tomorrow !
Phil23
Posts: 884
Joined: Sat 16 Jul 2016 11:59 pm
Weather Station: Davis VP2+ & GW1000 (Standalone)
Operating System: Win10 Pro / rPi Buster
Location: Australia

Re: Yet Another Dayfile Reader (PHP)

Post by Phil23 »

beteljuice wrote: Mon 22 Jul 2019 9:36 pm @phil23 - How many rums was it ?
Well,,,,,
2 Maybe & a bit of 9:00pm on a shovel.

I'm half thinking of putting it in the 'distribution' as an option, but every post increases my despair :groan:
Personally I think that's a good move, for both Rainfall and EVT.
Both the monthly totals & the Monthly Averages seem to be applicable for seeing how things have been & are now panning out.
:Now: :Today/Yesterday:

Image

Main Station Davis VP2+ Running Via Win10 Pro.
Secondary Stations, Ecowitt HP2551/GW1000 Via rPi 3 & 4 Running Buster GUI.
:Local Inverell Ecowitt Station: :Remote Ashford Ecowitt Station:
sutne
Posts: 372
Joined: Sun 14 Oct 2012 4:23 pm
Weather Station: HP2553 (WS80) and HP2564 (WS90)
Operating System: Raspbian Bullseye and Bookworm
Location: Rjoanddalen and Kronstad, Norway
Contact:

Re: Yet Another Dayfile Reader (PHP)

Post by sutne »

I would also like to have this in the main distribution, but is it possible to ask for more ?

Is it possible to add a column and have the year totals as well?
Post Reply