# -*- python -*- # This example demonstrates how to include weather conditions # in your configuration scripts. # Copyright © 2014, 2015, 2016, 2017 Mattias Andrée (maandree@kth.se) # # 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 . # Geographical coodinates. # ("Kristall, vertikal accent i glas och stål" (Crystal, vertical accent # in glass and steal) in this example. A glass 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' # You can also use None if you have ~/.config/metar set. # Command used to download a file at an HTTP URL download_command = None # This is what if used if `None` is selected: # download_command = lambda url : ['wget', url, '-O', '-'] # 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, download_command) # Account for weather. if metar is not None: conditions = [metar[0]] + metar[2] for condition in conditions: if condition in modifiers: dayness *= modifiers[condition] if metar[1] is not None: _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)