Reformatting EasyWeather data for UIView

 

The EasyWeather software supplied with the Watson W8681 wireless weather station (aka Fine Offset WH1080 / WH1081 and possibly rebadged under other names) produces a csv data file called EasyWeather.dat which is an accumulation of readings collected from the display unit across the USB interface. The data file is not directly compatible with UIView and there is no option to produce an output file that is.

When I first aquired my W8681 I wrote a REXX script for Kedit for Windows to produce a data file in the format needed. I did not publish that script as the software I used is proprietory and costs almost as much as the weather station. I had to install Python to overcome a bug between the WXtoImg software and my R2ZX satellite receiver and resolved to produce a Python script to do this conversion as Python is at least free software.

Python script
To make this work you will need to adjust the paths to what you have used on your own machine. Note that I don’t produce rainfall data – this is because the EasyWeather version I am using is bugged and sometimes produces ridiculous rainfall data. Even if that were not the case I don’t trust the rainfall data produced by my W8681 anyway.

I have no experience of Python – this script is probably badly written but does work for me – certainly I found the language to be idiosyncratic – for instance…
Why does tailer return a list with the second entry containing the required data?
Why does the substringing base the first position on index from 0 and the last position one higher than you’d expect?
I welcome any suggestions for changes from Python experts.

import tailer
# Get the last line of the EasyWeather.dat file
# This is a little strange - line[1] holds the data
line = tailer.tail(open('c:\Weather\NewWeather\EasyWeather.dat'), 1)

# f = open('c:\Weather\NewWeather\EasyWeather.las', 'w')
# f.write(line[1])

# f.close()

i=0
for value in line[1].split(','):
if i == 2:
stamp = value.strip()
if i == 6:
humidity = value.strip()
if i == 7:
temperature = value.strip()
if i == 11:
pressure = value.strip()
if i == 12:
wind_speed = value.strip()
if i == 14:
gust = value.strip()
if i == 16:
wind_dir = value.strip()
if i == 21:
rain_h = value.strip()
if i == 22:
rain_d = value.strip()
i = i + 1

# Constuct timestamp
# Uses current date as that is easier. This could result in an error near midnight
# but UIView should reject that record.
from datetime import date
now = date.today()
stamp_date = now.strftime("%b %d %Y")
stamp_time = stamp[11:16]
UIView_stamp = stamp_date+" "+stamp_time

# Wind direction (convert from 0 - 15 to degrees)
wind = float(wind_dir)
wind = int((wind * 22.5) + 0.5)
wind_dir = str(wind)
wind_dir = wind_dir.zfill(3)

# Wind speed (convert meters/sec to mph)
speed = float(wind_speed)

speed = int((speed * 2.2369) + 0.5)
wind_speed = str(speed)
wind_speed = wind_speed.zfill(3)

# Gust speed (convert meters/sec to mph)
speed = float(gust)
speed = int((speed * 2.2369) + 0.5)
gust = str(speed)
gust = gust.zfill(3)

# Temperature (convert C to F)
temp = float(temperature)
temp = int((temp * 9 / 5) + 32.5)
temperature = str(temp)
temperature = temperature.zfill(3)

# Pressure
press = float(pressure)
press = press * 10
press = int(press)
pressure = str(press)

# Rain last hour (convert mm to 1/100 inch)
rain = float(rain_h)
rain = (rain * 3.937) + 0.5
rain = int(rain)
rain_h = str(rain)
rain_h = rain_h.zfill(3)
# Now set it to ... anyway because of the EasyWeather bug
rain_h = '...'

# Rain last 24 hours (convert mm to 1/100 inch)
rain = float(rain_d)
rain = (rain * 3.937) + 0.5
rain = int(rain)
rain_d = str(rain)
rain_d = rain_d.zfill(3)
# Now set it to ... anyway because of the E
asyWeather bug
rain_d = '...'

f = open('c:\Weather\NewWeather\wx_ext.txt', 'w')

f.write(UIView_stamp+'\n')

second_line = wind_dir.zfill(3)+'/'+wind_speed+'g'+gust+'t'+temperature+'r'+rain_h+'p'+rain_d+'P...h'+humidity.zfill(2)+ 'b'+ pressure.zfill(5)
f.write(second_line)

f.close()

Installing Python
There are plenty of sites dedicated to the Python scripting language so I’ll only include very brief notes on this.

Download and install Python for Windows – www.python.org

Download and install Python Extensions for Windows – PyWin32 Project

To make life easier now is the time to add paths for the python executables and scripts to your path environment variable. Typically you’ll need to right click “My Computer” select properties then click advanced to find the environment variables.
The current default you’ll need to add to the end of the path is ;C:\Python25;C:\Python25\Scripts;

Download and install EasyInstall for Python – Easy Install for Python

Use EasyInstall to download and install the tailer package – open a command prompt (with run as administrator in Vista) and just type easy_install tailer

There are no short cuts to any place worth going.


  2 Responses to “Reformatting EasyWeather data for UIView”

  1. dear contact
    the value of abs pressure it not ok . I found it 822 hpa
    my city elevation above sea level equal 360m
    is this affect value of abs pressure

  2. http://www.altitude.org/air_pressure.php says..

    “At 360m, the standard barometric pressure is 97 kPa (730 mmHg)”
    730mmHg is 973 hPa so it looks like your station was probably reading low

    I’d advise you check other stations around you to see what they are reporting. If it is that far out and is new I’d say return it for a replacement.

 Leave a Reply

(required)

(required)

+ 81 = 86

Our weather forecast is from Wunderground for WordPress