--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/e4b49519-f227-4cfa-9151-7a3aafccc813%40googlegroups.com.
I'm not sure what you mean by "show this value in numbers." Do you mean formatting the value as "4:15 h", versus "4.25"?-tk
On Mon, Jul 22, 2019 at 2:50 AM Stefan Schnidrig <sschn...@bluewin.ch> wrote:
--Hello everybody.I have found this link (https://github.com/brewster76/util-archer/blob/master/user/radiationhours.py) where is described how to display the sunshine time. Now I would like to show this value in numbers (eg 4:15 h). Is that possible?
Thank you
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...@googlegroups.com.
$current.sunshine_hours.raw
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/5dfbcab1-9b7a-4b0c-9048-8a9add486ce9%40googlegroups.com.
If you just want the raw number, use the "raw" suffix:$current.sunshine_hours.raw-tk
On Mon, Jul 22, 2019 at 5:48 AM Stefan Schnidrig <sschn...@bluewin.ch> wrote:
Hello Thomas.--
Thanks for your message. No. I would like to use the solar sensor to display the sunshine time. But I want that in numbers, so I can put it in my xml.
Thank you
Am Montag, 22. Juli 2019 13:47:39 UTC+2 schrieb Thomas Keffer:I'm not sure what you mean by "show this value in numbers." Do you mean formatting the value as "4:15 h", versus "4.25"?-tkOn Mon, Jul 22, 2019 at 2:50 AM Stefan Schnidrig <sschn...@bluewin.ch> wrote:--Hello everybody.I have found this link (https://github.com/brewster76/util-archer/blob/master/user/radiationhours.py) where is described how to display the sunshine time. Now I would like to show this value in numbers (eg 4:15 h). Is that possible?
Thank you
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/e4b49519-f227-4cfa-9151-7a3aafccc813%40googlegroups.com.
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/5dfbcab1-9b7a-4b0c-9048-8a9add486ce9%40googlegroups.com.
If you just want the raw number, use the "raw" suffix:$current.sunshine_hours.raw-tk
On Mon, Jul 22, 2019 at 5:48 AM Stefan Schnidrig <sschn...@bluewin.ch> wrote:
Hello Thomas.--
Thanks for your message. No. I would like to use the solar sensor to display the sunshine time. But I want that in numbers, so I can put it in my xml.
Thank you
Am Montag, 22. Juli 2019 13:47:39 UTC+2 schrieb Thomas Keffer:I'm not sure what you mean by "show this value in numbers." Do you mean formatting the value as "4:15 h", versus "4.25"?-tkOn Mon, Jul 22, 2019 at 2:50 AM Stefan Schnidrig <sschn...@bluewin.ch> wrote:--Hello everybody.I have found this link (https://github.com/brewster76/util-archer/blob/master/user/radiationhours.py) where is described how to display the sunshine time. Now I would like to show this value in numbers (eg 4:15 h). Is that possible?
Thank you
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/e4b49519-f227-4cfa-9151-7a3aafccc813%40googlegroups.com.
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/5dfbcab1-9b7a-4b0c-9048-8a9add486ce9%40googlegroups.com.
#set hours = int($current.sunshine_hours.raw)#set minutes = int(($current.sunshine_hours.raw - $hours)*60 + 0.5)<sun value="$hours h $minutes m"/>
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/06eb2e2b-bc53-4bc1-8e67-515a2094cdf6%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/06eb2e2b-bc53-4bc1-8e67-515a2094cdf6%40googlegroups.com.
Hello
@Andrew
If I enter day.sunshine_hours.raw, then I get an error message.
@Thomas
Excuse the stupid question, but where should I paste? In my xml that will not work?
Thanks for your inputsTo view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/06eb2e2b-bc53-4bc1-8e67-515a2094cdf6%40googlegroups.com.
Now it would be great if you had the day, not 24 hours. Then you would always have the daily value.
Thanks!
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/06eb2e2b-bc53-4bc1-8e67-515a2094cdf6%40googlegroups.com.
#set hours = int($current.sunshine_hours.raw)#set minutes = int(($current.sunshine_hours.raw - $hours)*60 + 0.5)<sun value="$hours h $minutes m"/>
Gary
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/5ddf5a22-a565-4e12-9093-5c69d187e420%40googlegroups.com.
On looking at those instructions again there is no mention of rebuilding the daily summaries after changing the schema. You might want to try stopping WeeWX then using wee_database with the --rebuild_daily action (http://weewx.com/docs/utilities.htm#wee_database utility)
Gary
The type "sunshine_hours" is not in your database. It will work with "$current" because you have a current record, so weewx is using that. But, because it is not in your database, weewx cannot sum over the day.See the section Adding a new type to the database in the Customizing Guide for how to do this.-tk
On Tue, Jul 23, 2019 at 4:00 AM Stefan <sschn...@bluewin.ch> wrote:
--This is with $current.sunshine_hours.raw. It works!<solar><solar value="861"/><solar_max value="861"/><solar_max_time value="12:51"/><sun value="0.0833333333333"/></solar>But with $day.sunshine_hours.raw or $day.sunshine_hours.sum.raw or $day.sunshine_hours.raw.sumThe Problem always turns up when replacing $current by $day.Am Dienstag, 23. Juli 2019 08:35:37 UTC+2 schrieb gjr80:The answer is in the error message. You are using $day.sunshine_hours.raw, you should be using $day.sunshine_hours.sum or perhaps $day.sunshine_hours.sum.rawGary
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...@googlegroups.com.

Gary
Hello Gary.
Yes I know that. That does not bother me either. I want to change the color of the bars. Can I do that somehow? These should appear in yellow.
ThanksGary
|
|
| import weewx |
| from weewx.wxengine import StdService |
|
|
| class RadiationHours(StdService): |
| def __init__(self, engine, config_dict): |
| # Pass the initialization information on to my superclass: |
| super(RadiationHours, self).__init__(engine, config_dict) |
|
|
| # Default threshold value is 120 W/m2 |
| import syslog |
Gary
syslog.syslog(syslog.LOG_DEBUG, "Calculated sunshine_hours = %f, based on radiation = %f, and min_sunshine = %f" %syslog.syslog(syslog.LOG_DEBUG, "Calculated sunshine_hours = %f, based on radiation = %s, and min_sunshine = %f" %"""
Adds a new observation field to weewx: [sunshine_time]
Installation:
1. Save this file to your user customisations directory (which is often /usr/share/weewx/user)
2. Enable this service in weewx.conf by adding user.sunduration.SunshineDuration to the process_services list.
[Engine]
[[Services]]
# This section specifies the services that should be run. They are
# grouped by type, and the order of services within each group
# determines the order in which the services will be run.
prep_services = weewx.engine.StdTimeSynch
process_services = user.sunduration.SunshineDuration, weewx.engine.StdConvert, weewx.engine.StdCalibrate, weewx.engine.StdQC, weewx.wxservices.StdWXCalculate
3. Add [sunshine_time] to the database schema so tables include this new observation field.
In weewx.conf, change the wx_binding schema from schemas.wview.schema to user.sunduration.schema_with_sunshine_time
[DataBindings]
[[wx_binding]]
# The database must match one of the sections in [Databases].
# This is likely to be the only option you would want to change.
database = archive_sqlite
# The name of the table within the database
table_name = archive
# The manager handles aggregation of data for historical summaries
manager = weewx.wxmanager.WXDaySummaryManager
# The schema defines the structure of the database.
# It is *only* used when the database is created.
#schema = schemas.wview.schema
schema = user.sunduration.schema_with_sunshine_time
4. Shutdown Weewx and update your database to bring in the new field.
wee_database weewx.conf --reconfigure
Make sure you know what you're doing at this point, you can potentially corrupt/lose your archive data.
The weewx customization guide covers this in a lot more detail.
5. Tell Weewx about the units for this new type
Add this to user/extensions.py:
#
# Units for sunshine_days calculated field
#
import weewx.units
weewx.units.obs_group_dict['sunshine_time'] = 'group_interval'
6. Use [sunshine_time] in your graphs and html template tags.
Lots more detail on this process can be found here:
http://www.weewx.com/docs/customizing.htm#Adding_a_new_observation_type
"""
import syslog
from math import sin,cos,pi,asin
from datetime import datetime
import time
import weewx
from weewx.wxengine import StdService
import schemas.wview
class SunshineDuration(StdService):
def __init__(self, engine, config_dict):
# Pass the initialization information on to my superclass:
super(SunshineDuration, self).__init__(engine, config_dict)
# Start intercepting events:
self.bind(weewx.NEW_ARCHIVE_RECORD, self.newArchiveRecord)
def newArchiveRecord(self, event):
"""Gets called on a new archive record event."""
seuil = 0
tempe = float(event.record.get('outTemp'))
radiation = event.record.get('radiation')
event.record['sunshine_time'] = 0.0
if radiation is not None:
utcdate = datetime.utcfromtimestamp(event.record.get('dateTime'))
dayofyear = int(time.strftime("%j",time.gmtime(event.record.get('dateTime'))))
theta = 360 * dayofyear / 365
equatemps = 0.0172 + 0.4281 * cos((pi / 180) * theta) - 7.3515 * sin(
(pi / 180) * theta) - 3.3495 * cos(2 * (pi / 180) * theta) - 9.3619 * sin(
2 * (pi / 180) * theta)
latitude= float(self.config_dict["Station"]["latitude"])
longitude = float(self.config_dict["Station"]["longitude"])
corrtemps = longitude * 4
declinaison = asin(0.006918 - 0.399912 * cos((pi / 180) * theta) + 0.070257 * sin(
(pi / 180) * theta) - 0.006758 * cos(2 * (pi / 180) * theta) + 0.000908 * sin(
2 * (pi / 180) * theta)) * (180 / pi)
minutesjour = utcdate.hour*60 + utcdate.minute
tempsolaire = (minutesjour + corrtemps + equatemps) / 60
angle_horaire = (tempsolaire - 12) * 15
hauteur_soleil = asin(sin((pi / 180) * latitude) * sin((pi / 180) * declinaison) + cos(
(pi / 180) * latitude) * cos((pi / 180) * declinaison) * cos((pi / 180) * angle_horaire)) * (180 / pi)
if hauteur_soleil > 3:
seuil = (0.73 + 0.06 * cos((pi / 180) * 360 * dayofyear / 365)) *1080 * pow((sin(pi / 180) * hauteur_soleil), 1.25) * 0.90
mesure = (((tempe * 1 - 25) * (-0.0012) * radiation) + radiation)
if mesure > seuil:
event.record['sunshine_time'] = event.record['interval']
syslog.syslog(syslog.LOG_DEBUG, "Calculated sunshine_time = %f, based on radiation = %f, and threshold = %f" %
(event.record['sunshine_time'], radiation, seuil))
schema_with_sunshine_time = schemas.wview.schema + [('sunshine_time', 'REAL')]
Hello everybody
I have a question about graphic design. I would like to include the sunshine time in the graphics. Currently the value of 0.08 in sunshine always appears there. This is my current code in use.
[[chart6]]
title = Sonnenschein
# Make sure the y-axis increment is at least 0.02 for the sun plot
yscale = 0.0, 1.0, 0.1
type = column
[[[sunshine_hours]]]
aggregate_type = sum
aggregate_interval = 300
color = "#e4d354"
name = Sonnenschein in Minuten
I would like to do this now, because the interval 300s is 5min as sunshine. Can one make it like this?
Many thanks for your helpUnfortunately I haven't been able to solve the problem yet. I still have the problem that I want to include the sunshine time in my solar graphics. The value 0.08 is always given instead of 5min. How can you adjust that?Hi there.
I have recently taken the template for the hours of sunshine from the example under. Now I have noticed that my sunshine time in the xml is no longer correct. I think it's because of the conversion?
The Result:
<solar>
<solar value="831"/>
<solar_max value="877"/>
<solar_max_time value="11:39"/>
<sun_unformatted value="135.0"/>
<sun value="135 h 0 m"/>
</solar>
The Code:
<solar value="$current.radiation.formatted"/>
<solar_max value="$day.radiation.max.formatted"/>
<solar_max_time value="$day.radiation.maxtime.format("%H:%M")"/>
<sun_unformatted value="day.sunshine_hours.sum.raw"/>
#set hours = int($day.sunshine_hours.sum.raw)
#set minutes = int(($day.sunshine_hours.sum.raw - $hours)*60 + 0.5)
<sun value="$hours h $minutes m"/>
It is also said to divide the 130 minutes into hours and minutes. That means doing it with the existing code, but unfortunately it doesn't work anymore. Can someone help me?
#set hours = int($day.sunshine_hours.sum.raw/60)
#set minutes = $day.sunshine_hours.sum.raw - ($hours*60)
With a daily sum of 135 minutes , this give:
hours = int(135/60) = 2
minutes = 135-(2*60)= 15
So
<sun value="$hours h $minutes m"/> should give now 2 h 15 m
if mesure > seuil:
event.record['sunshine_time'] = event.record['interval']/60
A coming point now appears at the minutes, which should not be there. How can I remove it?#set minutes = int($day.sunshine_hours.sum.raw - ($hours*60))
I have another question. Is it possible that the entire database can now be run once in order to have the hours of sun generated by the past? The graphics are not up to date right now because the 5min sun was displayed as 0.8 before renewal.