Author Topic: A variation on the 'Sun Pie' script - High Noon  (Read 761 times)

0 Members and 1 Guest are viewing this topic.

Offline Cienega32

  • Forecaster
  • *****
  • Posts: 2635
    • East Mesa Weather
A variation on the 'Sun Pie' script - High Noon
« on: December 02, 2013, 07:38:28 AM »
I really like the 3D Sun Pie but it just didn't fit well in my older Alternate Dashboard.

After some nip & tucks, I ended up with a variation that did with a little less text. It gives me what I need in total daylight and an option to include the percent of daylight (show_pct). Like the MoonPhase graphic, a mouse-over will display info (changeinday)

The thing I mainly wanted was to display the beginning of the day slice (sunrise) in an accurate representation on a 24 hour circle that being with 6AM at the 9 o'clock and 6PM at the 3 o'clock positions on the disc. I wanted a High Noon graphic.

It didn't look too swift in 3D so 2D it was for me. It's a simple looking display but provides what I wanted.

Display snip is how it looks on www.lascruces-weather.com (with its older version of the Alternate Dashboard)

Code: [Select]
<!-- *** BEGIN Total Daylight Hours ***  -->
          <td rowspan="3" valign="middle" align="center">
<?php
// Another version of the original Sun Pie script
// Uses a 2D Pie, less text and a mouse-over for $changeinday
// Make piechart
$testtime substr($hoursofpossibledaylight,0,2);
$testminute substr($hoursofpossibledaylight,3,2);
$testminute $testminute/60;
$testresult $testtime+$testminute;
$testljus round(($testresult/24)*100,1);
$testmorker 100-$testljus;
$time_arr explode(':'$hoursofpossibledaylight2);
$suntime = (int)$time_arr[0] . " hrs " . (int)$time_arr[1] . " min";
$time_arr explode(':'$changeinday);
if (
substr($time_arr[0],0,1) != "-") {  // -0 when getting shorter
// Only report seconds if less than 1 minute
    
if ((int)$time_arr[1]<1){
        
$sunchange $time_arr[2] . " seconds more than yesterday";
        } else {
        
$sunchange = (int)$time_arr[1] . " min " $time_arr[2] . " seconds more than yesterday";
        }
} else {
    if ((int)
$time_arr[1]<1){
        
$sunchange $time_arr[2] . " seconds less than yesterday";
        } else {
        
$sunchange = (int)$time_arr[1] . " min " $time_arr[2] . " seconds less than yesterday";
        }
}

// ******************* High Noon *******************
   
$show_pct '1'// Add the daily percentage Daytime to 'Total Hours' display
   
if ($show_pct == '1'){
       
$show_suntime $suntime '~' $testljus "%";
       }else{
$show_suntime $suntime;
   }
   
$zulurads 1.5708// Google circle starts at 3 o'clock. Midnight would be at the 6 o'clock position
   
$rise_time explode(':',$sunrise) ;
   
$rise_h $rise_time[0];
   
$rise_m explode(' ',$rise_time[1]);
   
$rise_minutes = ($rise_h*60)+$rise_m[0]; // Sunrise time in minutes past midnite
   
$sunrise_rads deg2rad(.25*$rise_minutes)+$zulurads ;

// *************************************************
// chp=$sunrise_rads in  <img src=  call to Google charts
// Better displayed with  cht=p rather than the 3D call of   cht=p3
// Change 'white' background with  chf=bg,s,white&amp;
// Change the '444444' to '000000' for pure black. All 6 numbers being the same (0 to F) grayscales 'Nite time'
// Edit the <img src= line to be one line. IT'S SPLIT ONLY FOR CLARITY
// Moved $sunchange info to 'title' for mouse hover
// *************************************************
?>


<table border="0" cellpadding="1" cellspacing="2">
  <tr>
    <td class="data1" style="text-align:center; border:none;">
      <span style="font-weight:lighter; font-size:9px;">Total Daylight:</span>
    </td>
  </tr>
  <tr>
    <td class="data1" >
     <img src="http://chart.apis.google.com/chart?chs=84x90&amp;chma=0,0,0,0|0,0&amp;chd=t:<?php echo $testljus;?>,<?php echo $testmorker;?>&amp;cht=p&amp;chp=<?php echo $sunrise_rads;?>&amp;chf=bg,s,white&amp;chtt=<?php echo $show_suntime;?>&amp;chts=000000,9,c&amp;chco=FFD700,444444" alt="Sun graph" title="<?php echo $sunchange;?>"></img>
<!-- This is only commented out to use in my older Alternate Dashboard
    </td>
  </tr>
</table>
-->
          </td>
<!--  *** END Total Daylight Hours ***  -->

Pat ~ Davis VP2 6153-Weatherlink-Weather Display-StartWatch-VirtualVP-Win7 Pro-64bit
www.LasCruces-Weather.com   www.EastMesaWeather.com

Offline Cienega32

  • Forecaster
  • *****
  • Posts: 2635
    • East Mesa Weather
Re: A variation on the 'Sun Pie' script - High Noon
« Reply #1 on: December 27, 2013, 07:44:08 AM »
Redone.

Pat ~ Davis VP2 6153-Weatherlink-Weather Display-StartWatch-VirtualVP-Win7 Pro-64bit
www.LasCruces-Weather.com   www.EastMesaWeather.com

 

anything