SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-04-29 20:39:54

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

forecast: Query and plot weather information from the command line

forecast is a query program for the forecast.io weather API. It provides a command line interface which makes weather data for a configurable location available in the terminal. It does text output and graphical plots using ncurses. forecast is still under heavy development and features are being added on a rolling basis.

Many aspects, including colors and label formats, can be configured by the user.

Suggestions, bug reports and testers are very welcome.

Output examples
$ forecast -m print
Latitude                 | 52.5161
Longitude                | 13.3770
Timezone                 | Europe/Berlin
-------------------------+
Currently
-------------------------+
   Time                  | Wed Apr 29 22:27:40 2015
   Condition             | Mostly Cloudy
   Temperature           | 9.8 °C
   Apparent temperature  | 8.1 °C
   Dew point             | -1.8 °C
   Precipitation         | 0 %
   RH (φ)                | 44.0 %
   Wind speed            | 11 kph (SSE)
   Cloud cover           | 61 %
   Pressure              | 1017.98 hPa
   Ozone                 | 357.09 DU
$ forecast -m plot-hourly

2015_04_29_220941_1920x1080_scrot.jpg

$ forecast -m plot-daily

2015_04_29_221429_1918x1078_scrot.jpg

Synopsis
Usage:
  forecast [c:dhL:l:m:rv] [OPTIONS]
Options:
  -c|--config            PATH   Configuration file to use
  -d|--dump                     Dump the JSON data and a newline to stdout
  -h|--help                     Print this message and exit
  -L|--location-by-name  NAME   Select a location predefined in the configuration file
  -l|--location          CHOORD Query the weather at this location; CHOORD is a string in the format
                                <latitude>:<longitude> where the choordinates are given as floating
                                point numbers
  -m|--mode              MODE   One of print, print-hourly, plot-hourly, plot-daily, plot-precip-daily,
                                plot-precip-hourly, plot-daylight. Defaults to 'print'
  -r|--request                  By pass the cache if a cache file exists
  -v|--version                  Print program version and exit
Configuration/Documentation

Read the supplied README file. The man page is still incomplete.

You need to read this.

Installation

Debian and Ubuntu users may install the package from the BL-hydrogen repository. Set up the repository, then just do

$ sudo apt-get install forecast

Arch users may install from the AUR: forecast-git.

Source code

The project is being developed on Github: 2ion/forecast.

License

Of course, GPLv3+.

Caveats

No imperial units.

Last edited by twoion (2015-04-30 17:14:18)


Tannhäuser ~ {www,pkg,ddl}.bunsenlabs.org/{gitlog,repoidx}

Offline

Be excellent to each other!

#2 2015-04-29 21:15:32

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: forecast: Query and plot weather information from the command line

I've installed it from the AUR and used the config file provided in the README (with the location co-ordinates changed to London) and I get this (error code given before the prompt on the line after the command):

