Almanac hours of daylight calc possible?

312 views
Skip to first unread message

Steve

unread,
Dec 29, 2013, 11:24:20 AM12/29/13
to weewx...@googlegroups.com
Hi all,

I was wondering if it is possible for the Almanac data to calculate and display hours of daylight?

i.e Sunset - Sunrise = hh:mm:ss and / or End Civil twilight - Start Civil twilight = hh:mm:ss

(What (to me) would even be better is if the daylight hh:mm:ss each day was somehow included in the DB so it could be graphed and viewed as a sine wave over a year / ramps up and down for month & week views, I guess it would just flat line in a daily view?).

It's interesting to me because I have a PV solar system on my roof too, and the weather plays a great deal with what it generates.

Regards,

Steve. 

Thomas Keffer

unread,
Dec 29, 2013, 3:43:51 PM12/29/13
to weewx-user
Hi, Steve

For hours of daylight, you could take the difference between sunset and sunrise (NOT TESTED):

  $lod = $($almanac.sun.set.raw - $almanac.sun.rise.raw)

This will be in seconds. 

To include this in the database you would have to do the calculation in a weewx service, then add it to the archive packet. Not a bad first Python / weewx project!

-tk




--
You received this message because you are subscribed to the Google Groups "Weewx user's group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Steve

unread,
Dec 29, 2013, 8:31:32 PM12/29/13
to weewx...@googlegroups.com
Thanks for the pointers Tom.

Time to get my hands dirty, I'll see how I go.

I've now got weewx running the simulator on a second RPi that I set up to play with.

Regards,

Steve.
Message has been deleted

Dave Webb KB1PVH

unread,
Feb 6, 2017, 10:18:47 AM2/6/17
to weewx...@googlegroups.com
Steve,

Something like I have on my page?



Dave-KB1PVH


Sent from my Galaxy S7

On Feb 6, 2017 10:15 AM, "WindnFog" <foc...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

WindnFog

unread,
Feb 6, 2017, 2:42:34 PM2/6/17
to weewx-user
Yes, although I didn't ask the original question.  How are you doing that, Dave?  Looks interesting.


On Monday, February 6, 2017 at 11:18:47 AM UTC-4, Dave Webb wrote:
Steve,

Something like I have on my page?



Dave-KB1PVH


Sent from my Galaxy S7
On Feb 6, 2017 10:15 AM, "WindnFog" <foc...@gmail.com> wrote:


On Sunday, December 29, 2013 at 12:24:20 PM UTC-4, Steve wrote:
Hi all,

I was wondering if it is possible for the Almanac data to calculate and display hours of daylight?

i.e Sunset - Sunrise = hh:mm:ss and / or End Civil twilight - Start Civil twilight = hh:mm:ss

(What (to me) would even be better is if the daylight hh:mm:ss each day was somehow included in the DB so it could be graphed and viewed as a sine wave over a year / ramps up and down for month & week views, I guess it would just flat line in a daily view?).

It's interesting to me because I have a PV solar system on my roof too, and the weather plays a great deal with what it generates.

Regards,

Steve. 

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout - private.

Dave Webb KB1PVH

unread,
Feb 6, 2017, 2:49:13 PM2/6/17
to weewx...@googlegroups.com
Put this somewhere in your index.html.tmpl

 #set $now = $current.dateTime.raw
            #set $yesterday = $now - 24*3600
            #set $today_daylight = $almanac.sun.set.raw -  $almanac.sun.rise.raw
            #set $yesterday_daylight = $almanac($almanac_time=$yesterday).sun.set.raw - $almanac($almanac_time=$yesterday).sun.rise.raw
            #set $difference = $today_daylight - $yesterday_daylight
            #set $seconds = $almanac.sun.set.raw - $almanac.sun.rise.raw
            #set $hours = $seconds //3600
            #set $seconds %= 3600
            #set $minutes = $seconds//60
            #set $seconds %= 60
            <p>$("Today has %d hours, %d minutes, and %d seconds of daylight" % ($hours, $minutes, $seconds)),<br/>
            #if $difference > 0
            $("%d seconds more than yesterday." % $difference)</p>
            #else
            $("%d seconds less than yesterday." % -$difference)</p>
            #end if
            #else

Dave-KB1PVH

To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Dunphy

unread,
Feb 6, 2017, 4:31:07 PM2/6/17
to weewx...@googlegroups.com
On 06/02/17 03:49 PM, Dave Webb KB1PVH wrote:
> Put this somewhere in your index.html.tmpl
>
> #set $now = $current.dateTime.raw
> #set $yesterday = $now - 24*3600
> #set $today_daylight = $almanac.sun.set.raw -
> $almanac.sun.rise.raw
> #set $yesterday_daylight =
> $almanac($almanac_time=$yesterday).sun.set.raw -
> $almanac($almanac_time=$yesterday).sun.rise.raw
> #set $difference = $today_daylight - $yesterday_daylight
> #set $seconds = $almanac.sun.set.raw - $almanac.sun.rise.raw
> #set $hours = $seconds //3600
> #set $seconds %= 3600
> #set $minutes = $seconds//60
> #set $seconds %= 60
> <p>$("Today has %d hours, %d minutes, and %d seconds of daylight" %
> ($hours, $minutes, $seconds)),<br/>
> #if $difference > 0
> $("%d seconds more than yesterday." % $difference)</p>
> #else
> $("%d seconds less than yesterday." % -$difference)</p>
> #end if
> #else
>
> Dave-KB1PVH

