Hallo Hartmut,

Zuerst entschuldige ich mich für meinen armen Google Übersetzer Deutsch, 
ich hoffe du verstehst mich.

Wenn ich Ihren Beitrag richtig verstehe, möchten Sie in der Lage sein, die 
Anzahl der Tage in einem Zeitraum (z. B. einen Monat oder ein Jahr usw.) zu 
bestimmen, in denen die maximale outTemp weniger als 0 oder die Anzahl der 
Tage in einem Zeitraum war war kleiner als 0. Anstatt jeden weeWX-WD-Code 
anzupassen, wären die eingebauten Max_le- und Min_le-Aggregate viel 
einfacher. Diese Aggregate werden nicht oft verwendet und sind den meisten 
Benutzern wahrscheinlich nicht bekannt. Zum Beispiel würde die Anzahl der 
Tage in diesem Jahr, an denen die minimale outTemp weniger als 0 war, mit 
dem Tag zurückgegeben:

$year.outTemp.min_le((0, "degree_C"))

Ähnlich das Tag:

$month.outTemp.max_le((0, "degree_C"))

würde die Anzahl der Tage in diesem Monat angeben, an denen das 
outTemp-Maximum weniger als 0C betrug.

Wenn Sie sich die Vorlage skins/Standard/NOAA/NOAA-YYYY.txt.tmpl ansehen, 
werden diese Aggregate (und einige andere, zB max_ge, min_ge und sum_ge) in 
einer Vorlage verwendet. Eine Liste der verfügbaren Aggregate finden Sie im 
Anhang Aggregatentypen Anhang 
<http://weewx.com/docs/customizing.htm#aggregation_types> zum Customization 
Guide.

Natürlich, wenn Sie möchten, dass ich Ihren Code als Lernübung für Sie 
analysiere, kann ich das tun, aber dafür brauche ich mehr Zeit.

Hello Hartmut,

First, my apologies for my poor Google Translate German, I hope you can 
understand me.

If I understand your post correctly you would like to be able to determine 
the number of days in a period (say a month or a year etc) where the 
maximum outTemp was less than 0 or the number of days in a period where the 
minimum outTemp was less than 0. Rather than adapting any weeWX-WD code the 
built in max_le and min_le aggregates would be far simpler. These 
aggregates are not often used and probably not well known to most users. 
For example, the number of days this year where the minimum outTemp was 
less than 0 would be returned by using the tag:

$year.outTemp.min_le((0, "degree_C"))

Similarly the tag:

$month.outTemp.max_le((0, "degree_C"))

would give the number of days this month where the outTemp maximum was less 
than 0C.

If you have a look at the skins/Standard/NOAA/NOAA-YYYY.txt.tmpl template 
you will see these aggregates (and a few others eg, max_ge, min_ge and 
sum_ge) being used in a template. A list of the available aggregates is 
available in the Aggregation types appendix 
<http://weewx.com/docs/customizing.htm#aggregation_types> to the 
Customization Guide.

Of course if you want me to analyse your code as a learning exercise for 
you I can do that, but I will need more time to do that.

Gary

