]> Pileus Git - ~andy/rsl/blob - wsr88d.h
cc607c79ff01d8782c2a57c90378743dfd307334
[~andy/rsl] / wsr88d.h
1 #ifndef _wsr88d
2 #define _wsr88d
3 #include <stdio.h>
4
5 /* Modify the following to point to the file that contains the 
6  * nexrad (wsr88d) location information for each radar site.
7  * The directory should be the same as the LIBDIR in the makefile.
8  */
9 #ifndef WSR88D_SITE_INFO_FILE
10 #define WSR88D_SITE_INFO_FILE "/usr/local/trmm/GVBOX/lib/wsr88d_locations.dat"
11 #endif
12 /*===============================================================*/
13 typedef struct {
14   char archive2[8];    /* Always ARCHIVE2 */
15   char site_id[4];     /* 4-leter site ID.  e.g. KLMB */
16   char tape_num[6];    /* NCDC tape number. e.g. N00001 */
17   char b1;             /* Blank. */
18   char date[9];        /* Date tape written. dd-MMM-yy e.g. 19-FEB-93 */
19   char b2;             /* Blank. */
20   char time[8];        /* Time tape written.  hh:mm:ss.  e.g. 10:22:59 */
21   char b3;             /* Blank. */
22   char data_center[5]; /* Data Center writing tape: RDASC or NCDC. */
23   char wban_num[5];    /* WBAN number of this NEXRAD site.  This is a 
24                           unique 5-digit number assigned at
25                           NCDC.  Numbers are contained in the NCDC
26                           NEXRAD Station History file.  The file
27                           also contains the four letter site ID,
28                           Latitude, Longitude, Elevation, and
29                           common location name. */
30   char tape_mode[5];   /* Tape output mode.  Current values are 8200, 8500,
31                           8500c. */
32   char volume_num[5];  /* A volume number to be used for copies and
33                           extractions of data from tapes.  The form
34                           would be VOL01, VOL02, VOL03 ... VOLnn. */
35   char b4[6];          /* Blank. Available for future use. */
36   char b5[31552];      /* May be used for internal controls or
37                           other information at each archive center.
38                           Information of value to users will be
39                           documented at the time of tape shipment. */
40 } Wsr88d_tape_header;
41                                                   
42
43 /* Title record structure for nexrad archive2 data file.
44    The first record of each nexrad data file is a title record */
45 typedef struct
46    {
47    char     filename[9];
48    char     ext[3];
49    int      file_date;    /* modified Julian date */
50    int      file_time;    /* milliseconds of day since midnight */
51    char     unused1[4];
52    }
53 nr_archive2_title;
54
55 /* message packet structure for nexrad radar data */
56 typedef struct
57    {
58    short    ctm[6];    /* not used */
59
60    /* halfword 7 : message header information */
61    short    msg_size;  /* # halfwords from here to end of record? */
62    short    msg_type;  /* Digital Radar Data.  This message may contain
63                         * a combination of either reflectivity,
64                         * aliased velocity, or spectrum width.
65                         */
66    short    id_seq;    /* I.d. Seq = 0 to 7FFF, then roll over to 0 */
67    short    msg_date;  /* modified Julian date from 1/1/70 */
68    int      msg_time;  /* packet generation time in ms past midnite */
69    short    num_seg;
70    short    seg_num;
71
72    /* halfword 15 : data header information */
73    int      ray_time;  /* collection time for this ray in ms */
74    short    ray_date;  /* modified Julian date for this ray */
75    short    unam_rng;  /* unambiguous range */
76    short    azm;       /* coded azimuth angle */
77    short    ray_num;   /* ray no. within elevation scan */
78    short    ray_status;/* ray status flag */
79    short    elev;      /* coded elevation angle */
80    short    elev_num;  /* elevation no. within volume scan */
81    
82    /* halfword 24 : gate/bin information*/
83    short    refl_rng;   /* range to first gate of refl data */
84    short    dop_rng;    /* range to first gate of doppler data */
85    short    refl_size;  /* refl data gate size */
86    short    dop_size;   /* doppler data gate size */
87    short    num_refl;   /* no. of reflectivity gates */
88    short    num_dop;    /* no. of doppler gates */
89    
90    /* halfword 30 */
91    short    sec_num;    /* sector no. within cut */
92    float    sys_cal;    /* gain calibration constant */
93
94    /* halfword 33 : data parameters */
95    short    refl_ptr;   /* reflectivity data ptr */ 
96    short    vel_ptr;    /* velocity data ptr */
97    short    spc_ptr;    /* spectrum width ptr */
98    short    vel_res;    /* Doppler velocity resolution */
99    short    vol_cpat;   /* volume coverage pattern */
100    short    unused1[4];
101    
102    /* halfword 42 : data pointers for Archive II playback */
103    short    ref_ptrp;
104    short    vel_ptrp;
105    short    spc_ptrp;
106    
107    /* halfword 45 */
108    short    nyq_vel;    /* Nyquist velocity */
109    short    atm_att;    /* atmospheric attenuation factor */
110    short    min_dif;
111
112    /* halfwords 48 to 64 */
113   short    unused2[17];
114    
115    /* halfwords 65 to 1214 */
116    unsigned char     data[2300];
117
118    /* last 4 bytes : frame check sequence */
119    unsigned char     fts[4];
120    }
121 Wsr88d_packet;
122
123 /* structure for the radar site parameters */
124 typedef struct radar_site {
125     int number;        /* arbitrary number of this radar site */
126     char name[4];      /* Nexrad site name */
127     char city[15];     /* nearest city to  radaar site */
128     char state[2];     /* state of radar site */
129     int latd;   /* degrees of latitude of site */
130     int latm;   /* minutes of latitude of site */
131     int lats;   /* seconds of latitude of site */
132     int lond;   /* degrees of longitude of site */
133     int lonm;   /* minutes of longitude of site */
134     int lons;   /* seconds of longitude of site */
135     int height; /* height of site in meters above sea level*/
136     int bwidth; /* bandwidth of site (mhz) */
137     int spulse; /* length of short pulse (ns)*/
138     int lpulse; /* length of long pulse (ns) */
139 } Wsr88d_site_info;
140
141 typedef struct {
142   FILE *fptr;
143 } Wsr88d_file;
144
145 #define PACKET_SIZE 2432
146 typedef Wsr88d_packet Wsr88d_ray;    /* Same thing, different name. */
147
148
149 #define MAX_RAYS_IN_SWEEP 400
150 typedef struct {
151   Wsr88d_ray *ray[MAX_RAYS_IN_SWEEP];  /* Expected maximum is around 366. */
152 } Wsr88d_sweep;
153
154 typedef union {
155   nr_archive2_title title;
156   Wsr88d_packet p;
157 } Wsr88d_file_header;
158
159 typedef struct {
160   int dummy;     /* Structure not used yet. */
161 } Wsr88d_header;
162
163 typedef struct {
164   int dummy;     /* Structure not used yet. */
165 } Wsr88d_ray_header;
166
167 /* Selected so we can boolean or use them for a data mask. */
168 #define WSR88D_DZ 0x1
169 #define WSR88D_VR 0x2
170 #define WSR88D_SW 0x4
171 #define WSR88D_BADVAL  0500   /* non-meaningful value (500 octal) */
172 #define WSR88D_RFVAL (WSR88D_BADVAL-1) /* ival = 0 means below SNR,
173                                                = 1 means range folded. */
174
175
176 /***********************************************************************/
177 /*                                                                     */
178 /*                   Function specification.                           */
179 /*                                                                     */
180 /***********************************************************************/
181 Wsr88d_file *wsr88d_open(char *filename);
182 int wsr88d_perror(char *message);
183 int wsr88d_close(Wsr88d_file *wf);
184 int wsr88d_read_file_header(Wsr88d_file *wf,
185                                 Wsr88d_file_header *wsr88d_file_header);
186 int wsr88d_read_tape_header(char *first_file,
187                                 Wsr88d_tape_header *wsr88d_tape_header);
188 int wsr88d_read_sweep(Wsr88d_file *wf, Wsr88d_sweep *wsr88d_sweep);
189 int wsr88d_read_ray(Wsr88d_file *wf, Wsr88d_ray *wsr88d_ray);
190 int wsr88d_read_ray_header(Wsr88d_file *wf,
191                                 Wsr88d_ray_header *wsr88d_ray_header);
192 int wsr88d_ray_to_float(Wsr88d_ray *ray,
193                                 int THE_DATA_WANTED, float v[], int *n);
194 float wsr88d_get_nyquist(Wsr88d_ray *ray);
195 float wsr88d_get_atmos_atten_factor(Wsr88d_ray *ray);
196 float wsr88d_get_velocity_resolution(Wsr88d_ray *ray);
197 int   wsr88d_get_volume_coverage(Wsr88d_ray *ray);
198 float wsr88d_get_elevation_angle(Wsr88d_ray *ray);
199 float wsr88d_get_azimuth(Wsr88d_ray *ray);
200 float wsr88d_get_range(Wsr88d_ray *ray);
201 void  wsr88d_get_date(Wsr88d_ray *ray, int *mm, int *dd, int *yy);
202 void  wsr88d_get_time(Wsr88d_ray *ray, int *hh, int *mm, int *ss, float *fsec);
203 Wsr88d_site_info *wsr88d_get_site(char *in_sitenm); /* Courtesy of Dan Austin. */
204 int *wsr88d_get_vcp_info(int vcp_num,int el_num);  /* Courtesy of Dan Austin. */
205 float wsr88d_get_fix_angle(Wsr88d_ray *ray);
206 int   wsr88d_get_pulse_count(Wsr88d_ray *ray);
207 float wsr88d_get_azimuth_rate(Wsr88d_ray *ray);
208 float wsr88d_get_pulse_width(Wsr88d_ray *ray);
209 float wsr88d_get_prf(Wsr88d_ray *ray);
210 float wsr88d_get_prt(Wsr88d_ray *ray);
211 float wsr88d_get_wavelength(Wsr88d_ray *ray);
212 float wsr88d_get_frequency(Wsr88d_ray *ray);
213
214 int no_command (char *cmd);
215 FILE *uncompress_pipe (FILE *fp);
216 FILE *compress_pipe (FILE *fp);
217 int rsl_pclose(FILE *fp);
218
219 #endif