Thanks, Dave! Exactly what I wanted. I had to get rid of the
final #else so cheetahgenerator wouldn't complain, but I think that's a
function of where I put it.

<http://www.ve1dx.net/>

73, Paul VE1DX

Ruben Navarro Huedo

unread,
Feb 9, 2017, 8:29:41 AM2/9/17
to weewx-user
A lot of thanks for info Dave

I tried add forecast to my weewx website but using includes all tables were incorrectly formatted.

How did you insert forecast in the main page?

73 de EA5BZ

Dave Webb KB1PVH

unread,
Feb 9, 2017, 8:34:05 AM2/9/17
to weewx...@googlegroups.com
Ruben,

I use the widget from here.



Dave-KB1PVH


Sent from my Galaxy S7

Ruben Navarro Huedo

unread,
Feb 9, 2017, 9:15:04 AM2/9/17
to weewx-user
A lot of thank's.

I have tried to add your code to calculate hours of daylight but weewx doesn't show in my web site :-(



El jueves, 9 de febrero de 2017, 14:34:05 (UTC+1), Dave Webb escribió:
Ruben,

I use the widget from here.

http://blog.darksky.net/forecast-embeds/

Dave-KB1PVH


Sent from my Galaxy S7
On Feb 9, 2017 8:29 AM, "Ruben Navarro Huedo" <run...@gmail.com> wrote:
A lot of thanks for info Dave

I tried add forecast to my weewx website but using includes all tables were incorrectly formatted.

How did you insert forecast in the main page?

73 de EA5BZ

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Dave Webb KB1PVH

unread,
Feb 9, 2017, 9:19:09 AM2/9/17
to weewx...@googlegroups.com
Ruben,

 I will copy a bigger portion of the index.html.tmpl shortly so you can see exactly where I put it. 


Dave-KB1PVH


Sent from my Galaxy S7
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.

Dave Webb KB1PVH

unread,
Feb 9, 2017, 9:34:07 AM2/9/17
to weewx...@googlegroups.com
Ruben,

 Below is a larger portion of my index.html so you can see placement.


  #else
                <tr>
                  <td class="label">New moon:</td>
                  <td class="data">$almanac.next_new_moon</td>
                </tr>
                <tr>
                  <td class="label">Full moon:</td>
                  <td class="data">$almanac.next_full_moon</td>
                </tr>
                #end if
                <tr>
                  <td class="label">Phase:</td>
                  <td class="data">$almanac.moon_phase<br/>($almanac.moon_fullness% illuminated)</td>
                </tr>
              </table>
            </div> <!-- end class "celestial_body" -->
            #set $now = $current.dateTime.raw
            #set $yesterday = $now - 24*3600
            #set $today_daylight = $almanac.sun.set.raw -  $almanac.sun.rise.raw
            #set $yesterday_daylight = $almanac($almanac_time=$yesterday).sun.set.raw - $almanac($almanac_time=$yesterday).sun.rise.raw
            #set $difference = $today_daylight - $yesterday_daylight
            #set $seconds = $almanac.sun.set.raw - $almanac.sun.rise.raw
            #set $hours = $seconds //3600
            #set $seconds %= 3600
            #set $minutes = $seconds//60
            #set $seconds %= 60
            <p>$("Today has %d hours, %d minutes, and %d seconds of daylight" % ($hours, $minutes, $seconds)),<br/>
            #if $difference > 0
            $("%d seconds more than yesterday." % $difference)</p>
            #else
            $("%d seconds less than yesterday." % -$difference)</p>
            #end if
            #else
            ## No extended almanac information available. Fall back to a simple table.
            <table>
              <tr>
                <td class="label">Sunrise:</td>
                <td class="data">$almanac.sunrise</td>
              </tr>
              <tr>
                <td class="label">Sunset:</td>
                <td class="data">$almanac.sunset</td>
              </tr>
              <tr>
                <td class="label">Moon Phase:</td>


You can also read this thread



Dave-KB1PVH

Ruben Navarro Huedo

unread,
Feb 9, 2017, 9:51:16 AM2/9/17
to weewx-user
Running now Dave.

Problem was i hadn't extended almanac.

Using this topic i could add it:
https://groups.google.com/forum/#!topic/weewx-user/xViPKlo6ToE

Now all fine: http://meteoelche.es

Thank's a lot.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages