Comment démarrer avec pywws

Install dependencies

You may be able to install most of these using your operating system’s package manager. This is a lot easier than downloading and compiling source files from the project websites. Note that some Linux distributions may use different names for some of the packages, e.g. in Ubuntu, pyusb is python-usb.

In addition to the above, I recommend installing pip (the package may be called python-pip) or easy_install. These both simplify installation of software from the Python Package Index (PyPI). For example, PyUSB can be installed from PyPI using the pip command:

sudo pip install pyusb

Download the pywws software

Créer un dossier pour tous vos fichiers reliés à la météo et vous positionner dans ce dossier. Par exemple (avec un système d’exploitation Linux ou similaire):

mkdir ~/weather
cd ~/weather

You can install pywws directly from PyPI using pip or easy_install, or you can download and extract the files into your weather directory. This has the advantage that you can easily read the Python modules and other files. It also allows you to run pywws software without the ‘root’ privileges usually needed to install software.

Easy installation

This is a simple one line command:

sudo pip install pywws

The directories everything gets installed to depend on your operating system and Python version. The pywws modules are installed in the ‘site-packages’ directory (e.g. /usr/lib/python2.7/site-packages). Typically the scripts are installed in /usr/bin, and the example files are installed in /usr/share/pywws, but other directories (such as /usr/local/share) could be used.

Download and extract

You can either download a snapshot release from PyPI, or you can use git to get the most up to date development version of pywws.

To download a snapshot, visit http://pypi.python.org/pypi/pywws/ and download one of the .tar.gz or .zip files. Put it in your weather directory, then extract all the files, for example:

cd ~/weather
tar zxvf pywws-12.11_95babb0.tar.gz

ou:

cd ~/weather
unzip pywws-12.11_95babb0.zip

This should create a directory (called pywws-12.11_95babb0 in this example) containing all the pywws source files. It is convenient to create a soft link to this awkwardly named directory:

cd ~/weather
ln -s pywws-12.11_95babb0 pywws

Alternatively, to get the latest development version of pywws use git clone, then use setup.py to compile the language files and documentation:

cd ~/weather
git clone https://github.com/jim-easterbrook/pywws.git
cd pywws
python setup.py msgfmt
python setup.py build_sphinx

After downloading and extracting, or cloning the repos, you can then use setup.py to build and install everything:

cd ~/weather/pywws
python setup.py build
sudo python setup.py install

This is optional, and installs into the same directories as using pip would. If you don’t do this installation process, you will only be able to run pywws modules from your pywws directory.

(Python 3 users only) Translate pywws to Python 3

If your default Python version is 3.x and you installed pywws using pip, or ran python setup.py install, the code will already have been translated from Python 2 to Python 3 as part of the installation process. If not, you need to use setup.py to do the translation and create a Python 3 installation:

cd ~/weather/pywws
rm -Rf build
python3 setup.py build
sudo python3 setup.py install

Test the weather station connection

Finally you’re ready to test your pywws installation. Connect the weather station (if not already connected) then run the pywws.TestWeatherStation module. If you have downloaded but not installed pywws, then don’t forget to change to the pywws directory first. For example:

cd ~/weather/pywws
python -m pywws.TestWeatherStation

Si tout fonctionne correctement, vous devriez voir apparaitre un lot de chiffre ressemblant à ceci:

0000 55 aa ff ff ff ff ff ff ff ff ff ff ff ff ff ff 05 20 01 51 11 00 00 00 81 00 00 0f 00 00 60 55
0020 ea 27 a0 27 00 00 00 00 00 00 00 10 10 12 13 45 41 23 c8 00 32 80 47 2d 2c 01 2c 81 5e 01 1e 80
0040 96 00 c8 80 a0 28 80 25 a0 28 80 25 03 36 00 05 6b 00 00 0a 00 f4 01 18 03 00 00 00 00 00 00 00
0060 00 00 4e 1c 63 0d 2f 01 73 00 7a 01 47 80 7a 01 47 80 e4 00 00 00 71 28 7f 25 bb 28 bd 25 eb 00
0080 0c 02 84 00 0e 01 e3 01 ab 03 dc 17 00 10 08 21 08 54 10 03 07 22 18 10 08 11 08 30 10 04 21 16
00a0 26 08 07 24 17 17 08 11 01 06 10 09 06 30 14 29 09 01 06 07 46 09 06 30 14 29 09 01 06 07 46 08
00c0 08 31 14 30 10 05 14 15 27 10 01 26 20 47 09 01 23 05 13 10 01 26 20 47 09 01 23 05 13 10 02 22
00e0 11 06 10 02 22 11 06 08 07 07 19 32 08 12 13 22 32 08 09 07 08 48 01 12 05 04 43 10 02 22 14 43

Si ce test ne fonctionne pas, plusieurs facteurs peuvent être en cause, mais le plus courant est un problème de ‘permissions’; ce qui peut être vérifié en exécutant la commande suivante avec les droits ‘root’:

sudo python -m pywws.TestWeatherStation

Si celà fonctionne, vous devriez être capable de permettre à votre compte utilisateur normal d’accéder à votre station météo en créant une règle ‘udev’. Voir la page de compatibilité du wiki http://code.google.com/p/pywws/wiki/Compatibility (en anglais) pour plus de détails.

Pour tout autre problème, n’hésitez pas à demander de l’aide sur la liste de publipostage de pywws: http://groups.google.com/group/pywws

Set up your weather station

