mirror of
https://github.com/weewx/weewx.git
synced 2026-04-18 00:26:57 -04:00
Refined formatting of almanac data. Added time contexts 'ephem_day' and 'ephem_year'.
This commit is contained in:
@@ -202,7 +202,7 @@ class Almanac(object):
|
||||
# This is how you call a function on an instance when all you have is its name:
|
||||
djd = ephem.__dict__[attr](self.time_djd) #@UndefinedVariable
|
||||
return weewx.units.ValueHelper((djd, "dublin_jd", "group_time"),
|
||||
context="year", formatter=self.formatter)
|
||||
context="ephem_year", formatter=self.formatter)
|
||||
else:
|
||||
raise AttributeError, "Unknown attribute "+attr
|
||||
|
||||
@@ -267,7 +267,7 @@ class BodyWrapper(object):
|
||||
# being examined. So, create a temporary body and then throw it away
|
||||
temp_body = self.body_factory()
|
||||
time_djd = getattr(self.observer, attr)(temp_body)
|
||||
return weewx.units.ValueHelper((time_djd, "dublin_jd", "group_time"), context="day", formatter=self.formatter)
|
||||
return weewx.units.ValueHelper((time_djd, "dublin_jd", "group_time"), context="ephem_day", formatter=self.formatter)
|
||||
elif attr in fn_map:
|
||||
# These attribute names have to be mapped to a different function name. Like the
|
||||
# attributes above, they also have the side effect of changing the state of the body.
|
||||
@@ -278,7 +278,7 @@ class BodyWrapper(object):
|
||||
fn = fn_map[attr]
|
||||
# Call the function, with a second argument giving the start-of-day
|
||||
time_djd = getattr(self.observer, fn)(temp_body, self.sod_djd)
|
||||
return weewx.units.ValueHelper((time_djd, "dublin_jd", "group_time"), context="day", formatter=self.formatter)
|
||||
return weewx.units.ValueHelper((time_djd, "dublin_jd", "group_time"), context="ephem_day", formatter=self.formatter)
|
||||
else:
|
||||
# Just return the result unchanged.
|
||||
return getattr(self.body, attr)
|
||||
|
||||
@@ -239,12 +239,14 @@ default_unit_label_dict = { "centibar" : " cb",
|
||||
|
||||
# Default strftime formatting to be used in the absence of a skin
|
||||
# configuration file:
|
||||
default_time_format_dict = {"day" : "%H:%M",
|
||||
"week" : "%H:%M on %A",
|
||||
"month" : "%d-%b-%Y %H:%M",
|
||||
"year" : "%d-%b-%Y %H:%M",
|
||||
"rainyear" : "%d-%b-%Y %H:%M",
|
||||
"current" : "%d-%b-%Y %H:%M"}
|
||||
default_time_format_dict = {"day" : "%H:%M",
|
||||
"week" : "%H:%M on %A",
|
||||
"month" : "%d-%b-%Y %H:%M",
|
||||
"year" : "%d-%b-%Y %H:%M",
|
||||
"rainyear" : "%d-%b-%Y %H:%M",
|
||||
"current" : "%d-%b-%Y %H:%M",
|
||||
"ephem_day" : "%H:%M",
|
||||
"ephem_year" : "%d-%b-%Y %H:%M"}
|
||||
|
||||
|
||||
#===============================================================================
|
||||
@@ -301,6 +303,9 @@ class Formatter(object):
|
||||
self.unit_format_dict = unit_format_dict
|
||||
self.unit_label_dict = unit_label_dict
|
||||
self.time_format_dict = time_format_dict
|
||||
# Add new keys for backwards compatibility on old skin dictionaries:
|
||||
self.time_format_dict.setdefault('ephem_day', "%H:%M")
|
||||
self.time_format_dict.setdefault('ephem_year', "%d-%b-%Y %H:%M")
|
||||
|
||||
@staticmethod
|
||||
def fromSkinDict(skin_dict):
|
||||
|
||||
@@ -791,7 +791,8 @@ December: Min, max temperatures: N/A N/A
|
||||
<pre>Azimuth, altitude of mars: $almanac.mars.az $almanac.mars.alt</pre>
|
||||
<pre>Next new, full moon: $almanac.next_new_moon $almanac.next_full_moon</pre>
|
||||
<pre>Next summer, winter solstice: $almanac.next_summer_solstice $almanac.next_winter_solstice</pre>
|
||||
<pre> </pre>
|
||||
<p>The included almanac includes information for the Sun, Moon, Venus, Mars,
|
||||
and Jupiter. </p>
|
||||
<h2>Writing a custom generator</h2>
|
||||
<p>To do more sophisticated customization it may be necessary to extend an existing
|
||||
generator, or write your own. </p>
|
||||
@@ -1050,6 +1051,13 @@ month = %d-%b-%Y %H:%M</pre>
|
||||
<p>would specify that week data should use a format such as "<span class="code">15:20
|
||||
on Sunday</span>", while month data should look like "<span class="code">06-Oct-2009
|
||||
15:20</span>"</p>
|
||||
<p>It also allows the formatting to be set for almanac times:</p>
|
||||
<pre>ephem_day = %H:%M
|
||||
ephem_year = %d-%b-%Y %H:%M</pre>
|
||||
<p>The first of these, <span class="code">ephem_day</span>, is used for
|
||||
almanac times within the day, such as sunrise or sunset. The second,
|
||||
<span class="code">ephem_year</span>, is used for almanac times within the
|
||||
year, such as the next equinox or full moon.</p>
|
||||
<h3 class="config_section">[[DegreeDays]] </h3>
|
||||
<p class="config_important">heating_base<br />
|
||||
cooling_base</p>
|
||||
|
||||
@@ -348,15 +348,13 @@
|
||||
</tr>
|
||||
#end if
|
||||
#if $almanac.hasExtras
|
||||
#set $sun_az = "%.1f°" % $almanac.sun.az
|
||||
#set $sun_alt= "%.1f°" % $almanac.sun.alt
|
||||
<tr>
|
||||
<td class="label">Azimuth:</td>
|
||||
<td class="data">$sun_az</td>
|
||||
<td class="data">$("%.1f°" % $almanac.sun.az)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Altitude:</td>
|
||||
<td class="data">$sun_alt</td>
|
||||
<td class="data">$("%.1f°" % $almanac.sun.alt)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Equinox:</td>
|
||||
@@ -374,7 +372,7 @@
|
||||
<caption class="caption">Moon</caption>
|
||||
<tr>
|
||||
<td class="label">Phase:</td>
|
||||
<td class="data">$almanac.moon_phase ($almanac.moon_fullness% full)</td>
|
||||
<td class="data">$almanac.moon_phase<br/>($almanac.moon_fullness% full)</td>
|
||||
</tr>
|
||||
#if $almanac.hasExtras
|
||||
<tr>
|
||||
@@ -389,15 +387,13 @@
|
||||
<td class="label">Set:</td>
|
||||
<td class="data">$almanac.moon.set
|
||||
</tr>
|
||||
#set $moon_az = "%.1f°" % $almanac.moon.az
|
||||
#set $moon_alt= "%.1f°" % $almanac.moon.alt
|
||||
<tr>
|
||||
<td class="label">Azimuth:</td>
|
||||
<td class="data">$moon_az</td>
|
||||
<td class="data">$("%.1f°" % $almanac.moon.az)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Altitude:</td>
|
||||
<td class="data">$moon_alt</td>
|
||||
<td class="data">$("%.1f°" % $almanac.moon.alt)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Full moon:</td>
|
||||
|
||||
@@ -136,12 +136,14 @@
|
||||
# This section sets the string format to be used
|
||||
# each time scale.
|
||||
#
|
||||
day = %H:%M
|
||||
week = %H:%M on %A
|
||||
month = %d-%b-%Y %H:%M
|
||||
year = %d-%b-%Y %H:%M
|
||||
rainyear = %d-%b-%Y %H:%M
|
||||
current = %d-%b-%Y %H:%M
|
||||
day = %H:%M
|
||||
week = %H:%M on %A
|
||||
month = %d-%b-%Y %H:%M
|
||||
year = %d-%b-%Y %H:%M
|
||||
rainyear = %d-%b-%Y %H:%M
|
||||
current = %d-%b-%Y %H:%M
|
||||
ephem_day = %H:%M
|
||||
ephem_year = %d-%b-%Y %H:%M
|
||||
|
||||
[[DegreeDays]]
|
||||
#
|
||||
|
||||
@@ -102,6 +102,189 @@ body {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#content .header {
|
||||
font-size: 14pt;
|
||||
font-weight: bolder;
|
||||
color: #3d6c87;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
#content .caption {
|
||||
font-weight: bold;
|
||||
color: #3d6c87;
|
||||
}
|
||||
|
||||
#content .label {
|
||||
text-align: right;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#content .data {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#about, #almanac {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
#almanac {
|
||||
width:80%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.celestial_group {
|
||||
}
|
||||
|
||||
.celestial_body {
|
||||
width: 48%;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#plots {
|
||||
width: 90%;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
#plots img {
|
||||
margin: 3px;
|
||||
border: thin solid #3d6c87;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
#radar_img {
|
||||
width: 90%;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
#radar_img img {
|
||||
width: 90%;
|
||||
padding: 3px;
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Navigation bar (week, month, etc.) at the bottom
|
||||
*/
|
||||
#navbar {
|
||||
margin: 0 1% 1% 1%;
|
||||
padding: 5px;
|
||||
text-align: center;
|
||||
clear: both;
|
||||
border-top: 1px solid #dcdcdc;
|
||||
border-right: 1px solid #a9a9a9;
|
||||
border-bottom: 1px solid #808080;
|
||||
border-left: 1px solid #a9a9a9;
|
||||
background-color: #fafaff;
|
||||
}
|
||||
|
||||
/*************** Global Styles ***************/
|
||||
|
||||
h2, h3, h4, h5, h6 {
|
||||
color: #3d6c87;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 10pt;
|
||||
background-color: #f2f2f7;
|
||||
background-image: url('backgrounds/band.gif');
|
||||
background-repeat: repeat;
|
||||
background-attachment: scroll;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the big header at the top of the page
|
||||
*/
|
||||
#masthead {
|
||||
margin: 1% 1% 0 1%;
|
||||
padding: 5px;
|
||||
text-align: center;
|
||||
border-top: 1px solid #dcdcdc;
|
||||
border-right: 1px solid #a9a9a9;
|
||||
border-bottom: 1px solid #808080;
|
||||
border-left: 1px solid #a9a9a9;
|
||||
background-color: #fafaff;
|
||||
}
|
||||
|
||||
#masthead h1 {
|
||||
color: #3d6c87;
|
||||
}
|
||||
#masthead h3 {
|
||||
color: #5f8ea9;
|
||||
}
|
||||
|
||||
/*
|
||||
* This holds the statistics (daily high/low, etc.) on the left:
|
||||
*/
|
||||
#stats_group {
|
||||
width: 30%;
|
||||
min-height: 500px;
|
||||
margin: 1%;
|
||||
padding: 5px;
|
||||
float: left;
|
||||
border-top: 1px solid #dcdcdc;
|
||||
border-right: 1px solid #a9a9a9;
|
||||
border-bottom: 1px solid #808080;
|
||||
border-left: 1px solid #a9a9a9;
|
||||
background-color: #fafaff;
|
||||
}
|
||||
|
||||
.stats table {
|
||||
border: thin solid #000000;
|
||||
width: 100%;
|
||||
}
|
||||
.stats td {
|
||||
border: thin solid #000000;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.stats_header {
|
||||
background-color: #000000;
|
||||
color: #a8b8c8;
|
||||
font-size: 14pt;
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
.stats_label {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.stats_data {
|
||||
color: red;
|
||||
}
|
||||
|
||||
/*
|
||||
* This holds the "About", "Almanac", and plots on the right
|
||||
*/
|
||||
#content {
|
||||
width: 62%;
|
||||
min-height: 500px;
|
||||
margin: 1%;
|
||||
padding: 5px;
|
||||
float: right;
|
||||
border-top: 1px solid #dcdcdc;
|
||||
border-right: 1px solid #a9a9a9;
|
||||
border-bottom: 1px solid #808080;
|
||||
border-left: 1px solid #a9a9a9;
|
||||
background-color: #fafaff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#content .header {
|
||||
text-align: center;
|
||||
font-size: 14pt;
|
||||
@@ -122,35 +305,38 @@ body {
|
||||
|
||||
#content td {
|
||||
width: 50%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#content .label {
|
||||
text-align: right;
|
||||
font-style: italic;
|
||||
padding-right: 2px;
|
||||
}
|
||||
|
||||
#content .data {
|
||||
text-align: left;
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
#about, #almanac {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.celestial_group {
|
||||
#almanac {
|
||||
# border: thin solid #3d6c87;
|
||||
width:60%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.celestial_group {
|
||||
}
|
||||
|
||||
.celestial_body {
|
||||
width: 48%;
|
||||
# border: thin solid #3d6c87;
|
||||
border-top: 1px solid #3d6c87;
|
||||
border-left:1px solid #3d6c87;
|
||||
border-bottom: 2px solid #3d6c87;
|
||||
border-right: 2px solid #3d6c87;
|
||||
# border-top: 1px solid #3d6c87;
|
||||
# border-left:1px solid #3d6c87;
|
||||
# border-bottom: 2px solid #3d6c87;
|
||||
# border-right: 2px solid #3d6c87;
|
||||
display:inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
@@ -201,4 +387,3 @@ body {
|
||||
h2, h3, h4, h5, h6 {
|
||||
color: #3d6c87;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user