empty@Arch ~ % forecast -m  plot-daily
[1]    559 segmentation fault (core dumped)  forecast -m plot-daily
139 empty@Arch ~ % uname -a                                                                       :(
Linux Arch 4.0.1-1-ARCH #1 SMP PREEMPT Wed Apr 29 12:00:26 CEST 2015 x86_64 GNU/Linux

Here is my ~/.forecastrc

# forecast.io API key

apikey = "";

# Default mode for forecast when invoked without any command line
# options. Must be one of print, print-hourly, plot-hourly, plot-daily.

op = "print";

# Location coordinates as doubles

location: {
  latitude = 51.5333;
  longitude = 0.0833;
};

# Plot appearance

plot: {

  # The plot's y axis will extend to +/- this value in terminal lines
  height = 10;

  bar: {

    # Bar width in columns
    width = 5;

    # Primary bar color
    # One of: WHITE, BLACK, RED, GREEN, CYAN, BLUE, MAGENTA, YELLOW
    # Name must be uppercase
    color = "RED";

    # Secondary bar color in overlay plots (currently only plot-daily)
    overlay_color = "BLACK";

  };

  legend: {

    # Color used for labels
    color = "WHITE";

    # Color used for highlight/color accents in text
    texthighlight_color = "RED";

  };

  hourly: {

    # plot-hourly: Consecutive hours to plot
    succeeding_hours = 30;

    # Bar labels, see strftime(3) for possible formats
    label_format = "%H:%M";

  };

  daily: {

    # Bar labels, see strftime(3) for possible formats
    label_format = "%d%b";

  };

};

What have I done wrong?

EDIT: Also:

empty@Arch ~ % forecast -m print
Latitude                 | 0.0000
Longitude                | 0.0000
Timezone                 | (null)
-------------------------+
Currently
forecast: render.c:112: render_datapoint: Assertion `o' failed.
[1]    691 abort (core dumped)  forecast -m print
134 empty@Arch ~ %                                                                                :(

My apologies if I've missed something obvious here, I'm very tired ATM...

Last edited by Head_on_a_Stick (2015-04-29 21:17:46)

Offline

#3 2015-04-29 21:55:46

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: forecast: Query and plot weather information from the command line

^ You didn't obtain an API key from https://developer.forecast.io/ and put in into the currently zero-length key "apikey" in the config file smile I currently don't guard against (almost) everything the user could do wrong because, as you know, code first and documentation plus sanity later.

I don't ship a key because I haven't read the TOS of forecast.io, and because API are limited to 1000/day per key.

Sorry. You could use a service such as anonbox.net for getting the key.

Oh and thanks for testing smile

Last edited by twoion (2015-04-29 21:56:54)


Tannhäuser ~ {www,pkg,ddl}.bunsenlabs.org/{gitlog,repoidx}

Offline

#4 2015-04-29 22:19:15

brontosaurusrex
#! Red Menace
Registered: 2012-06-15
Posts: 1,643

Re: forecast: Query and plot weather information from the command line

on wheezy

 make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /home/b/source/forecast/missing aclocal-1.15 
/home/b/source/forecast/missing: line 81: aclocal-1.15: command not found
WARNING: 'aclocal-1.15' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
make: *** [aclocal.m4] Error 127
aclocal --version
aclocal (GNU automake) 1.11.6

I guess it must be Jessie?

Last edited by brontosaurusrex (2015-04-29 22:19:52)

Offline

#5 2015-04-29 22:22:18

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: forecast: Query and plot weather information from the command line

^ No, it doesn't need to be Jessie. This is just autotools...Try running this in the ./forecast directory:

autoreconf --force --install --symlink --make

The error you see happens when the autoconf/automake/aclocal stuff was generated with different autotool versions from what is available on the system.

I should add an 'autogen.sh' script in order to prevent this.

Thanks, I hadn't considered this.
--
Edit: AFK for the night smile

Last edited by twoion (2015-04-29 22:24:52)


Tannhäuser ~ {www,pkg,ddl}.bunsenlabs.org/{gitlog,repoidx}

Offline

#6 2015-04-30 17:06:35

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: forecast: Query and plot weather information from the command line

New 0.3 release.

Precepitation plots (-m plot-precip-daily, -m precip-hourly) and caching have been added (damn fast now!) as well as some checks for user input (-> HoaS big_smile).

The configuration file has gained some more keys, so be sure to use an up-to-date config file!

Updated synopsis:

Usage:
  forecast [c:dhl:m:rv] [OPTIONS]
Options:
  -c|--config    PATH   Configuration file to use
  -d|--dump             Dump the JSON data and a newline to stdout
  -h|--help             Print this message and exit
  -l|--location  CHOORD Query the weather at this location; CHOORD is a string in the format
                        <latitude>:<longitude> where the choordinates are given as floating
                        point numbers
  -m|--mode      MODE   One of print, print-hourly, plot-hourly, plot-daily, plot-precip-daily,
                        plot-precip-hourly. Defaults to 'print'
  -r|--request          By pass the cache if a cache file exists
  -v|--version          Print program version and exit

A fancy pic (water is blue):
2015_04_30_190424_1918x1078_scrot.jpg


Tannhäuser ~ {www,pkg,ddl}.bunsenlabs.org/{gitlog,repoidx}

Offline

#7 2015-04-30 20:33:56

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: forecast: Query and plot weather information from the command line

twoion wrote:

some checks for user input (-> HoaS big_smile).

It is now officially idiot-proof big_smile
Screenshot_2015_04_30_21_24_55.jpg
I love it!

Thanks twoion smile

Is it possible to get a print out for a specific day/date?

Offline

#8 2015-04-30 21:30:04

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: forecast: Query and plot weather information from the command line

Head_on_a_Stick wrote:

Is it possible to get a print out for a specific day/date?

Glad you like it.

No date/time specs yet. Good idea though; the available data however is today+7d and now+48h. I'll got to this when I have the time.


Tannhäuser ~ {www,pkg,ddl}.bunsenlabs.org/{gitlog,repoidx}

Offline

#9 2015-08-25 22:05:20

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: forecast: Query and plot weather information from the command line

Announcing forecast 0.4.

Querying the weather for multiple locations has been made easier.

You can now define an arbitrary number of named locations in the configuration file:

location_map: {
  Berlin: [ 52.5161,  13.3770 ];
  Tokyo:  [ 35.7000, 139.7667 ];
};

and reference these locations directly from the command line instead of having to invoke forecast with explicit coordinates:

$ forecast -L Tokyo # or forecast --location-by-name Tokyo

Correspondingly, the cache system now maintains an extra cache for each unique location.

OpenSSL is a new dependency (for the md5 hash algo).

I hope you like it.


Tannhäuser ~ {www,pkg,ddl}.bunsenlabs.org/{gitlog,repoidx}

Offline

#10 2015-08-27 18:20:23

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: forecast: Query and plot weather information from the command line

forecast 0.5
 - Using LZ4 compression reduces the file size of inidivial 
   cache files from ~20K to ~5K (depending on your filesystem's
   block size, it might still occupy at least one block, for example 8K).
 - Bump to 0.5 since all existing cache files need to be re-genereated.

Feature creep, I say.

The package is now available through the BunsenLabs repository at http://pkg.bunsenlabs.org.


Tannhäuser ~ {www,pkg,ddl}.bunsenlabs.org/{gitlog,repoidx}

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo