kopia lustrzana https://github.com/sq9atk/sr0wx
moduł informacje o propagacji
rodzic
3ab59ed813
commit
f702fcb526
Plik binarny nie jest wyświetlany.
|
@ -1,8 +1,40 @@
|
|||
<?php
|
||||
|
||||
|
||||
// TYLKO Z TEJ TABLICY GENEROWANE SĄ SAMPLE
|
||||
// URUCHOMIENIE W KONSOLI:
|
||||
// php index.php
|
||||
$slownik = array(
|
||||
array('lekkie zachmurzenie','lekkie_zachmurzenie'),
|
||||
array('słowa do przeczytania','nazwa_pliku_wynikowego'),
|
||||
);
|
||||
|
||||
|
||||
|
||||
// TABLICE Z SAMPLAMI DO MODUŁÓW
|
||||
|
||||
/// PROPAGACJA
|
||||
$slownikPropagacja = array(
|
||||
array('rigreferens','rigreference'),
|
||||
array('rigreferens kom','rigreference_com'),
|
||||
array('noaa','noaa'),
|
||||
|
||||
array('dzień ','dzien'),
|
||||
array('noc','noc'),
|
||||
|
||||
array('informacje o propagacji','informacje_o_propagacji'),
|
||||
array('pasma','pasma'),
|
||||
|
||||
array('warunki podwyższone','warunki_podwyzszone'),
|
||||
array('warunki normalne','warunki_normalne'),
|
||||
array('warunki obniżone','warunki_obnizone'),
|
||||
array('pasmo zamknięte','pasmo_zamkniete'),
|
||||
|
||||
array('160 metrów','160_metrow'),
|
||||
array('80 metrów','80_metrow'),
|
||||
array('40 metrów','40_metrow'),
|
||||
array('20 metrów','20_metrow'),
|
||||
array('10 metrów','10_metrow'),
|
||||
array('6 metrów','6_metrow'),
|
||||
);
|
||||
|
||||
|
||||
|
|
28
config.py
28
config.py
|
@ -342,6 +342,17 @@ radioactivesq9atk = RadioactiveSq9atk(
|
|||
## więcej czujników na stronie http://radioactiveathome.org/map/
|
||||
)
|
||||
|
||||
|
||||
# ---------------
|
||||
# propagation_sq9atk
|
||||
# ---------------
|
||||
from propagation_sq9atk import PropagationSq9atk
|
||||
propagationsq9atk = PropagationSq9atk(
|
||||
language=pl_google,
|
||||
service_url="https://rigreference.com/solar/img/tall",
|
||||
)
|
||||
|
||||
|
||||
# ---------------
|
||||
# calendar_sq9atk
|
||||
# ---------------
|
||||
|
@ -372,13 +383,14 @@ calendarsq9atk = CalendarSq9atk(
|
|||
# WŁĄCZONE MODUŁY
|
||||
modules = [
|
||||
activitymap,
|
||||
#openweathersq9atk,
|
||||
meteosq9atk, # ten moduł jest zastąpiony przez openweathersq9atk
|
||||
#meteoalarmsq9atk,
|
||||
#imgwpodestsq9atk,
|
||||
#airpollutionsq9atk,
|
||||
#geomagneticsq9atk,
|
||||
#radioactivesq9atk,
|
||||
#calendarsq9atk,
|
||||
openweathersq9atk,
|
||||
#meteosq9atk, # pogoda z onet-u, ten moduł jest zastąpiony przez openweathersq9atk
|
||||
meteoalarmsq9atk,
|
||||
imgwpodestsq9atk,
|
||||
airpollutionsq9atk,
|
||||
propagationsq9atk,
|
||||
geomagneticsq9atk,
|
||||
radioactivesq9atk,
|
||||
calendarsq9atk,
|
||||
]
|
||||
|
||||
|
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -0,0 +1,109 @@
|
|||
#!/usr/bin/python -tt
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib2
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from PIL import Image
|
||||
from pprint import pprint
|
||||
|
||||
from sr0wx_module import SR0WXModule
|
||||
|
||||
class PropagationSq9atk(SR0WXModule):
|
||||
"""Klasa pobierająca dane kalendarzowe"""
|
||||
|
||||
def __init__(self,language,service_url):
|
||||
self.__service_url = service_url
|
||||
self.__language = language
|
||||
self.__logger = logging.getLogger(__name__)
|
||||
self.__pixels = {
|
||||
# niepotrzebne pasma można zaremowac znakiem '#'
|
||||
160 : {'day' :{'x':50, 'y':60}, 'night':{'x':100, 'y':60}},
|
||||
80 : {'day' :{'x':50, 'y':95}, 'night':{'x':100, 'y':95}},
|
||||
40 : {'day' :{'x':50, 'y':140}, 'night':{'x':100, 'y':140}},
|
||||
20 : {'day' :{'x':50, 'y':185}, 'night':{'x':100, 'y':185}},
|
||||
10 : {'day' :{'x':50, 'y':230}, 'night':{'x':100, 'y':230}},
|
||||
6 : {'day' :{'x':50, 'y':270}, 'night':{'x':100, 'y':270}},
|
||||
}
|
||||
|
||||
self.__levels = {
|
||||
'#17e624':'warunki_podwyzszone', # zielony
|
||||
'#e6bc17':'warunki_normalne', # żółty
|
||||
'#e61717':'warunki_obnizone', # czerwony
|
||||
'#5817e6':'pasmo_zamkniete', #fioletowy
|
||||
}
|
||||
|
||||
def rgb2hex(self, rgb):
|
||||
return '#%02x%02x%02x' % rgb
|
||||
|
||||
|
||||
def downloadImage(self, url):
|
||||
try:
|
||||
self.__logger.info("::: Odpytuję adres: " + url)
|
||||
webFile = urllib2.urlopen(url, None, 30)
|
||||
return Image.open(webFile)
|
||||
except urllib2.URLError, e:
|
||||
print e
|
||||
except socket.timeout:
|
||||
print "Timed out!"
|
||||
return ""
|
||||
|
||||
|
||||
def collectBandConditionsFromImage(self, image, dayTime):
|
||||
imageData = image.load()
|
||||
data = list()
|
||||
for band in sorted(self.__pixels):
|
||||
x = self.__pixels[band][dayTime]['x']
|
||||
y = self.__pixels[band][dayTime]['y']
|
||||
rgba = imageData[x,y]
|
||||
color = self.rgb2hex(( rgba[0],rgba[1],rgba[2] ));
|
||||
|
||||
# można zaremowac wybraną grupę aby nie podawać info o konkretnych warunkach
|
||||
if self.__levels[color] == 'warunki_podwyzszone':
|
||||
string = str(band) + '_metrow' + ' ' + self.__levels[color]
|
||||
data[:0] = [string]
|
||||
|
||||
if self.__levels[color] == 'warunki_normalne':
|
||||
string = str(band) + '_metrow' + ' ' + self.__levels[color]
|
||||
data[:0] = [string]
|
||||
|
||||
if self.__levels[color] == 'warunki_obnizone':
|
||||
string = str(band) + '_metrow' + ' ' + self.__levels[color]
|
||||
data[:0] = [string]
|
||||
|
||||
if self.__levels[color] == 'pasmo_zamkniete':
|
||||
string = str(band) + '_metrow' + ' ' + self.__levels[color]
|
||||
data[:0] = [string]
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def get_data(self):
|
||||
|
||||
image = self.downloadImage(self.__service_url)
|
||||
|
||||
self.__logger.info("::: Przetwarzam dane...\n")
|
||||
|
||||
message = " ".join([
|
||||
" _ informacje_o_propagacji ",
|
||||
" _ dzien _ ",
|
||||
" _ pasma _ ",
|
||||
" _ " .join( self.collectBandConditionsFromImage(image, 'day') ),
|
||||
" _ noc _ ",
|
||||
" _ pasma _ ",
|
||||
" _ " .join( self.collectBandConditionsFromImage(image, 'night') ),
|
||||
" _ "
|
||||
])
|
||||
|
||||
return {
|
||||
"message": message,
|
||||
"source": "noaa",
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Ładowanie…
Reference in New Issue