wxnow template

131 views
Skip to first unread message

wmiler

unread,
Jan 29, 2012, 1:25:31 PM1/29/12
to wview
Does anybody have a template for generating a wxnow.txt format file?

Thanks,

- Wyatt -

CW4149

Mark S. Teel

unread,
Jan 30, 2012, 11:32:32 AM1/30/12
to wv...@googlegroups.com
Should be easy, do you have a definition for the wxnow.txt file?

wmiler

unread,
Jan 30, 2012, 12:51:19 PM1/30/12
to wview
The definition is here:
http://wiki.sandaysoft.com/a/Wxnow.txt

The problem I ran into, is the date must be of the form:
Feb 01 2009 All I seem to be able to generate is of the form: 01/30/12

Also, I need the barometer to output in mb not inches, but I need to
keep
it in inches for regular web display.

Everything else I think will parse correctly.

Thanks,

- Wyatt -

CW4149

Michael Gray

unread,
Jan 30, 2012, 1:04:37 PM1/30/12
to wv...@googlegroups.com
date "+%b %d %Y"

On 1/30/2012 12:51 PM, wmiler wrote:
> Feb 01 2009

wmiler

unread,
Jan 30, 2012, 1:20:20 PM1/30/12
to wview
Um, I can't do that thru wview I imagine, I'm guessing some kind of
post-process script?

- Wyatt -

CW4149

wmiler

unread,
Jan 31, 2012, 1:21:59 PM1/31/12
to wview
On Jan 30, 1:20 pm, wmiler <wmi...@nyx.net> wrote:
> Um, I can't do that thru wview I imagine, I'm guessing some kind of
> post-process script?
>
>   - Wyatt -
>
Ok, so this is what I've got in my post-generate.sh:
echo "`date "+%b %d %Y %H:%M"`" | cat - wxnow.txt >/tmp/out && mv /tmp/
out wxnow.txt
This gets the date formatted and located correctly:

--
Jan 31 2012 13:16
167/4g4t66.2P0.00h22b30.384
--

This now only leaves getting the barometer into the correct units. Any
thoughts?

Mind you, I stink at sed/awk, I would imagine I'll need to find a way
to extract the 30.384, do the calc, and replace it in the file.

drich

unread,
Jan 31, 2012, 1:59:02 PM1/31/12
to wv...@googlegroups.com

If you can tell me what format you want it in, I can probably whip up an awk script for it. You should be able to do the whole thing in a single awk call. For example, assuming that wxnow.txt contains the 2nd line in your e-mail, you could use:

awk '{print strftime("%b %d %Y %H:%M"); print}' ~/wxnow.txt

 

On 31.01.2012 10:21, wmiler wrote:

On Jan 30, 1:20 pm, wmilerwrote:
Um, I can't do that thru wview I imagine, I'm guessing some kind of post-process script?   - Wyatt -
Ok, so this is what I've got in my post-generate.sh:
echo "`date "+%b %d %Y %H:%M"`" | cat - wxnow.txt >/tmp/out && mv /tmp/
out wxnow.txt
This gets the date formatted and located correctly:

--
Jan 31 2012 13:16
167/4g4t66.2P0.00h22b30.384
--

This now only leaves getting the barometer into the correct units. Any
thoughts?

Mind you, I stink at sed/awk, I would imagine I'll need to find a way
to extract the 30.384, do the calc, and replace it in the file.

  - Wyatt -

CW4149
On Jan 30, 1:04 pm, Michael Graywrote:
date "+%b %d %Y"
On 1/30/2012 12:51 PM, wmiler wrote:
Feb 01 2009
-- You received this message because you are subscribed to the Google Groups "wview" group. To post to this group, send email to wv...@googlegroups.com. To unsubscribe from this group, send email to wview+un...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/wview?hl=en. 

 

--
http://www.employees.org/~drich/
"Step up to red alert!" "Are you sure, sir?
It means changing the bulb in the sign..."

      - Red Dwarf (BBC)

wmiler

unread,
Jan 31, 2012, 2:45:37 PM1/31/12
to wview
On reflection, after I read the UK Met WOW thread, I realized there
was a significantly easier way to go about this. Now I just need to
remember out how to get single digit numbers to be left-padded with
0's as needed for the spec. Seems like printf has a call for that....

