File: bscan.c

package info (click to toggle)
librsl 1.42-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,836 kB
  • sloc: ansic: 16,950; sh: 8,544; yacc: 316; perl: 151; lex: 94; makefile: 61
file content (88 lines) | stat: -rw-r--r-- 1,978 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * For RSL version 0.28 and higher.
 *
 * v1.0 Began 2/16/94 by John Merritt.
 *
 * Demonstrates reading NEXRAD files and loading the Radar structure.
 */



#include <stdio.h>
#ifdef sgi
#include <getopt.h>
#endif
#include <stdlib.h>
#include <string.h>

#include "rsl.h"

usage()
{
  fprintf(stderr,"Usage: bscan infile [callid]\n");
  exit(-1);
}

process_args(int argc, char **argv,
			 char **in_file, char **callid)
{
 
  if (argc < 2) usage();
  else if (argc == 2) *in_file = strdup(argv[1]);
  else if (argc == 3) {
	*in_file = strdup(argv[1]);
	*callid  = strdup(argv[2]);
  } else {
	usage();
  }
}


main(int argc, char **argv)
{
  char *infile, *callid;

  Radar *radar;
  Volume *cappi_vol;
  char *index_str[] = {"DZ", "VR", "SW"};

  int i;

/* 1. Process the arguments. */
  callid = NULL;
  process_args(argc, argv, &infile, &callid); /* malloc for in/outfile */


/*
 * Pass bitwise or of DZ_MASK, VR_MASK, SW_MASK
 */
  i = DZ_INDEX;

  RSL_radar_verbose_on();
  if ((radar = RSL_anyformat_to_radar(infile, callid)) == NULL)	exit(-1);

  printf("Radar date: %2.2d/%2.2d/%2.2d\n", radar->h.month, radar->h.day, radar->h.year);
  printf("Radar time: %2.2d:%2.2d:%f\n", radar->h.hour, radar->h.minute, radar->h.sec);

  printf("Radar file: %s\n", infile);
  printf("Radar site: %c%c%c%c\n",
		 radar->h.name[0],
		 radar->h.name[1],
		 radar->h.name[2],
		 radar->h.name[3]);
  printf("Radar date: %2.2d/%2.2d/%2.2d\n", radar->h.month, radar->h.day, radar->h.year);
  printf("Radar time: %2.2d:%2.2d:%f\n", radar->h.hour, radar->h.minute, radar->h.sec);


  if (i == DZ_INDEX) RSL_load_refl_color_table();
  if (i == VR_INDEX) RSL_load_vel_color_table();
  if (i == SW_INDEX) RSL_load_sw_color_table();
  if (i == VR_INDEX) RSL_rebin_velocity_volume(radar->v[i]); /* Modifies v[i]. */

  printf("Generating bscan ppm images of %s\n", index_str[i]);
  RSL_bscan_volume((Volume *) radar->v[i], "bscan.ppm");
  printf("----> BSCAN complete.\n");

  exit(0);

}