Come iniziare con pywws

Installation

First of all you need to install Python and a USB library (to allow Python to access the weather station). See Dipendenze for more detail.

Creare una directory per tutti i file meteo correlati e posizionarsi nella directory. Per esempio (su un sistema Linux o simile sistema operativo):

mkdir ~/weather
cd ~/weather

Installazione facile

The easiest way to install pywws is with the pip command:

sudo pip install pywws

Aggiornare pywws con una semplice riga di comando:

sudo pip install -U pywws

Now you are ready to Testare la connessione della stazione meteo.

Scaricare ed estrarre

If you prefer not to use pip, or you want easy access to the pywws source files (e.g. to translate the documentation – see Come utilizzare pywws in un altra lingua), you can download and extract the files into your weather directory.

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-14.03.dev1178.tar.gz

o:

cd ~/weather
unzip pywws-14.03.dev1178.zip

This should create a directory (called pywws-14.03.dev1178 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-14.03.dev1178 pywws

L’aggiornamento di una versione scaricata è lo stesso processo come per la prima installazione. Scarica il .tar.gz o .zip file, estrai il suo contenuto, quindi elimina il link che punta al vecchio download e creane uno che punta al nuovo download. Una volta che siete soddisfatti e la nuova versione funziona OK, è possibile eliminare il vecchio download interamente.

Clone the repository

The PyPI files contain a snapshot release of the software - a new one is issued every few months. If you want to use the very latest version of pywws, e.g. to work on fixing a bug, you can get all the files you need from the GitHub repository. Install git and use it to clone the repos:

cd ~/weather
git clone https://github.com/jim-easterbrook/pywws.git

To upgrade you use git to pull any changes:

cd ~/weather/pywws
git pull

Install pywws

If you have downloaded or cloned the pywws source files, you need to use setup.py to install it:

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

The python setup.py compile_catalog step is only needed if you want to use pywws in a language other than English. See Test the pywws translations for more detail.

Note to Python 3 users: this will generate and use Python 3 versions of the pywws software in ~/weather/pywws/build/lib.

Compile documentation (optional)

If you’d like to have a local copy of the pywws documentation (and have downloaded the source or cloned the repo) you can «compile» the English documentation. This requires the sphinx package:

cd ~/weather/pywws
python setup.py build_sphinx

Compiling the documentation in another language requires the additional step of compiling the translation files, which requires the sphinx-intl package. For example, to compile the French documentation:

cd ~/weather/pywws
sphinx-intl build --locale-dir src/pywws/lang -l fr
LANG=fr python setup.py build_sphinx

The compiled documentation should then be found at ~/weather/pywws/doc/html/index.html. See Come utilizzare pywws in un altra lingua for more detail.

Testare la connessione della stazione meteo

Now you’re ready to test your pywws installation. Connect the weather station (if not already connected) then run the pywws.TestWeatherStation module:

pywws-testweatherstation

Se tutto funziona correttamente, questo dovrebbe visualizzare dei numeri sullo schermo, ad esempio:

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

Ci sono diverse ragioni perché questo potrebbe non funzionare. Molto probabilmente è un problema di “permessi”. Questo può essere testato eseguendo il comando come root:

sudo pywws-testweatherstation

If this works then you may be able to allow your normal user account to access the weather station by setting up a “udev” rule. The exact method may depend on your Linux version, but this is typically done by creating a file /etc/udev/rules.d/39-weather-station.rules containing the following:

ACTION!="add|change", GOTO="weatherstation_end"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1941", ATTRS{idProduct}=="8021", GROUP="weatherstation"
LABEL="weatherstation_end"

Unplug and replug the station’s USB connection to force udev to apply the new rule. This allows any user in the group weatherstation to access the weather station. You need to create this group and add your normal user account to it – many Linux systems have a GUI for user and group management.

Se avete qualsiasi altro problema, per favore chiedi aiuto pywws mailing list: http://groups.google.com/group/pywws

Configurare la tua stazione meteo

Se non lo hai già fatto, imposta la tua stazione meteo per visualizzare la corretta pressione atmosferica relativa. (Vedere il manuale per informazioni su come effettuare questa operazione). pywws ottiene l’offset tra pressione relativa e assoluta dalla stazione, quindi questa deve essere impostata prima di utilizzare pywws.

Cercando su internet tra i bollettini meteo di una stazione vicina, idealmente una ufficiale come un aeroporto, è possibile ottenere la corretta pressione relativa dalla vostra posizione. Questo è meglio farlo quando il tempo è calmo e la pressione è costante su una vasta area.

Impostare l’intervallo di registrazione della stazione meteo

La tua stazione meteo probabilmente lasciato la fabbrica con un intervallo di registrazione di 30 minuti. In questo modo la stazione memorizzare circa 11 settimane di dati. La maggior parte degli utenti pywws usano i loro computer per leggere i dati dalla stazione ogni ora, o più spesso che solo bisogno la stazione per archivi dati sufficienti per coprire i fallimenti del computer. L’intervallo consigliato è di 5 minuti, che consente ancora 2 settimane di stoccaggio. Per impostare l’intervallo usa pywws.SetWeatherStation:

pywws-setweatherstation -r 5

Note that the weather station will not start using the new interval until the current 30 minute logging period is finished. This may cause «station is not logging data» errors when running pywws logging. If this happens you need to wait until the 30 minute logging period ends.

Registrare i dati della stazione meteo

Innanzitutto, scegliere una directory per archiviare tutti i dati della stazione meteo. Questo verrà scritto abbastanza frequentemente, quindi un disco rigido è preferibile a una memory stick, come questi hanno un numero limitato di scritture. Nella maggior parte dei casi è adatta la home directory, per esempio:

mkdir ~/weather/data

Questa directory viene definita nella documentazione pywws altrove come directory di dati.

Assicurarsi che il computer abbia la giusta data ora e fuso orario, poiché questi vengono usati per etichettare i dati della stazione meteo. Se non hai già fatto, vale la pena di impostazione NTP per sincronizzare il computer a un “time server”.

La prima volta che si esegue pywws.LogData sarà creato un file di configurazione nella directory dati chiamato “weather.ini” e poi chiudi il programma. È necessario modificare il file di configurazione e cambiare la linea ws type = Unknown in ws type = 1080 o ws type = 3080. (Se la tua stazione meteo visualizza illuminamento solare avete un modello 3080, tutti gli altri sono 1080). Quindi eseguire nuovamente pywws.LogData. Ciò può richiedere diversi minuti, siccome esso copierà tutti i dati memorizzati nella memoria della vostra stazione. Il programma pywws.LogData ha un’opzione “verbose” che aumenta la quantità di messaggi vengono visualizzati durante l’esecuzione. Questo è utile quando si esegue manualmente, ad esempio:

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

(Sostituire ~/weather/data con la directory dei dati, se è diversa.)

Ora dovreste avere alcuni file di dati che si possono guardare. Ad esempio:

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

(Sostituire l’anno, il mese e il giorno con quelli che i vostri dati dovrebbero avere.)

Convertire i vecchi dati di EasyWeather (opzionale)

Se era in esecuzione EasyWeather prima di decidere di utilizzare pywws, è possibile convertire i dati che EasyWeather aveva registrato nel formato pywws. Trovare il file EasyWeather.dat e poi convertirlo:

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

Impostare alcune opzioni di configurazione

Dopo l’esecuzione pywws.LogData ci dovrebbe essere un file di configurazione nella directory dati chiamata “weather.ini”. Aprire questa con un editor di testo. Si dovrebbe trovare qualcosa come il seguente:

[config]
ws type = 1080
logdata sync = 1
pressure offset = 9.4

È necessario aggiungere una nuova voce nella sezione [config] chiamata day end hour. Questo dice a pywws che convenzione si desidera utilizzare nel calcolo dei dati di riepilogo giornalieri. Nel Regno Unito, la “giornata meteorologica” è solitamente dalle 09.00 alle 09:00 GMT (10.00 alle 10.00 BST durante l’estate), quindi utilizzare un valore di ora di fine giornata di 9. In altri paesi il valore 24 (o 0) potrebbe essere più adatto. Si noti che il valore è impostato nel periodo invernale locale. Non è necessario cambiarla quando l’ora legale è in vigore.

Dopo la modifica, il file weather.ini dovrebbe apparire qualcosa di simile a questo:

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

È inoltre possibile modificare il valore pressure offset per regolare il calcolo di pywws della pressione relativa (al livello del mare) dal valore assoluto della stazione. In futuro se si modifica la pressione offset o l’ora di fine giornata, è necessario aggiornare tutti i dati memorizzati tramite il comando pywws.Reprocess.

Per maggiori dettagli sulle opzioni del file di configurazione, vedere weather.ini - configurazione del formato del file.

Cambiato nella versione 13.10_r1082: inserito pressure offset un elemento di configurazione. In precedenza è sempre stata letta dalla stazione meteo.

Elaborare i dati grezzi(raw)

pywws.LogData copia solo i dati grezzi dalla stazione meteo. Per fare qualcosa di utile con quei dati è probabilmente necessario di riepiloghi ogni ora, giornalieri e mensili. Sono creati da pywws.Process. Ad esempio:

python -m pywws.Process ~/weather/data

Ora dovreste avere alcuni file elaborati da guardare:

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

Se cambi l’impostazione di configurazione day end hour, è necessario rielaborare tutti i dati meteo. È possibile farlo eseguendo pywws.Reprocess:

python -m pywws.Reprocess ~/weather/data

Ora siete pronti per impostare la registrazione ad intervalli o continua, come descritto in Come impostare “hourly” per la registrazione oraria con pywws o Come impostare una registrazione “live” con pywws.

Leggere la documentazione

You’re looking at it right now! The Guide per gli utenti section is probably the most useful bit to read first, but the Programmi Python e moduli section has a lot more detail on the various pywws modules and commands.


Commenti o domande? Si prega di iscriversi per al mailing list pywws http://groups.google.com/group/pywws e facci sapere.