Thanks for everybody's help tho, it's been a long time since I've
played with wview (if it ain't broke, don't mess with it :).

- Wyatt -

CW4149
Still chugging along on v5.5.1 :)
> athttp://groups.google.com/group/wview?hl=en.
>
> --
>
> Dan Rich
> <dr...@employees.org>http://www.employees.org/~drich/[1]
>  "Step up to
> red alert!" "Are you sure, sir?
>  It means changing the bulb in the
> sign..."
>  - Red Dwarf (BBC)
>
> Links:
> ------
> [1]http://www.employees.org/%7Edrich/

drich

unread,
Jan 31, 2012, 2:48:31 PM1/31/12
to wv...@googlegroups.com

I just found the spec -- I think this will do what you're looking for:

awk '{print strftime("%b %d %Y %H:%M"); split($0,a,"b");printf"%sb%d\n",a[1],a[2]*338.639}' ~/wxnow.txt

--
Dan Rich
http://www.employees.org/~drich/
"Step up to red alert!" "Are you sure, sir?
It means changing the bulb in the sign..."

      - Red Dwarf (BBC)

 

--
You received this message because you are subscribed to the Google Groups "wview" group.
To post to this group, send email to wv...@googlegroups.com.
To unsubscribe from this group, send email to wview+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/wview?hl=en.

wmiler

unread,
Jan 31, 2012, 5:24:26 PM1/31/12
to wview
Ok, this should work, posting here for anybody that needs this.

The file below should be named wxnow.shx, and placed in the html
template directory, and added to the html-template.conf file for
generation.

-- CUT HERE --
#!/bin/bash
# wxnow.shx
# Generates a shell script for processing with etc/wview/post-
generate.sh
# to create a wxnow.txt file
# Spec for wxnow.txt file is here: http://wiki.sandaysoft.com/a/Wxnow.txt
#
# 2012 Wyatt Miler CW4149
#

DATE=`date "+%b %d %Y %H:%M"`;
WIND=<!--windDirectionDegrees-->;
WINDSPD=<!--windSpeed-->;
WINDGST=<!--windGustSpeed-->;
OUTTEMPIN=<!--outsideTemp-->;
OUTTEMP=`echo "($OUTTEMPIN+0.05)/1" | bc`;
RAIN=<!--dailyRain-->;
OUTHUM=<!--outsideHumidity-->;
BAROIN=<!--barometer-->;
BARO=`echo "((($BAROIN*33.835)+0.05)*10)/1" | bc`;

echo $DATE > wxnow.txt
printf "%03d/%03dg%03dt%03dP%03dh%03db%05d\n" "$WIND" "$WINDSPD"
"$WINDGST" "$OUTTEMP" "$RAIN" "$OUTHUM" "$BARO" >> wxnow.txt

-- CUT HERE --

In etc/wview/post-generate.sh add the following line:

bash ./wxnow.sh

That should do it.

- Wyatt -

CW4149


On Jan 31, 2:48 pm, drich <dr...@employees.org> wrote:
> I just found the spec -- I think this will do what you're looking
> for:
>
> awk '{print strftime("%b %d %Y %H:%M");
> split($0,a,"b");printf"%sb%dn",a[1],a[2]*338.639}' ~/wxnow.txt
> visit this group athttp://groups.google.com/group/wview?hl=en.
>
>
>
> > --
>
> > Dan Rich
> >http://www.employees.org/~drich/[1]
> > "Step up to red
>
> alert!" "Are you sure, sir?> It means changing the bulb in the
> sign..."
> > - Red Dwarf (BBC)
>
> > --
> > You received this message
>
> because you are subscribed to the Google Groups "wview" group.> To post
>
> to this group, send email to wv...@googlegroups.com.> To unsubscribe
>
> from this group, send email to wview+un...@googlegroups.com.> For
>
> more options, visit this group athttp://groups.google.com/group/wview?hl=en.
>
> --
>
> Dan Rich
> <dr...@employees.org>http://www.employees.org/~drich/[2]
>  "Step up to
> red alert!" "Are you sure, sir?
>  It means changing the bulb in the
> sign..."
>  - Red Dwarf (BBC)
>
> Links:
> ------
> [1]http://www.employees.org/%7Edrich/
> [2]http://www.employees.org/%7Edrich/
Reply all
Reply to author
Forward
0 new messages