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 4017) - 17 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

AnnualDataSummary PHP

Discussion and support for 3rd-party (non-Sandaysoft) tools for Cumulus
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: AnnualDataSummary PHP

Post by BCJKiwi »

Thanks for your ongoing assistance.

Unfortunately there seems tobe some problem with the attachment as is seems not to contain any usable data, Would you please re-attach the file.

Have attached the full file set so you can check out anything else that may be introducing the errors.
Thanks
You do not have the required permissions to view the files attached to this post.
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: AnnualDataSummary PHP

Post by sfws »

Apologies, I did make a mistake when attaching earlier. The zipped file got stored in a place I did not find when zipping and it picked up file pointer instead of actual file.
Believe now have correct file attached to my previous posting.
Will look at your attachments, and respond as I find necessary.
Incidentally, when you get min/max temp working you might be inspired to try rain daily (or high hourly)/rate combination, or low/high humidity combination, or low/high apparent temperature combination. See https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=6640 for what I selected.
Last edited by sfws on Tue 13 Nov 2012 9:22 pm, edited 1 time in total.
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: AnnualDataSummary PHP

Post by sfws »

My first read through your code suggests that the changes I've suggested to eliminate colspan="2" will correct all the 21 HTML validation errors.

-----------------------------------------------------------------------------------------------------

Code: Select all