On Sunday, 4 March 2018 01:07:03 UTC+10, Hartmut Schweidler wrote:
>
> Hallo 
>
> Ich habe eine Frage. wie kann ich den Code aus WeewxWD für die Ermittlung 
> der "dry" und "wet" Tage für Frost (outTemp.min <0) bzw Eistage 
> (outTemp.max<0)  verwenden?
>
> weewx-wd 
> <https://bitbucket.org/ozgreg/weewx-wd/src/110688ada0c6?at=v1.2.0_development>
>  
> / bin 
> <https://bitbucket.org/ozgreg/weewx-wd/src/110688ada0c6/bin/?at=v1.2.0_development>
>  
> / user 
> <https://bitbucket.org/ozgreg/weewx-wd/src/110688ada0c6/bin/user/?at=v1.2.0_development>
>  
> / wdSearchX3.py
>
>         # Get our year stats vectors
>         _rain_vector = []
>         _time_vector = []
>         for tspan in weeutil.weeutil.genDaySpans(_mn_first_of_year_ts, 
> timespan.stop):
>             _row = db_lookup().getSql("SELECT dateTime, sum FROM 
> archive_day_rain WHERE dateTime >= ? AND dateTime < ? ORDER BY dateTime", 
> (tspan.start, tspan.stop))
>             if _row is not None:
>                 _time_vector.append(_row[0])
>                 _rain_vector.append(_row[1])
>         # Get our run of year dry days
>         _interim = []   # List to hold details of any runs we might find
>         _index = 0      # Placeholder so we can track the start dateTime of 
> any runs
>         # Use itertools groupby method to make our search for a run easier
>         # Step through each of the groups itertools has found
>         for k,g in itertools.groupby(_rain_vector):
>             _length = len(list(g))
>             if k == 0:  # If we have a run of 0s (ie no rain) add it to our
>                         # list of runs
>                 _interim.append((k, _length, _index))
>             _index += _length
>         if _interim != []:
>             # If we found a run (we want the longest one) then get our results
>             (_temp, _year_dry_run, _position) = max(_interim, key=lambda 
> a:a[1])
>             # Our 'time' is the day the run ends so we need to add on run-1 
> days
>             _year_dry_time_ts = _time_vector[_position] + (_year_dry_run - 1) 
> * 86400
>         else:
>             # If we did not find a run then set our results accordingly
>             _year_dry_run = 0
>             _year_dry_time_ts = None
>
>
> das unter Verwendung von archive_day_rain die Tabelle archive_day_outTemp 
> verwendet wird um die Anzahl der Tage outTemp < 0.0 °C zu bestimmen
>
> mein Versuch:
>         # Get our year stats vectors
>         _outTemp_vector = []
>         _time_vector = []
>         for tspan in weeutil.weeutil.genDaySpans(_mn_first_of_year_ts, 
> timespan.stop):
>             _row = db_lookup().getSql("SELECT dateTime, min FROM 
> archive_day_outTemp WHERE dateTime >= ? AND dateTime < ? ORDER BY dateTime"
> , (tspan.start, tspan.stop))
>             if _row is not None:
>                 _time_vector.append(_row[0])
>                 _outTemp_vector.append(_row[1])
>         # Get our run of year min0 days
>         _interim = []   # List to hold details of any runs we might find
>         _index = 0      # Placeholder so we can track the start dateTime 
> of any runs
>         # Use itertools groupby method to make our search for a run easier
>         # Step through each of the groups itertools has found
>         for k,g in itertools.groupby(_outTemp_vector):
>             _length = len(list(g))
>             if k < 0:   # If we have a run of les then 0 degree C (ie no 
> outTemp) add it to our
>                         # list of runs
>                 _interim.append((k, _length, _index))
>             _index += _length
>         if _interim != []:
>             # If we found a run (we want the longest one) then get our 
> results
>             (_temp, _year_minE_run, _position) = max(_interim, key=lambda 
> a:a[1])
>             # Our 'time' is the day the run ends so we need to add on 
> run-1 days
>             _year_minE_time_ts = _time_vector[_position] + (_year_minE_run 
> - 1) * 86400
>             _year_minS_time_ts = _year_minE_time_ts - (86400 * 
> _year_minE_run)
>         else:
>             # If we did not find a run then set our results accordingly
>             _year_minE_run = 0
>             _year_minE_time_ts = None
>             _year_minS_time_ts = None
>
>
> unter 
> https://github.com/hes19073/hesweewx/blob/master/bin/user/xfrostday.py
>
> mein Versuch. Es werden jedoch nicht alle Frost bzw. Eistage richtig 
> ermittelt.
> Gruss und Danke
> Hartmut
>

Reply via email to