summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-20 10:12:14 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-20 10:13:18 +0100
commit2506f732294fb689ed5fe5519119754dcf918087 (patch)
tree1a0973c80c41badaea4b614c8f740393c8fcb217
parentdoc weather (diff)
downloadblueshift-2506f732294fb689ed5fe5519119754dcf918087.tar.gz
blueshift-2506f732294fb689ed5fe5519119754dcf918087.tar.bz2
blueshift-2506f732294fb689ed5fe5519119754dcf918087.tar.xz
add weather demo
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--TODO1
-rw-r--r--examples/comprehensive2
-rw-r--r--examples/weather71
-rwxr-xr-xsrc/__main__.py1
4 files changed, 73 insertions, 2 deletions
diff --git a/TODO b/TODO
index ef05950..74950cf 100644
--- a/TODO
+++ b/TODO
@@ -5,7 +5,6 @@ High priority:
Medium priority:
Test and demo _ICC_PROFILE
Demo functionise
- Demo weather
Low priority:
Add a section in manual for information on which order
diff --git a/examples/comprehensive b/examples/comprehensive
index 8c6b45d..8ec121d 100644
--- a/examples/comprehensive
+++ b/examples/comprehensive
@@ -3,7 +3,7 @@
# This example covers most of what Blueshift offers. For a complete
# coverage of Blueshift complement this example with:
# backlight, crtc-detection, crtc-searching, logarithmic,
-# stored-settings, modes, textconf
+# stored-settings, modes, textconf, weather
# However the are features that are only covered by the info manual:
# Methods for calculating correlated colour temperature
diff --git a/examples/weather b/examples/weather
new file mode 100644
index 0000000..5291fb6
--- /dev/null
+++ b/examples/weather
@@ -0,0 +1,71 @@
+# -*- python -*-
+
+# This example demonstrates how to include weather conditions
+# in you configuration scripts.
+
+
+# Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
+#
+# Permission is granted to copy, distribute and/or modify this document
+# under the terms of the GNU Free Documentation License, Version 1.3
+# or any later version published by the Free Software Foundation;
+# with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+# You should have received a copy of the GNU General Public License
+# along with this software package. If not, see <http://www.gnu.org/licenses/>.
+
+
+# Geographical coodinates.
+# ("Kristall, vertikal accent i glas och stål" (Crystal, vertical accent
+# in glass and steal) in this example. A glas obelisk, lit from the inside
+# with adjustable colours and a default colour of 5600 K, in the middle
+# of a hyperelliptic roundabout.)
+latitude, longitude = 59.3326, 18.0652
+
+# International Civil Aviation Organization (ICAO)
+# code of the nearest airport.
+# (Stockholm Bromma Airport in this example.)
+airport = 'ESSB'
+
+# The colour temperature at day and at night.
+temperature_day, temperature_night = 6500, 3700
+
+# Dayness modifiers based on weather and sky conditions.
+modifiers = { 'clear' : 1.00
+ , 'mostly clear' : 0.95
+ , 'partly cloudy' : 0.90
+ , 'mostly cloudy' : 0.85
+ , 'overcast' : 0.80
+ , 'obscured' : 0.75
+ }
+
+# The maximum for visibility range for when to
+# account for the visibility range.
+visibility_max = 4
+
+
+# The visibility of the Sun.
+dayness = sun(latitude, longitude)
+
+# Get weather report.
+metar = weather(airport)
+
+# Account for weather.
+if metar is not None:
+ conditions = [metar[0]] + metar[2]
+ for condition in conditions:
+ if condition in modifiers:
+ dayness *= modifiers[condition]
+ _bound, visibility = metar[1]
+ if (visibility_max is not None) and (visibility is not None):
+ if visibility < visibility_max:
+ dayness *= visibility / visibility_max
+
+# Calculation of the colour temperature.
+temp = temperature_day * dayness + temperature_night * (1 - dayness)
+
+## Calculate the whitepoint with adjusted colour temperature.
+whitepoint = temperature(temp, lambda t : divide_by_maximum(cmf_10deg(t)))
+
+# Apply adjustments.
+randr(0)
+
diff --git a/src/__main__.py b/src/__main__.py
index 4197963..f96bcdc 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -42,6 +42,7 @@ from solar import *
from curve import *
from colour import *
from monitor import *
+from weather import *
from backlight import *
from blackbody import *