// set the class for 0 values if rain or wind (or anything else that can have) has a 0 value
				if (array_key_exists($id, $data)) {
					$data_arr = explode('|', $data[$id]);
	 				if (
/*
($whatdata =='mintemp' || $whatdata =='dayrain' || $whatdata =='loaptmp' || $whatdata =='lodew' || $whatdata =='minwchl' || $whatdata =='hourain' || $whatdata =='rainrate' || $whatdata =='windgust') && (
// all the above parameters can be left out of IF test, just need to test for zero value
*/
floatval(str_replace(',','.',$data_arr[0])) == 0
// remove extra bracket now only 1 condition
/* ) */
){
					$tablelayout .= ' zerovalue';
					}
In passing, if you want all zero values to have the class 'zerovalue', you do not need to list the possible parameters (as indicated by commenting out above).
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: AnnualDataSummary PHP

Post by BCJKiwi »

Thanks very much - success!!

Had to make a few additional changes;
1. this code replicated what was above and produced two header rows with month labels.

Code: Select all

$tablelayout .= "<table>";
$tablelayout .= "<tr>";
$tablelayout .= '<th id="table_year">' . $year_list . '</th>';
and so was removed.
2. this line was not needed as the concatenation was already being achieved later within the function readDayfile(.... and the additional / produced an extra / in every datacell including the empty ones

Code: Select all

$tablelayout .= '/'; /*  concatenate separator for two values */
3. but did change the later concatenation code within the function readDayfile(....

Code: Select all

from
$data[$id] =  '|'. $buf_arr[$dayfilecol] .'/'. $buf_arr[$dayfilecol2];
to
$data[$id] = $buf_arr[$dayfilecol] .'/'. $buf_arr[$dayfilecol2];
even though it displayed OK without this last change.
4. Also made the suggested zerovalue changes but found that in minmaxt, if the min was 0 then both min and max were dimmed. So changed that code to

Code: Select all

if ($whatdata !=='minmaxt' && (floatval(str_replace(',','.',$data_arr[0])) == 0))
which seems to work OK.
5. Also changed the datasummary.css so the month labels at the top of the columns are centered over the data to match the data which was already centered. reverted as teh day numbers were also centered!

Let me know what you think. Will look at the other options for concatenation however there are more than enough data items now so could replace two data items (hi and low) with one data item (hi/lo).

Thanks again
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: AnnualDataSummary PHP

Post by sfws »

BCJKiwi wrote:Let me know what you think. Will look at the other options for concatenation however there are more than enough data items now so could replace two data items (hi and low) with one data item (hi/lo).
Congratulations. All is perfect. (Personally, I would either use low and high or min and max, not mix both in parameter selectors and title for table).
My previous suggestion meant, if you wanted to carry on tinkering, you could reduce your parameter selectors by combining other low/high pairs. (I guess DAJ original included separate and combined min/max temperature just to demonstrate the options).

(Sorry I made you double up the header and slash, my posted code intentionally included the header to show whole table, at the time I did not have your complete code to mirror or edit that).

I learnt something new from you too. Early in the year when I designed my web templates, I typed out url in full on each page (with some typos initially) for the HTML validator, now I know I can type 'referer':

Code: Select all

<a href="http://validator.w3.org/check?uri=referer">Valid HTML</a>
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: AnnualDataSummary PHP

Post by BCJKiwi »

Yes I'll have a think about combining some of the those data items into comparisons. Should be able to present the same info in a more concise manner and make it more meaningful at the same time.

How do we go about getting this updated and error free code into a place/form that others can use without them having to go through all this drama again?

Thinking of maybe two versions - a minimal version that matches the data points of the orginal - well at least no more than one line of selection buttons, and, a second with all the fields that make sense with as many comaprisons along the style of the min/max.

Once I've had a rest I'll sort out an alternate with the more compact dual data layout where practical and see what the outcome looks like.

Thanks again for all your help.
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: AnnualDataSummary PHP

Post by steve »

BCJKiwi wrote:How do we go about getting this updated and error free code into a place/form that others can use
Putting it into the wiki would make most sense.
Steve
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: AnnualDataSummary PHP

Post by BCJKiwi »

@ Steve - Well I did think that is where it should end up but I can't put it there hence the Q.

@ sfws - Have an alternate page on the site now along the lines of what was discussed regarding hi/lo vlaues on the one calendar.
Any constructive comments (from anyone) welcome.
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: AnnualDataSummary PHP

Post by steve »

BCJKiwi wrote:@ Steve - Well I did think that is where it should end up but I can't put it there hence the Q.
Ah - is there a problem with the registration process? I did wonder if it was still working.
Steve
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: AnnualDataSummary PHP

Post by sfws »

BCJKiwi wrote: 4. Also made the suggested zerovalue changes but found that in minmaxt, if the min was 0 then both min and max were dimmed. So changed that code to

Code: Select all

if ($whatdata !=='minmaxt' && (floatval(str_replace(',','.',$data_arr[0])) == 0))
which seems to work OK.

Code: Select all

if ($dayfilecol2 =0 && (floatval(str_replace(',','.',$data_arr[0])) == 0))
is better coding practice i.e. test the general not the specific.
Not sure if you worked that out for yourself in latest page.
@ sfws - Have an alternate page on the site now along the lines of what was discussed regarding hi/lo vlaues on the one calendar.
Any constructive comments (from anyone) welcome.
I would say the new page is easier to cope with, basically because you have fewer parameters to work through to see all information available. Being perdantic, I think the title in the screen shot needs
Capture.zip
to still say 'Highest Hourly' or similar.
You do not have the required permissions to view the files attached to this post.
Last edited by sfws on Mon 19 Nov 2012 12:02 pm, edited 1 time in total.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: AnnualDataSummary PHP

Post by BCJKiwi »

Testing philosophy;
I agree in principle. The current test is

Code: Select all

if ($whatdata =='rainrate' && (floatval(str_replace(',','.',$data_arr[0])) == 0))
as rainrate is now the only dataset I could see that it made sense for. Once there are two datasets in the one field, if either is 0 then both become dimmed so it is not appropriate to apply the replacement to all datasets.

Have reworked the calendar titles. With combined data it is not quite so straight forward. For example, daily rain is daily rain, not highest or lowest, however hourly rain is the highest for the same day.

Have included the rollover fix and inserted notes in the code to show what is required for the Saratoga template setup which uses the CUtagsT.txt in Cumulus and sends that to the website as CUtags.php . The code works to achieve what you have indicated but not sure how to test it - any suggestions?

The css file has no colour changes from DAJ's v1.1 but does have some other changes - all noted in the file.

Have attached the current file set so whoever handles 'scrutineering' and adding to the wiki can take it from here. removed - see updated version in later post (only minor changes)
Last edited by BCJKiwi on Fri 16 Nov 2012 1:09 pm, edited 1 time in total.
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: AnnualDataSummary PHP

Post by sfws »

The advantage of using two columns for 'twin' parameters is that one can be coloured or otherwise made to look different for zero or high values, without affecting the other. That is why in my own web page design for these daily summaries I stuck to that.
Daily Summary close up for rain Nov 2012.JPG
In your case, you have caused yourself problems by concatenation

Code: Select all

					if ($dayfilecol2==0) {
						$data[$id] = $buf_arr[$dayfilecol];
					}
					else
					{
						$data[$id] = $buf_arr[$dayfilecol] .'/'. $buf_arr[$dayfilecol2];
					}
being done before you test for zero and high values.
If you keep the two values separate until after you do the test

Code: Select all

// set the class for 0 values if rain or wind (or anything else that can have) has a 0 value
				if (array_key_exists($id, $data)) {
					$data_arr = explode('|', $data[$id]);
	 				if ($whatdata =='rainrate' && (floatval(str_replace(',','.',$data_arr[0])) == 0))
	 				{
					$tablelayout .= ' zerovalue';
					}
// set a class for high temperature values
					if (($whatdata == 'hilotemp') && (floatval(str_replace(',','.',$data_arr[0])) >= 23)) {
						$tablelayout .= ' highvalue';
					}
				}
and then combine, as per my earlier code extract:

Code: Select all

$tablelayout .= '/'; /*  concatenate separator for two values */
(and surrounding lines) then you can use

Code: Select all

<span class="zerovalue">
</span>
round the value that is zero, to just colour that. Similarly for high values. Remember you may need to test both the minimum and the maximum figures in the pair, especially if you want your code to cover conditions possible all round the world - here in UK we can have negative values and exceptionally high values all within the same 24 hours.
It is past UK bedtime for me, so I won't write all the code out! See if this is enough for you to solve, otherwise I will see when I get some time.
Hi
Have discovered the .zerovalue problem also applies to .highvalue.
i.e. if there are two values concatenated in the one data cell, then if either value is zero, then both values are changed as the change applies to the datacell via $tablelayout, not to the actual data.

Unfortunately, this is beyond me.
I have looked at the style sheet and the program flow but within the construct being used, am unable to see how to apply a style to the specific text.

So before publishing this new version, we should either resolve this, or remove the feature.

Thanks
_________________
BCJKiwi
You do not have the required permissions to view the files attached to this post.
Last edited by sfws on Fri 16 Nov 2012 9:22 am, edited 1 time in total.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: AnnualDataSummary PHP

Post by BCJKiwi »

There is an issue with your method of placement of the concatenation as described before (and retested this morning).
a / appears in every field, including those with no data at all, hence my reverting to my earlier approach.

Will have another look at your other post.

Thanks
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: AnnualDataSummary PHP

Post by BCJKiwi »

steve wrote:Ah - is there a problem with the registration process? I did wonder if it was still working.
Steve,
Sorry, I was focused on sorting the script and now realise I missed your post entirely.
I have had another look at the Wiki and it seems a separate login for the wiki is required so have requested one. Have received an acknlowledgement and email confirmation link but no password yet.

I had assumed there would be some sort of script vetting process, and that it would not be good form to just edit someone else's data, however I guess that is the nature of a wiki so will give it a go.

Have found another minor glitch in the code to do with the concatenated data which I am trying to sort out so will not update the wiki until that is sorted.
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: AnnualDataSummary PHP

Post by sfws »

BCJKiwi wrote:a / appears in every field, including those with no data at all, hence my reverting to my earlier approach.
Simply, bypass all the value handling code if no data, by having concatenation within:

Code: Select all

if (array_key_exists($id, $data)) {
Post Reply