home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: rodmur@ecst.csuchico.edu (Dale Harris)
- Subject: v34i120: getwxmap - Retrieve and display Weather satellite maps, Part01/01
- Message-ID: <1993Jan18.185414.27374@sparky.imd.sterling.com>
- X-Md4-Signature: a7f3369e7992aabfc8197f2a364d5074
- Date: Mon, 18 Jan 1993 18:54:14 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: rodmur@ecst.csuchico.edu (Dale Harris)
- Posting-number: Volume 34, Issue 120
- Archive-name: getwxmap/part01
- Environment: X11, UNIX, xv
-
- Getwxmap is a relatively simple untility that retrieves the most recent
- weather satellite maps from vmd.cso.uiuc.edu and displays them on a
- X-windows display.
-
- Special Thanks to Emma Pease <emma@Russell.Stanford.EDU> for the man page!
-
- USAGE: getwxmap [ -D -R -d -b -s -r -v -u# ]
- -D if you don't want the files displayed
- -R if you don't want the files removed after displaying
- -b Display in background on root window
- -d for debugging
- -s Retrieves the current Surface Anaylsis Map (this usually gets
- made a little before 15 minutes after the hour, so WXMAP
- doesn't grab it until 15 minutes or later after the hour)
- -r Retrieves the most recent Infra Red Light Map
- -v Retrieves the most recent Visible Light Map
- -u# Retrieves the most recent Upper Air maps at a # * 100hPa itervals
- (# = 2,3,5,7,8 for 200hPa, 300hPa, 500hPa, 700hPa, 800hPa respectively)
-
- Dale Harris
- ---------------------------------- cut here ----------------------------------
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: README Makefile getwxmap.1 getwxmap.c
- # Wrapped by kent@sparky on Mon Jan 18 12:44:28 1993
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 1 (of 1)."'
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(429 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XCheck out the Makefile, if your on a SYSV machine you might want to
- X-DSYSV, check out the #define fields also in the source, be sure also to
- Xset the -DDOMAIN in the Makefile to your site name. Also this has been
- Xconverted to ANSI Standard C, just something to keep in mind when you edit
- Xthe Makefile. If you find any bugs or have any suggestions e-mail:
- Xrodmur@ecst.csuchico.edu
- X
- XThanx!
- X
- XDale Harris {rodmur@ecst.csuchico.edu}
- END_OF_FILE
- if test 429 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(640 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- X#
- X# Makefile for getwxmap.c ver 2.21
- X# Copyright (C) January 13, 1993 by Dale A. Harris
- X# {rodmur@ecst.csuchico.edu}
- X#
- XCC=gcc
- X#CC=cc
- X
- X# Remember to switch on the ANSI flag for your compiler
- X#AFLAG= -Aa #for hp compilers
- XAFLAG= -ansi # for gcc
- X
- XCFLAGS= -g # for debugging
- X#CFLAGS=-O #most machines in this world
- X#CFLAGS=-O2 #for gcc
- X#CFLAGS= +O3 # with cc on HP9000/7xx-series running HPUX 8.*
- X
- X#Be sure to set your own domain name here.
- XDEFINES= -DSYSV -DDOMAIN=\"ecst.csuchico.edu\"
- X
- Xgetwxmap: getwxmap.c
- X $(CC) $(CFLAGS) $(AFLAG) -o getwxmap $(DEFINES) getwxmap.c
- X
- Xclean:
- X rm -f getwxmap.o getwxmap core
- END_OF_FILE
- if test 640 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'getwxmap.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'getwxmap.1'\"
- else
- echo shar: Extracting \"'getwxmap.1'\" \(1109 characters\)
- sed "s/^X//" >'getwxmap.1' <<'END_OF_FILE'
- X.TH GETWXMAP 1 "30 November 1992"
- X.SH NAME
- Xgetwxmap \- retrieve weather maps and display on X11 displays
- X.SH SYNOPSIS
- X.B getwxmap
- X.RB [ " \-D -R -d -b -s -r -v -u#" ]
- X.SH DESCRIPTION
- X.B getwxmap
- Xretrieves the most recent of any of the various weather maps at
- Xvmd.cso.uiuc.edu and displays them using xv.
- X.SH OPTIONS
- X.TP
- X.B \-D
- Xdon't display file.
- X.TP
- X.B \-R
- Xdon't remove file when program finishes.
- X.TP
- X.B \-b
- Xdisplay in background on root window.
- X.TP
- X.B \-d
- Xdebugging.
- X.TP
- X.B \-s
- Xretrieves the current Surface Anaylsis Map (this usually gets
- Xmade a little before 15 minutes after the hour, so WXMAP
- Xdoesn't grab it until 15 minutes or later after the hour).
- X.TP
- X.B \-r
- Xretrieves the most recent Infra Red Light Map.
- X.TP
- X.B \-v
- Xretrieves the most recent Visible Light Map.
- X.TP
- X.B \-u#
- Xretrieves the most recent Upper Air maps at a (# * 100hPa) intervals
- X(# = 2,3,5,7,8 for 200hPa, 300hPa, 500hPa, 700hPa, 800hPa respectively).
- X.SH SEE ALSO
- X.BR xv (1V),
- X.SH AUTHOR
- XThis program is written by Dale A. Harris (rodmur@ecst.csuchico.edu).
- XMany thanks to Emma Pease <emma@Russell.Stanford.EDU> for this man page!
- END_OF_FILE
- if test 1109 -ne `wc -c <'getwxmap.1'`; then
- echo shar: \"'getwxmap.1'\" unpacked with wrong size!
- fi
- # end of 'getwxmap.1'
- fi
- if test -f 'getwxmap.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'getwxmap.c'\"
- else
- echo shar: Extracting \"'getwxmap.c'\" \(8259 characters\)
- sed "s/^X//" >'getwxmap.c' <<'END_OF_FILE'
- X/*
- X @(#) getwxmap 2.21, January 15, 1993
- X
- X Copyright (C) 1993, Dale A. Harris (rodmur@ecst.csuchico.edu)
- X
- X This program may be freely re-distributed at no charge provided that
- X this notice is left intact. Modified copies must preserve this notice.
- X It is requested that any useful changes you make be sent to the author.
- X
- X WXMAP:
- X Is a C program that was converted from a shell script I wrote to retrieve the
- X most recent of any the various weather maps at vmd.cso.uiuc.edu and display
- X them using some utility similar to xv (xv is a multi-purpose GIF, JPEG,
- X etc., displayer for X-windows, written by John Bradley
- X (bradley@cis.upenn.edu))
- X
- X Much thanks to Charlie Kline (cvk@uiuc.edu), and all the others I may
- X not know about, for their work on publicly available satellite weather
- X images
- X
- X Thanks a bunch to all with bug reports and fixes.
- X
- X Special Thanks to Emma Pease <emma@Russell.Stanford.EDU> for the man page!
- X
- X USAGE: getwxmap [ -D -R -d -b -s -r -v -u# ]
- X -D if you don't want the files displayed
- X -R if you don't want the files removed after displaying
- X -b Display in background on root window
- X -d for debugging
- X -s Retrieves the current Surface Anaylsis Map (this usually gets
- X made a little before 15 minutes after the hour, so WXMAP
- X doesn't grab it until 15 minutes or later after the hour)
- X -r Retrieves the most recent Infra Red Light Map
- X -v Retrieves the most recent Visible Light Map
- X -u# Retrieves the most recent Upper Air maps at a # * 100hPa itervals
- X (# = 2,3,5,7,8 for 200hPa, 300hPa, 500hPa, 700hPa, 800hPa respectively)
- X*/
- X
- X#include <stdio.h>
- X#include <time.h>
- X#include <stdlib.h>
- X#ifdef SYSV
- X#include <malloc.h>
- X#endif
- X#include <string.h>
- X#include <unistd.h>
- X
- X#define SMAX 7
- X#define SITE "vmd.cso.uiuc.edu"
- X#define DIR "wx"
- X#define DISP "xv"
- X#ifndef DOMAIN
- X#define DOMAIN "SomewhereStupid"
- X#endif
- X#define UMAPNO 5 /* number of umaps */
- X#define UMAP1 2
- X#define UMAP2 3
- X#define UMAP3 5
- X#define UMAP4 7
- X#define UMAP5 8
- X#define UMAPHOURMADE 3
- X#define UMAPMINMADE 5 /* minutes past the hour that the U*.GIF's made */
- X#define SMAPMINMADE 15 /* Minutes past the hour that SA*.GIF made */
- X
- X
- X/*
- X don't use the -quit option here with xv, it won't work properly if you
- X want to display more than one picture
- X*/
- X#define BKGRDOPTS "-root -maxpect"
- X
- Xmain (int argc, char **argv)
- X{
- X
- X time_t seconds_off;
- X struct tm *tp, *otp, *tptmp, *thetime ();
- X char *mnthday, *gmt, *wgifs, *dispstr, *command, *filename, *uhour, *temp;
- X int background = 0, surface = 0, visible = 0, infrared = 0, nodis = 0,
- X norm = 0, debug = 0, upair = 0, i, j;
- X short int hpa[UMAPNO] =
- X {UMAP1, UMAP2, UMAP3, UMAP4, UMAP5}; /* the pressures for the umaps */
- X FILE *tosite;
- X void usage ();
- X
- X
- X mnthday = (char *) calloc (5, sizeof (char));
- X gmt = (char *) calloc (7, sizeof (char));
- X wgifs = (char *) calloc (100, sizeof (char));
- X dispstr = (char *) calloc (150, sizeof (char));
- X uhour = (char *) calloc (3, sizeof (char));
- X command = (char *) calloc (30, sizeof (char));
- X filename = (char *) calloc (30, sizeof (char));
- X
- X if (argc == 1)
- X {
- X fprintf (stderr, "%s: Pick an option\n", argv[0]);
- X usage ();
- X exit (1);
- X }
- X for (i = 1; i < argc; ++i)
- X for (j = (argv[i][0] == '-') ? 1 : 0; j < strlen (argv[i]); ++j)
- X switch (argv[i][j])
- X {
- X case 's':
- X ++surface;
- X break;
- X case 'b':
- X ++background;
- X break;
- X case 'r':
- X ++infrared;
- X break;
- X case 'v':
- X ++visible;
- X break;
- X case 'u':
- X switch (argv[i][++j] & 15)
- X {
- X case 2:
- X upair |= 1;
- X break;
- X case 3:
- X upair |= 2;
- X break;
- X case 5:
- X upair |= 4;
- X break;
- X case 7:
- X upair |= 8;
- X break;
- X case 8:
- X upair |= 16;
- X break;
- X default:
- X fprintf (stderr, "%s: Unavailable map: %i\n", argv[0], argv[i][j] & 15);
- X exit (1);
- X }
- X break;
- X case 'D':
- X ++nodis;
- X break;
- X case 'R':
- X ++norm;
- X break;
- X case 'd':
- X ++debug;
- X break;
- X default:
- X fprintf (stderr, "%s: Bad Option: %c\n", argv[0], argv[i][j]);
- X usage ();
- X exit (1);
- X }
- X
- X /* getting the time */
- X otp = tp = thetime ((time_t) 0, tp, argv[0]);
- X strftime (gmt, SMAX, "%m%d%H", tp);
- X
- X if (surface)
- X if (tp->tm_min >= SMAPMINMADE)
- X sprintf (wgifs, " SA%s.GIF ", gmt);
- X else
- X {
- X fprintf (stderr, "%s: SA%s.GIF not made until %d past the hour, getting last hours map.\n", argv[0], gmt, SMAPMINMADE);
- X /* Take off an hour's worth of seconds if before the quarter hour */
- X tp = thetime ((time_t) 3600, tp, argv[0]);
- X strftime (gmt, SMAX, "%m%d%H", tp);
- X sprintf (wgifs, " SA%s.GIF ", gmt);
- X tptmp = tp;
- X tp = otp;
- X free (tptmp);
- X }
- X if (infrared)
- X strcat (wgifs, " CIR.GIF ");
- X if (visible)
- X strcat (wgifs, " CVIS.GIF ");
- X if (upair)
- X /*
- XThe GMT hours of 3 to 15 was my best guess when the upperair maps
- Xget made, but on occasion it appears to be differant, so all I can
- Xsay is best of luck!
- X*/
- X {
- X if (tp->tm_hour < 3)
- X {
- X /* if at 0 to 2 GMT take off the (hour + 1) times an hours worth of seconds */
- X seconds_off = (tp->tm_hour + 1) * 3600;
- X tp = thetime (seconds_off, tp, argv[0]);
- X strftime (mnthday, SMAX, "%m%d", tp);
- X tptmp = tp;
- X tp = otp;
- X free (tptmp);
- X }
- X else
- X strftime (mnthday, SMAX, "%m%d", tp);
- X
- X for (i = 0; i <= (UMAPNO - 1); ++i)
- X {
- X if (upair & 1)
- X {
- X
- X /* attach proper hour onto the end of u*.gifs */
- X strcpy (uhour, ((tp->tm_hour >= UMAPHOURMADE)
- X && (tp->tm_hour < (UMAPHOURMADE + 12))) ? "00" : "12");
- X
- X /* if it is the hours that the u*.gifs are made and if not 5 past the
- X hour, then don't get them */
- X
- X if (((tp->tm_hour == UMAPHOURMADE)
- X || (tp->tm_hour == (UMAPHOURMADE + 12)))
- X && (tp->tm_min < UMAPMINMADE))
- X fprintf (stderr, "%s: wait until %d after the hour for U%d%s%s.GIF\n", argv[0], UMAPMINMADE, hpa[i], mnthday, uhour);
- X else
- X {
- X temp = (char *) strdup (wgifs);
- X sprintf (wgifs, " %s U%d%s%s.GIF ", temp, hpa[i], mnthday, uhour);
- X free (temp);
- X }
- X }
- X upair >>= 1;
- X }
- X }
- X
- X /* Using ftp to grab the files */
- X
- X if (strlen (wgifs) != 0)
- X {
- X if (debug)
- X sprintf (command, "ftp -i -n -v %s", SITE);
- X else
- X sprintf (command, "ftp -i -n %s", SITE);
- X
- X if ((tosite = (FILE *) popen (command, "w")) == (FILE *) NULL)
- X {
- X fprintf (stderr, "%s: Can't popen!?!", argv[0]);
- X exit (1);
- X }
- X fprintf (tosite, "user anonymous %s@%s\n", getlogin (), DOMAIN);
- X fputs ("bin\n", tosite);
- X fprintf (tosite, "cd %s\n", DIR);
- X fprintf (tosite, "mget %s\n", wgifs);
- X fputs ("quit\n", tosite);
- X pclose (tosite);
- X
- X if (!nodis)
- X {
- X if (background)
- X sprintf (dispstr, "%s %s %s", DISP, BKGRDOPTS, wgifs);
- X else
- X sprintf (dispstr, "%s %s", DISP, wgifs);
- X system (dispstr);
- X }
- X
- X if (!norm)
- X {
- X filename = strtok (wgifs, " ");
- X while (filename != (char *) NULL)
- X {
- X /* no use checking what unlink returns because I don't care */
- X unlink (filename);
- X filename = strtok ((char *) NULL, " ");
- X }
- X }
- X }
- X exit (0);
- X}
- X
- Xstruct tm *
- Xthetime (time_t s_off, struct tm *tp, char *name)
- X{
- X time_t datime;
- X
- X if ((datime = time ((time_t *) NULL)) == (time_t) - 1)
- X {
- X fprintf (stderr, "%s: time unavailable?!?\n", name);
- X exit (1);
- X }
- X datime -= s_off;
- X if ((tp = gmtime (&datime)) == (struct tm *) NULL)
- X {
- X fprintf (stderr, "%s: Coordinated Universal Time unavailable??\n", name);
- X exit (1);
- X }
- X return (tp);
- X}
- X
- Xvoid
- Xusage ()
- X{
- X fputs ("Usage: getwxmap [ -R -D -d -s -r -v -u# ]\n", stderr);
- X fputs ("getwxmap [ -RDdsrvu# ]\n", stderr);
- X fputs ("getwxmap [ RDdsrvu# ]\n", stderr);
- X fputs ("-D if you don't want the files displayed\n", stderr);
- X fputs ("-R if you don't want the files removed after displaying\n", stderr);
- X fputs ("-b for background, root window\n", stderr);
- X fputs ("-d for debugging\n", stderr);
- X fputs ("-s For the Surface Anaylsis map\n", stderr);
- X fputs ("-r for the Infra Red Light Map\n", stderr);
- X fputs ("-v for Visible Light Map\n", stderr);
- X fputs ("-u# for the Upper Air maps at a # * 100 hPa itervals\n", stderr);
- X fputs ("(# = 2,3,5,7,8 for 200hPa, 300hPa, 500hPa, 700hPa, 800hPa respectively)\n", stderr);
- X return;
- X}
- END_OF_FILE
- if test 8259 -ne `wc -c <'getwxmap.c'`; then
- echo shar: \"'getwxmap.c'\" unpacked with wrong size!
- fi
- # end of 'getwxmap.c'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-