Skip to content

Commit

Permalink
Added archive and NOAA Reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daveiano committed May 11, 2022
1 parent 7d7fe5a commit b2b5e0b
Show file tree
Hide file tree
Showing 21 changed files with 477 additions and 29 deletions.
38 changes: 38 additions & 0 deletions bin/user/archive_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from xml.etree.ElementInclude import include
from datetime import datetime
from weewx.cheetahgenerator import SearchList


class ArchiveUtil(SearchList):
def filter_months(self, months, year):
"""
Returns a filtred list of months
Args:
months (list): A list of months [2022-01, 2022-02]
year (string): Year.
Returns:
str: A icon include string.
"""
months_filtered = []

for month in months:
if year in month:
months_filtered.append(month)

return months_filtered

def month_string_format(self, month):
"""
Returns a formatted value of a weewwx month string (2022-01)
Args:
month (string): A month
Returns:
str: Formatted month string.
"""
date_time_obj = datetime. strptime(month, '%Y-%m')

return date_time_obj.strftime('%B')
7 changes: 6 additions & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def loader():
class BasicInstaller(ExtensionInstaller):
def __init__(self):
super(BasicInstaller, self).__init__(
version="1.0.0-alpha2",
version="1.0.0-alpha3",
name='weewx-wdc',
description='Weather Data Center skin for weewx.',
author="David Baetge",
Expand All @@ -33,12 +33,17 @@ def __init__(self):
'bin/user/stats_util.py'
'bin/user/general_util.py'
'bin/user/celestial_util.py'
'bin/user/archive_util.py'
]),
('skins/weewx-wdc',
['skins/weewx-wdc/index.html.tmpl',
'skins/weewx-wdc/week.html.tmpl',
'skins/weewx-wdc/month.html.tmpl',
'skins/weewx-wdc/month-%Y-%m.html.tmpl',
'skins/weewx-wdc/NOAA/NOAA-%Y-%m.txt.tmpl',
'skins/weewx-wdc/year.html.tmpl',
'skins/weewx-wdc/NOAA/NOAA-%Y.txt.tmpl',
'skins/weewx-wdc/year-%Y.html.tmpl',
'skins/weewx-wdc/statistics.html.tmpl',
'skins/weewx-wdc/celestial.html.tmpl',
'skins/weewx-wdc/skin.conf',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weewx-wdc",
"version": "1.0.0-alpha2",
"version": "1.0.0-alpha3",
"description": "Weather Data Center skin for weewx.",
"author": "David Baetge <[email protected]>",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Inspired by and build with the [Carbon Design System](https://carbondesignsystem
- Combinable diagrams via skin.conf
- Responsive
- Day, week, month, year and all-time pages
- Archive and NOAA Reports
- Almanac
- Translated for DE and EN

Expand Down Expand Up @@ -49,9 +50,8 @@ Starts a nginx docker container to serve the generated files.

### Todo

- Add yearly archive accessible via Sidebar
- Add NOAA reports accessible via Sidebar
- Responsive
- Add Carbon Data Tables
- Responsive
- Add Climatological stat tiles (for the archive?)

## Credits
40 changes: 40 additions & 0 deletions skins/weewx-wdc/NOAA/NOAA-%Y-%m.txt.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#errorCatcher Echo
#set $YM="%Y %m"
#set $D=" %d"
#set $M=" %b"
#set $Time=" %H:%M"
#set $NODAY=" N/A"
#set $Temp="%6.1f"
#set $Wind="%6.1f"
#set $Dir="%6.0f"
#set $Count="%6d"
#set $NONE=" N/A"
#if $unit.unit_type_dict.group_rain == "mm"
#set $Rain="%6.1f"
#else
#set $Rain="%6.2f"
#end if
MONTHLY CLIMATOLOGICAL SUMMARY for $month_name $year_name


NAME: $station.location
ELEV: $station.altitude LAT: $station.latitude[0]-$station.latitude[1] $station.latitude[2] LONG: $station.longitude[0]-$station.longitude[1] $station.longitude[2]


TEMPERATURE ($unit.label.outTemp.strip()), RAIN ($unit.label.rain.strip()), WIND SPEED ($unit.label.windSpeed.strip())

HEAT COOL AVG
MEAN DEG DEG WIND DOM
DAY TEMP HIGH TIME LOW TIME DAYS DAYS RAIN SPEED HIGH TIME DIR
---------------------------------------------------------------------------------------
#for $day in $month.days
#if $day.outTemp.has_data or $day.rain.has_data or $day.wind.has_data
$day.dateTime.format($D, add_label=False) $day.outTemp.avg.format($Temp,$NONE,add_label=False) $day.outTemp.max.format($Temp,$NONE,add_label=False) $day.outTemp.maxtime.format($Time,add_label=False) $day.outTemp.min.format($Temp,$NONE,add_label=False) $day.outTemp.mintime.format($Time,add_label=False) $day.heatdeg.sum.format($Temp,$NONE,add_label=False) $day.cooldeg.sum.format($Temp,$NONE,add_label=False) $day.rain.sum.format($Rain,$NONE,add_label=False) $day.wind.avg.format($Wind,$NONE,add_label=False) $day.wind.max.format($Wind,$NONE,add_label=False) $day.wind.maxtime.format($Time,add_label=False) $day.wind.vecdir.format($Dir,$NONE,add_label=False)
#else
$day.dateTime.format($D)
#end if
#end for
#if $month.outTemp.has_data or $month.rain.has_data or $month.wind.has_data
---------------------------------------------------------------------------------------
$month.outTemp.avg.format($Temp,$NONE,add_label=False) $month.outTemp.max.format($Temp,$NONE,add_label=False) $month.outTemp.maxtime.format($D,add_label=False) $month.outTemp.min.format($Temp,$NONE,add_label=False) $month.outTemp.mintime.format($D,add_label=False) $month.heatdeg.sum.format($Temp,$NONE,add_label=False) $month.cooldeg.sum.format($Temp,$NONE,add_label=False) $month.rain.sum.format($Rain,$NONE,add_label=False) $month.wind.avg.format($Wind,$NONE,add_label=False) $month.wind.max.format($Wind,$NONE,add_label=False) $month.wind.maxtime.format($D,add_label=False) $month.wind.vecdir.format($Dir,add_label=False)
#end if
102 changes: 102 additions & 0 deletions skins/weewx-wdc/NOAA/NOAA-%Y.txt.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#errorCatcher Echo
#set $YM="%Y %m"
#set $D=" %d"
#set $M=" %b"
#set $NODAY=" N/A"
#set $Temp="%6.1f"
#set $Wind="%6.1f"
#set $Dir="%6.0f"
#set $Count="%6d"
#set $NONE=" N/A"
#if $unit.unit_type_dict.group_temperature == "degree_F"
#set $Hot =(90.0,"degree_F")
#set $Cold =(32.0,"degree_F")
#set $VeryCold=(0.0, "degree_F")
#else
#set $Hot =(30.0,"degree_C")
#set $Cold =(0.0,"degree_C")
#set $VeryCold=(-20.0,"degree_C")
#end if
#if $unit.unit_type_dict.group_rain == "inch"
#set $Trace =(0.01,"inch")
#set $SomeRain =(0.1, "inch")
#set $Soak =(1.0, "inch")
#set $Rain="%6.2f"
#elif $unit.unit_type_dict.group_rain == "mm"
#set $Trace =(.3, "mm")
#set $SomeRain =(3, "mm")
#set $Soak =(30.0,"mm")
#set $Rain="%6.1f"
#else
#set $Trace =(.03,"cm")
#set $SomeRain =(.3, "cm")
#set $Soak =(3.0,"cm")
#set $Rain="%6.2f"
#end if
#def ShowInt($T)
$("%6d" % $T[0])#slurp
#end def
#def ShowFloat($R)
$("%6.2f" % $R[0])#slurp
#end def
CLIMATOLOGICAL SUMMARY for year $year_name


NAME: $station.location
ELEV: $station.altitude LAT: $station.latitude[0]-$station.latitude[1] $station.latitude[2] LONG: $station.longitude[0]-$station.longitude[1] $station.longitude[2]


TEMPERATURE ($unit.label.outTemp.strip())

HEAT COOL MAX MAX MIN MIN
MEAN MEAN DEG DEG >= <= <= <=
YR MO MAX MIN MEAN DAYS DAYS HI DAY LOW DAY $ShowInt($Hot) $ShowInt($Cold) $ShowInt($Cold) $ShowInt($VeryCold)
------------------------------------------------------------------------------------------------
#for $month in $year.months
#if $month.outTemp.has_data
$month.dateTime.format($YM) $month.outTemp.meanmax.format($Temp,$NONE,add_label=False) $month.outTemp.meanmin.format($Temp,$NONE,add_label=False) $month.outTemp.avg.format($Temp,$NONE,add_label=False) $month.heatdeg.sum.format($Temp,$NONE,add_label=False) $month.cooldeg.sum.format($Temp,$NONE,add_label=False) $month.outTemp.max.format($Temp,$NONE,add_label=False) $month.outTemp.maxtime.format($D,$NODAY) $month.outTemp.min.format($Temp,$NONE,add_label=False) $month.outTemp.mintime.format($D,$NODAY) $month.outTemp.max_ge($Hot).format($Count,$NONE,add_label=False) $month.outTemp.max_le($Cold).format($Count,$NONE,add_label=False) $month.outTemp.min_le($Cold).format($Count,$NONE,add_label=False) $month.outTemp.min_le($VeryCold).format($Count,$NONE,add_label=False)
#else
$month.dateTime.format($YM)
#end if
#end for
#if $year.outTemp.has_data
------------------------------------------------------------------------------------------------
$year.outTemp.meanmax.format($Temp,$NONE,add_label=False) $year.outTemp.meanmin.format($Temp,$NONE,add_label=False) $year.outTemp.avg.format($Temp,$NONE,add_label=False) $year.heatdeg.sum.format($Temp,$NONE,add_label=False) $year.cooldeg.sum.format($Temp,$NONE,add_label=False) $year.outTemp.max.format($Temp,$NONE,add_label=False) $year.outTemp.maxtime.format($M,$NODAY) $year.outTemp.min.format($Temp,$NONE,add_label=False) $year.outTemp.mintime.format($M,$NODAY) $year.outTemp.max_ge($Hot).format($Count,$NONE,add_label=False) $year.outTemp.max_le($Cold).format($Count,$NONE,add_label=False) $year.outTemp.min_le($Cold).format($Count,$NONE,add_label=False) $year.outTemp.min_le($VeryCold).format($Count,$NONE,add_label=False)
#end if


PRECIPITATION ($unit.label.rain.strip())

MAX ---DAYS OF RAIN---
OBS. OVER
YR MO TOTAL DAY DATE $ShowFloat(Trace) $ShowFloat($SomeRain) $ShowFloat($Soak)
------------------------------------------------
#for $month in $year.months
#if $month.rain.has_data
$month.dateTime.format($YM) $month.rain.sum.format($Rain,$NONE,add_label=False) $month.rain.maxsum.format($Rain,$NONE,add_label=False) $month.rain.maxsumtime.format($D,$NODAY) $month.rain.sum_ge($Trace).format($Count,$NONE,add_label=False) $month.rain.sum_ge($SomeRain).format($Count,$NONE,add_label=False) $month.rain.sum_ge($Soak).format($Count,$NONE,add_label=False)
#else
$month.dateTime.format($YM)
#end if
#end for
#if $year.rain.has_data
------------------------------------------------
$year.rain.sum.format($Rain,$NONE,add_label=False) $year.rain.maxsum.format($Rain,$NONE,add_label=False) $year.rain.maxsumtime.format($M,$NODAY) $year.rain.sum_ge($Trace).format($Count,$NONE,add_label=False) $year.rain.sum_ge($SomeRain).format($Count,$NONE,add_label=False) $year.rain.sum_ge($Soak).format($Count,$NONE,add_label=False)
#end if


WIND SPEED ($unit.label.windSpeed.strip())

DOM
YR MO AVG HI DATE DIR
-----------------------------------
#for $month in $year.months
#if $month.wind.has_data
$month.dateTime.format($YM) $month.wind.avg.format($Wind,$NONE,add_label=False) $month.wind.max.format($Wind,$NONE,add_label=False) $month.wind.maxtime.format($D,$NODAY) $month.wind.vecdir.format($Dir,$NONE,add_label=False)
#else
$month.dateTime.format($YM)
#end if
#end for
#if $year.wind.has_data
-----------------------------------
$year.wind.avg.format($Wind,$NONE,add_label=False) $year.wind.max.format($Wind,$NONE,add_label=False) $year.wind.maxtime.format($M,$NODAY) $year.wind.vecdir.format($Dir,$NONE,add_label=False)
#end if
16 changes: 3 additions & 13 deletions skins/weewx-wdc/celestial.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#encoding UTF-8
#from datetime import datetime
#set $now = datetime.now().strftime("%d. %b %Y %H:%M")
#attr $use_parameter_month = False
#attr $use_parameter_year = False

<!DOCTYPE html>
<html>
Expand Down Expand Up @@ -75,19 +77,7 @@
</section>
</main>

<div id="footer">
<div class="bx--grid bx--grid--full-width">
<div class="bx--row">
<div class="bx--col">
<p>
weewx: $station.uptime<br />
server: $station.os_uptime<br />
weewx $station.version with $station.hardware<br />
</p>
</div>
</div>
</div>
</div>
#include "includes/footer.inc"

<script src="dist/js/index.js"></script>
</body>
Expand Down
26 changes: 21 additions & 5 deletions skins/weewx-wdc/includes/combined-diagram-tile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,30 @@

<!--prettier-ignore-->
#for $combined_obs in $combined_diagram.obs.keys()
#set $series_name = $combined_obs + 'Series' + str($diagram_index)
#silent $series_names.append($series_name)
#silent $series_labels.append($obs.label[$combined_obs])
#if 'color' in $combined_diagram.obs[$combined_obs] then $series_colors.append($combined_diagram.obs[$combined_obs].color) else $series_colors.append($get_color($combined_obs))#
#set $series_name = $combined_obs + 'Series' + str($diagram_index)
#silent $series_names.append($series_name)
#silent $series_labels.append($obs.label[$combined_obs])
#if 'color' in $combined_diagram.obs[$combined_obs] then $series_colors.append($combined_diagram.obs[$combined_obs].color) else $series_colors.append($get_color($combined_obs))#

<!--prettier-ignore-->
#if $precision == 'month' and $use_parameter_month
<script>
/* prettier-ignore */
var $series_name = $getattr($month, $partial_obs).series(aggregate_type=$get_aggregate_type($partial_obs), aggregate_interval=$get_aggregate_interval($partial_obs, $precision), time_series='start', time_unit='unix_epoch').round($get_rounding($partial_obs)).json;
</script>
<!--prettier-ignore-->
#else if $precision == 'year' and $use_parameter_year
<script>
/* prettier-ignore */
var $series_name = $getattr($span($hour_delta=$get_delta($partial_obs, $precision)), $combined_obs).series(aggregate_type=$get_aggregate_type($partial_obs), aggregate_interval=$get_aggregate_interval($partial_obs, $precision), time_series='start', time_unit='unix_epoch').round($get_rounding($combined_obs)).json;
var $series_name = $getattr($year, $partial_obs).series(aggregate_type=$get_aggregate_type($partial_obs), aggregate_interval=$get_aggregate_interval($partial_obs, $precision), time_series='start', time_unit='unix_epoch').round($get_rounding($partial_obs)).json;
</script>
#else
<script>
/* prettier-ignore */
var $series_name = $getattr($span($hour_delta=$get_delta($partial_obs, $precision)), $partial_obs).series(aggregate_type=$get_aggregate_type($partial_obs), aggregate_interval=$get_aggregate_interval($partial_obs, $precision), time_series='start', time_unit='unix_epoch').round($get_rounding($partial_obs)).json;
</script>
<!--prettier-ignore-->
#end if
#end for

<div
Expand Down
15 changes: 15 additions & 0 deletions skins/weewx-wdc/includes/diagram-tile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,25 @@
<div class="value">
<!--prettier-ignore-->
#set $series_name = $partial_obs + 'Series' + str($diagram_index)

<!--prettier-ignore-->
#if $precision == 'month' and $use_parameter_month
<script>
/* prettier-ignore */
var $series_name = $getattr($month, $partial_obs).series(aggregate_type=$get_aggregate_type($partial_obs), aggregate_interval=$get_aggregate_interval($partial_obs, $precision), time_series='start', time_unit='unix_epoch').round($get_rounding($partial_obs)).json;
</script>
<!--prettier-ignore-->
#else if $precision == 'year' and $use_parameter_year
<script>
/* prettier-ignore */
var $series_name = $getattr($year, $partial_obs).series(aggregate_type=$get_aggregate_type($partial_obs), aggregate_interval=$get_aggregate_interval($partial_obs, $precision), time_series='start', time_unit='unix_epoch').round($get_rounding($partial_obs)).json;
</script>
#else
<script>
/* prettier-ignore */
var $series_name = $getattr($span($hour_delta=$get_delta($partial_obs, $precision)), $partial_obs).series(aggregate_type=$get_aggregate_type($partial_obs), aggregate_interval=$get_aggregate_interval($partial_obs, $precision), time_series='start', time_unit='unix_epoch').round($get_rounding($partial_obs)).json;
</script>
#end if

<!--
@todo Define helper fn for data-obs
Expand Down
23 changes: 19 additions & 4 deletions skins/weewx-wdc/includes/ui-shell.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!--prettier-ignore-->
#encoding UTF-8
#errorCatcher Echo

<script
type="module"
Expand Down Expand Up @@ -82,10 +84,23 @@
$gettext("Statistics")
</bx-side-nav-link>
<bx-side-nav-divider></bx-side-nav-divider>
<bx-side-nav-menu title="NOAA Reports">
<bx-side-nav-menu-item href="#"> 1 </bx-side-nav-menu-item>
<bx-side-nav-menu-item href="#"> 2 </bx-side-nav-menu-item>
<bx-side-nav-menu-item href="#"> 3 </bx-side-nav-menu-item>
<bx-side-nav-menu title="$gettext('Archive & NOAA Reports')">
<!--prettier-ignore-->
#set $archive_months = $SummaryByMonth
#for $year in $SummaryByYear
#set $months_for_year = $filter_months(archive_months, $year)
<!--prettier-ignore-->
<bx-side-nav-menu-item href="year-${year}.html">
<b>$year</b>
</bx-side-nav-menu-item>
<!--prettier-ignore-->
#for $month in $months_for_year
<bx-side-nav-menu-item href="month-${month}.html">
&nbsp;&nbsp;&nbsp;&nbsp;$month_string_format($month)
</bx-side-nav-menu-item>
<!--prettier-ignore-->
#end for
#end for
</bx-side-nav-menu>
</bx-side-nav-items>
</bx-side-nav>
2 changes: 2 additions & 0 deletions skins/weewx-wdc/index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#errorCatcher Echo
#encoding UTF-8
#attr $precision = 'day'
#attr $use_parameter_month = False
#attr $use_parameter_year = False

<!DOCTYPE html>
<html>
Expand Down
1 change: 1 addition & 0 deletions skins/weewx-wdc/lang/de.conf
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"WeeWX uptime" = "WeeWX-Laufzeit"
"WeeWX version" = "WeeWX-Version"
"This station is controlled by <a href='https://weewx.com'>WeeWX</a>, an experimental weather software system written in Python." = "Diese Station wird von <a href='https://weewx.com'>WeeWX</a> gesteuert, einer experimentellen Wetter-Software, geschrieben in Python."
"Archive & NOAA Reports" = "Archiv & NOAA Reporte"

[[Geographical]]
"Altitude" = "Höhe ü. NN" # As in height above sea level
Expand Down
1 change: 1 addition & 0 deletions skins/weewx-wdc/lang/en.conf
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"WeeWX uptime" = "WeeWX uptime"
"WeeWX version" = "WeeWX version"
"This station is controlled by <a href='https://weewx.com'>WeeWX</a>, an experimental weather software system written in Python." = "This station is controlled by <a href='https://weewx.com'>WeeWX</a>, an experimental weather software system written in Python."
"Archive & NOAA Reports" = "Archive & NOAA Reports"

[[Geographical]]
"Altitude" = "Altitude" # As in height above sea level
Expand Down
Loading

0 comments on commit b2b5e0b

Please sign in to comment.