From be19ac7cb8638d9a751f5ea32e2722d99604af85 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 27 Mar 2014 23:59:39 +0100 Subject: doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/backlight.py | 2 ++ src/blackbody.py | 4 ++++ src/colour.py | 40 ++++++++++++++++------------------------ src/monitor.py | 3 +++ src/solar.py | 3 +++ src/weather.py | 2 ++ 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/backlight.py b/src/backlight.py index be5265b..cee3af6 100644 --- a/src/backlight.py +++ b/src/backlight.py @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# This module implements support for backlight control. + import os import sys from subprocess import Popen diff --git a/src/blackbody.py b/src/blackbody.py index bd29318..41c6fe5 100644 --- a/src/blackbody.py +++ b/src/blackbody.py @@ -14,6 +14,10 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + +# This module implements support for colour temperature based +# calculation of white points + import math from colour import * diff --git a/src/colour.py b/src/colour.py index e0cc490..e2bbc01 100644 --- a/src/colour.py +++ b/src/colour.py @@ -15,6 +15,9 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +# This module implements functions from convertions between colour spaces +# and comparion of colours + def linear_to_standard(*colour): ''' @@ -57,11 +60,8 @@ def ciexyz_to_ciexyy(X, Y, Z): @param Z:float The Z parameter @return :[float, float, float] The x, y and Y parameters ''' - if X + Y + Z == 0: - return [0, 0, 0] - y = Y / (X + Y + Z) - x = X / (X + Y + Z) - return [x, y, Y] + s = X + Y + Z + return [X / s, Y / s, Y] if not s == 0 else [0, 0, 0] def matrix_mul_vector(matrix, vector): @@ -78,6 +78,9 @@ def matrix_mul_vector(matrix, vector): ciexyz_to_linear_matrix = [[ 3.240450, -1.537140, -0.4985320], [-0.969266, 1.876010, 0.0415561], [0.0556434, -0.204026, 1.0572300]] +''' +Multiplication matrix to convert from CIE xyY to linear RGB +''' def ciexyz_to_linear(X, Y, Z): ''' @@ -94,6 +97,9 @@ def ciexyz_to_linear(X, Y, Z): linear_to_ciexyz_matrix = [[0.4124564, 0.3575761, 0.1804375], [0.2126729, 0.7151522, 0.0721750], [0.0193339, 0.1191920, 0.9503041]] +''' +Multiplication matrix to convert from linear RGB to CIE xyY +''' def linear_to_ciexyz(r, g, b): ''' @@ -118,10 +124,7 @@ def srgb_to_ciexyy(r, g, b): ''' if r == g == b == 0: return (0.312857, 0.328993, 0) - rc = standard_to_linear(r, g, b) - rc = linear_to_ciexyz(*rc) - rc = ciexyz_to_ciexyy(*rc) - return rc + return ciexyz_to_ciexyy(*linear_to_ciexyz(*standard_to_linear(r, g, b))) def ciexyy_to_srgb(x, y, Y): @@ -133,10 +136,7 @@ def ciexyy_to_srgb(x, y, Y): @param Y:float The Y parameter @return :[float, float, float] The red, green and blue components ''' - rc = ciexyy_to_ciexyz(x, y, Y) - rc = ciexyz_to_linear(*rc) - rc = linear_to_standard(*rc) - return rc + return linear_to_standard(*ciexyz_to_linear(*ciexyy_to_ciexyz(x, y, Y))) def ciexyz_to_cielab(x, y, z): @@ -170,10 +170,7 @@ def cielab_to_xiexyz(l, a, b): x = a / 500 + y z = y - b / 200 f = lambda c : c ** 3 if c ** 3 > 0.00885642 else (c - 0.1379310) / (7.78 + 703 / 99900) - (x, y, z) = [f(c) for c in (x, y, z)] - x *= 0.95047 - z *= 1.08883 - return (x, y, z) + return [f(c) * m for c, m in zip((x, y, z), (0.95047, 1, 1.08883))] def delta_e(a, b): @@ -184,11 +181,6 @@ def delta_e(a, b): @param b:(float, float, float) The second colour @return :float The difference ''' - a = standard_to_linear(*a) - b = standard_to_linear(*b) - a = linear_to_ciexyz(*a) - b = linear_to_ciexyz(*b) - a = ciexyz_to_cielab(*a) - b = ciexyz_to_cielab(*b) - return sum([(c1 - c2) ** 2 for c1, c2 in zip(a, b)]) ** 0.5 + standard_to_cielab = lambda x : ciexyz_to_cielab(*linear_to_ciexyz(*standard_to_linear(*a))) + return sum([(c1 - c2) ** 2 for c1, c2 in zip(standard_to_cielab(a), standard_to_cielab(b))]) ** 0.5 diff --git a/src/monitor.py b/src/monitor.py index 499864f..470335c 100644 --- a/src/monitor.py +++ b/src/monitor.py @@ -21,6 +21,7 @@ from subprocess import Popen, PIPE from aux import * from curve import * + # /usr/lib LIBDIR = 'bin' sys.path.append(LIBDIR) @@ -31,12 +32,14 @@ LIBEXECDIR = 'bin' randr_opened = None vidmode_opened = None + try: from blueshift_drm import * except: pass ## Not compiled with DRM support + def close_c_bindings(): ''' Close all C bindings and let them free resources and close connections diff --git a/src/solar.py b/src/solar.py index 1a89d52..041d427 100644 --- a/src/solar.py +++ b/src/solar.py @@ -14,6 +14,9 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + +# This module implements algorithms for calculating information about the Sun. + import math import time diff --git a/src/weather.py b/src/weather.py index f0f0de3..fba6ffc 100644 --- a/src/weather.py +++ b/src/weather.py @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# The module implements support for retrieval of weather reports + from subprocess import Popen, PIPE -- cgit v1.2.3-70-g09d2