If you haven’t already done so, set your weather station to display the correct relative atmospheric pressure. (See the manual for details of how to do this.) pywws gets the offset between relative and absolute pressure from the station, so this needs to be set before using pywws.

You can get the correct relative pressure from your location by looking on the internet for weather reports from a nearby station, ideally an official one such as an airport. This is best done during calm weather when the pressure is almost constant over a large area.

If you change the offset at any time, you can update all your stored data by running pywws.Reprocess.

Set the weather station logging interval

Your weather station probably left the factory with a 30 minute logging interval. This enables the station to store about 11 weeks of data. Most pywws users set up their computers to read data from the station every hour, or more often, and only need the station to store enough data to cover computer failures. The recommended interval is 5 minutes, which still allows 2 weeks of storage. Use pywws.SetWeatherStation to set the interval:

python -m pywws.SetWeatherStation -r 5

Log your weather station data

En premier lieu, choisissez un dossier pour entreposer toute les données de votre station météo. Ces données étant écrites très fréquemment, un disque rigide sera préférable à une mémoire Flash (USB), puisque ces dernières ont un nombre d’écriture limité. Dans la plupart des cas, le répertoire personnel est préférable, par exemple:

mkdir ~/weather/data

Ce répertoire est référé dans la documentation pywws en tant que votre ‘répertoire de données’.

Assurez-vous que votre ordinateur ait la date et l’heure précise, ainsi que le fuseau horaire approprié, puisqu’ils seront utilisés pour identifier les données de votre station météo. Si vous ne l’avez pas déjà fait, il pourrait être utile d’utiliser la synchronisation horaires par réseau (NTP) pour synchroniser votre ordinateur à un ‘serveur de temps’.

La première fois que vous exécutez pywws.LogData un fichier de configuration, nommé ‘weather.ini’, sera créé dans votre répertoire de données, puis s”arrêtera. Vous devez éditer ce fichier de configuration et y modifier la ligne ws type = Unknown à ws type = 1080 ou ws type = 3080. (Si la console de votre station météo affiche la luminosité solaire, vous avez une station de type 3080, sinon, vous indiquez le type 1080.) Puis exécutez pywws.LogData de nouveau. Cette fois, l’exécution peut durer quelques minutes, puisqu’il copiera l’intégralité des données météo emmagasinées dans la mémoire de votre station météo. Le programme pywws.LogData possède une option ‘verbose’ qui augmente le nombre de messages affichés pendant l’exécution. Cette option est utile lors d’exécution manuelle, par exemple:

python -m pywws.LogData -vvv ~/weather/data

(Remplacez ~/weather/data par votre répertoire de données, si différent.)

Vous devriez maintenant avoir quelques fichiers de données à regarder. Par exemple:

more ~/weather/data/weather/raw/2012/2012-12/2012-12-16.txt

(Remplacez année, mois et jour par la date pour laquelle vous devriez avoir des données.)

Convert old EasyWeather data (optional)

Si vous utilisiez EasyWeather avant de décider d’utiliser pywws, vous pouvez convertir les données que EasyWeather a enregistré, vers format de pywws. Localisez votre fichier EasyWeather.dat et convertissez-le ainsi:

python -m pywws.EWtoPy EasyWeather.dat ~/weather/data

Set some configuration options

Après avoir exécuté pywws.LogData, il devrait y avoir un fichier de configuration nommé ‘weather.ini’ dans votre répertoire de données. Ouvrez ce fichier avec un éditeur de texte. Vous devriez y trouver des lignes semblables à celle-ci:

[config]
ws type = 1080
logdata sync = 1

Vous devez ajouter une nouvelle entrée nommée day end hour dans la section [config]. Ceci indique à pywws quelle convention vous souhaitez utiliser pour le calcul du sommaire des données quotidiennes. En Grande-Bretagne, le ‘jour météorologique’ s’étale habituellement de 09:00 à 09:00 GMT (10:00 à 10:00 BST durant l’été), j’utilise donc 9 pour l’heure de fin du jour. Dans d’autres pays une valeur de 24 (ou 0) peut être souhaitable. Noter que cette valeur est définie à l’heure hivernale locale. Vous ne devriez pas avoir besoin de changer cette valeur pendant la saison chaude.

Après édition, votre fichier weather.ini devrait resembler à ceci:

[config]
ws type = 1080
logdata sync = 1
day end hour = 9

Pour plus de détails sur les options du fichier de configuration, voir weather.ini - format du fichier de configuration.

Process the raw data

pywws.LogData just copies the raw data from the weather station. To do something useful with that data you probably need hourly, daily and monthly summaries. These are created by pywws.Process. For example:

python -m pywws.Process ~/weather/data

Vous devriez avoir ainsi quelques fichiers traités à consulter:

more ~/weather/data/weather/daily/2012/2012-12-16.txt

If you ever change your day end hour configuration setting, you will need to reprocess all your weather data. You can do this by running pywws.Reprocess:

python -m pywws.Reprocess ~/weather/data

Vous êtes maintenant prêt pour fixer une journalisation régulière ou continue, tel que décrit dans la section Comment configurer la journalisation horaire avec pywws ou Comment configurer le mode ‘live’ avec pywws.

Read the documentation

The doc directory in your pywws source directory contains HTML and plain text versions of the documentation (unless you did a direct installation with pip). The HTML files can be read with any web browser. Start with the index (pywws) and follow links from there.

Commentaires ou questions? SVP, souscrivez à la liste d’envoi de pywws http://groups.google.com/group/pywws et laissez-le nous savoir.