Meteobridge und WXSIM

This document covers my setup to provide weather data gathered by meteobridge to my WXSIM instance.

Problemspace

WXSIM relies on current and historic weather data which can be fed in from different sources (like Cumulus or WeatherDispplay). Meteobridge doesn’t have its own format, but can generate data through a template based system. To save space meteobridge is only holding minute-based data for maximum of two days – for older data on can only access hourly aggregated data. A related aspect is the amount of available data and Tom, the author of WXSIM , recommends at least 10-minute data to create proper forecast. Given that meteobridge stores mostly hourly data, exporting historic data isn’t a real option.

It turns out that a reduced cumulus file format would do the job, since it’s already supported by WXSIM and CSV generation can be achieved with the meteobridge template system.

Special case: precipitation

WXSIM is able to use local precipitation data to improve the forecast accuracy. Tom stated that the data isn’t strictly necessary, but highly recommended. Unfortunately total-sums aren’t available when using the iteratative template expansion, so a simple export appending the current data to the data log doesn’t work.

Solution with precipitation

Right now I have a two-step setup to generate a cumulus style export file that WXSIM can read:

  1. Every 5min a one-liner of the current values is created through the HTML-Generation feature
  2. A second event (triggered by the first one) appends this file to the monthly cumulus log file

Template

#if#{*[th0hum-avg5.0:]>0*}#then#[DD]/[MM]/[YY],[hh]:[mm],[th0temp-avg5.1:],[th0hum-avg5.0:],[th0dew-avg5.1:],[wind0wind-avg5=mph.1:],[wind0wind-max5=mph.1:],[wind0dir-avg5.0:],[rain0rate-avg5.1:],[rain0total-daysum.1:],[thb0seapress-avg5.1:],[rain0total-yearsum.1:],,,,,,,[sol0rad-avg5.0:],,#else##no data - [YY][MM][DD][hh][mm] #fi#
  • Currently I’m using the average of the last 5 minutes, but one could also use the current value.
  • I added a check whether here’s some valid data (humidity > 0), to avoid lines with bads data which might cause errors when importing them into WXSIM
  • Just put the file with the extension .txt in your template directory and trigger the following event using this template.
Event to generate data export

Script

#!/bin/sh
#
# Script to append log lines in cumulus format to a monthly log
CUMULUS_CURRENT_FILE="/tmp/mnt/data/html/cumulus_wxsim.cur"
if [ -f "$CUMULUS_CURRENT_FILE" ]; then
    CUMULUS_MONTHLY_FILE="/tmp/mnt/data/export/`date '+%b%y'`log.txt"
    # Append current line and drop invalid lines
    CURRENT_DATA=$(cat $CUMULUS_CURRENT_FILE | grep -v "no data" | grep -v ",,,,,,,,,")
    if [[ ! -z "$CURRENT_DATA" ]]; then
      printf "$CURRENT_DATA\r\n" >> $CUMULUS_MONTHLY_FILE
    fi
    rm $CUMULUS_CURRENT_FILE
else
    echo "$CUMULUS_CURRENT_FILE doesn't exist" 
fi
exit 0
  • The script first checks if there’s a new file with the current data
  • Then it tries to append it to the monthly log, but filters lines with missing data
  • Removes the current data file

One could easily adjust the script to do some more sofisticated error handling.

  • Put the script in your script folder and trigger the following event
Event to trigger the script

Some additional notes

  • Make sure that the script (/tmp/mnt/data/scripts/wxsim.sh) is executable. You may need to ssh into your meteobridge and run chmod u+x wxsim.sh.
  • The windows machine has be configured with the right number format in regional settings, so that the decimal symbol is a period/dot. I’m using English UK.
  • Set the path \\meteobridge\data\export or the corresponding path with a mapped drive as the `Local station data directory`

  • Change the import unit for wind-speed to mi/hr

  • WXSIMATE requires two month of data to work properly. You can use following template to export the data from meteobridge: [DD]/[MM]/[YY],[hh]:[mm],[th0temp-avg.1:],[th0hum-avg.0:],[th0dew-avg.1:],[wind0wind-avg=mph.1:],[wind0wind-max=mph.1:],[wind0dir-avg.0:],[rain0rate-avg.1:],[rain0total-daysum.1:],[thb0seapress-avg.1:],[rain0total-yearsum.1:],,,,,,,[sol0rad-avg.0:],, Save it with the extension .exp in template directory and export at least hourly data for the current and last month using this template. Don’t forget to rename the generated files properly.

Download templates & script

Resign from using precipitaion

In case you don’t have or want precipitaion data in the log files you can use a single event the append data to a monthly log

#pragma exportfile=[MMM].[YY]log.txt
#pragma append=y
#pragma emptylines=n
#pragma crlf=y
#if#{*[th0hum-avg5.0:]>0*}#then#[DD]/[MM]/[YY],[hh]:[mm],[th0temp-avg5.1:],
Nach oben scrollen