[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20010503: New VGF product




>From: "Glenn Rutledge" <address@hidden>
>Organization: NCDC
>Keywords: 200105031513.f43FDwp17256
> 
>
> Steve,
> Thanks much for the redbook soultions.  It's now finally working.  I've
> just been asked if I can plot the attached "redbook" graphic file NCDC
> receives form the NWS OSO servers (I think).  I can't make any sense of
> the data just looking at it (don't know how the create these files, or
> wheter they even have headers- I think they concatenate many products
> into single files).
> 
> My questions is, how would you try and run the redbook "decoder" on this
> file?   Thx much  Glenn
> 
> 
> 

Glenn,
 
The GEMPAK redbook graphics library routines are not set up to look
for more than 1 product in a file. Also, as you suspected, the file
you sent doesn't contain a transmission header like the products on
the NOAAPORT broadcast do, so my dcredbook program isn't going
to solve your problem.
 
The best solution I can offer you is a short program to dump out the
individual redbook graphics products from what I found by looking through
the file you sent me. Its an example- you might have to tweak later
depending on your data files since I only had a small sample of data to
look at. After you dump out the individual redbook graphics
to separate files, you can either use dcredbook on each individually
to create a separate vgf file, or use GPMAP to draw each graphic to a common or
separate files.
 
 
The attatchment you sent me had 4 redbook products contained within it.
The products (not really a coherent set of products!) were:
1) severe weather reports
2) day2 convective outlook
3) 96 hour 500mb heigh lables
4) 72 hour 500mb heigh lables

The separator between each product seemed to be:
#### some_numbers ####
So, I created the attatched parse.c program (compile with cc -o parse parse.c)
to take the pieces (keying on the 4 "#" characters) and wrap them with
a FOS header and trailer and dump out to separate files.
 
Running "parse glenn.dat" (glenn.dat was your attatched file) gives me
4 files:
7408 May 15 12:43 redbook_0.dat
1110 May 15 12:43 redbook_1.dat
6652 May 15 12:43 redbook_2.dat
6478 May 15 12:43 redbook_3.dat
 
From here, I can run each through dcredbook to create vgf files:

 % set FILES=`ls redbook_*.dat`
 % foreach FILE ($FILES)
 %    cat $FILE | dcredbook_vg -d - 'VG|%P-YYYYMMDDHH.vgf'
 % end
 

Or, here is an example script for running GPMAP (set the DEVICE to xw, vg etc
depending on your needs!)

#!/bin/csh -f
# 
# Sample script to plot all files named redbook_*.dat using gpmap.
# Each redbook graphic file will be plotted in a separate color.

set FILES=`ls redbook_*.dat`

@ CNT = 0
@ LINE_COLOR = 6

foreach FILE ($FILES)

if($CNT == 0) then
   set CLEAR=yes
else
   set CLEAR=no
endif

gpmap << EOF
 MAP      = 1
 GAREA    = AFNA
 PROJ     = str/90;-105;0
 SATFIL   =  
 RADFIL   =  
 LATLON   = 0
 PANEL    = 0
 TITLE    = 1
 TEXT     = 1
 CLEAR    = $CLEAR
 DEVICE   = XW
 LUTFIL   =  
 STNPLT   =  
 VGFILE   =  
 AFOSFL   =  
 AWPSFL   = $FILE
 LINE     = $LINE_COLOR
 WATCH    =  
 WARN     =  
 HRCN     =  
 ISIG     =  
 LTNG     =  
 ATCF     =  
 AIRM     =  
 NCON     =  
 SVRL     =
 r

 e
EOF

@ CNT = $CNT + 1
@ LINE_COLOR = $LINE_COLOR - 1
if($LINE_COLOR == 1) @ LINE_COLOR = 30

end

############### end of csh script ##################

Hope this helps.
Steve Chiswell
Unidata User SUpport

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

main(int argc, char *argv[])
{
int fd,ofd=0,outnum=0;
int cnt=0,seq=0;
int INPROD=0;
char buf[80], filnm[256];

static const char *FOS_HEAD="\001\015\015\012999 \015\015\012";
static const char *FOS_TRAILER="\015\015\012\003";
static int FOSHLEN=11,FOSTLEN=4;

fd = open(argv[1], O_RDONLY);

while(read(fd,buf,1) > 0)
   {
   if(buf[0] == '#')
      seq++;
   else
      seq=0;

   if(seq == 4)
      {
      printf("found start %d\n",cnt);
      INPROD++;
      }

   if(INPROD == 2)
      {
      if(ofd == 0)
         {
         sprintf(filnm,"redbook_%d.dat\0",outnum); outnum++;
         ofd = open(filnm, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
         write(ofd,FOS_HEAD,FOSHLEN-1);
         }
      else
         write(ofd, buf, 1);
      }

   if(INPROD == 3)
      {
      write(ofd,FOS_TRAILER,FOSTLEN);
      close(ofd); ofd = 0;
      INPROD = 1;
      }

   cnt++;
   }

if(ofd != 0)
   {
   write(ofd,FOS_TRAILER,FOSTLEN);
   close(ofd);
   }

printf("look cnt %d\n",cnt);

}

Attachment: glenn.dat
Description: glenn.dat