]> Pileus Git - ~andy/rsl/blob - wsr88d.h
62490fc80e34da8c1489d65fb64b24015c9af811
[~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/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;                   /* this usually points to the gzip pipe */
143   FILE *orig;                   /* save the original file pointer for cleanup */
144 } Wsr88d_file;
145
146 #define PACKET_SIZE 2432
147 typedef Wsr88d_packet Wsr88d_ray;    /* Same thing, different name. */
148
149
150 #define MAX_RAYS_IN_SWEEP 400
151 typedef struct {
152   Wsr88d_ray *ray[MAX_RAYS_IN_SWEEP];  /* Expected maximum is around 366. */
153 } Wsr88d_sweep;
154
155 typedef union {
156   nr_archive2_title title;
157   Wsr88d_packet p;
158 } Wsr88d_file_header;
159
160 typedef struct {
161   int dummy;     /* Structure not used yet. */
162 } Wsr88d_header;
163
164 typedef struct {
165   int dummy;     /* Structure not used yet. */
166 } Wsr88d_ray_header;
167
168 /* Selected so we can boolean or use them for a data mask. */
169 #define WSR88D_DZ 0x1
170 #define WSR88D_VR 0x2
171 #define WSR88D_SW 0x4
172 #define WSR88D_BADVAL  0500   /* non-meaningful value (500 octal) */
173 #define WSR88D_RFVAL (WSR88D_BADVAL-1) /* ival = 0 means below SNR,
174                                                = 1 means range folded. */
175
176
177 /***********************************************************************/
178 /*                                                                     */
179 /*                   Function specification.                           */
180 /*                                                                     */
181 /***********************************************************************/
182 Wsr88d_file *wsr88d_open(char *filename);
183 int wsr88d_perror(char *message);
184 int wsr88d_close(Wsr88d_file *wf);
185 int wsr88d_read_file_header(Wsr88d_file *wf,
186                                 Wsr88d_file_header *wsr88d_file_header);
187 int wsr88d_read_tape_header(char *first_file,
188                                 Wsr88d_tape_header *wsr88d_tape_header);
189 int wsr88d_read_sweep(Wsr88d_file *wf, Wsr88d_sweep *wsr88d_sweep);
190 int wsr88d_read_ray(Wsr88d_file *wf, Wsr88d_ray *wsr88d_ray);
191 int wsr88d_read_ray_header(Wsr88d_file *wf,
192                                 Wsr88d_ray_header *wsr88d_ray_header);
193 int wsr88d_ray_to_float(Wsr88d_ray *ray,
194                                 int THE_DATA_WANTED, float v[], int *n);
195 float wsr88d_get_nyquist(Wsr88d_ray *ray);
196 float wsr88d_get_atmos_atten_factor(Wsr88d_ray *ray);
197 float wsr88d_get_velocity_resolution(Wsr88d_ray *ray);
198 int   wsr88d_get_volume_coverage(Wsr88d_ray *ray);
199 float wsr88d_get_elevation_angle(Wsr88d_ray *ray);
200 float wsr88d_get_azimuth(Wsr88d_ray *ray);
201 float wsr88d_get_range(Wsr88d_ray *ray);
202 void  wsr88d_get_date(Wsr88d_ray *ray, int *mm, int *dd, int *yy);
203 void  wsr88d_get_time(Wsr88d_ray *ray, int *hh, int *mm, int *ss, float *fsec);
204 Wsr88d_site_info *wsr88d_get_site(char *in_sitenm); /* Courtesy of Dan Austin. */
205 int *wsr88d_get_vcp_info(int vcp_num,int el_num);  /* Courtesy of Dan Austin. */
206 float wsr88d_get_fix_angle(Wsr88d_ray *ray);
207 int   wsr88d_get_pulse_count(Wsr88d_ray *ray);
208 float wsr88d_get_azimuth_rate(Wsr88d_ray *ray);
209 float wsr88d_get_pulse_width(Wsr88d_ray *ray);
210 float wsr88d_get_prf(Wsr88d_ray *ray);
211 float wsr88d_get_prt(Wsr88d_ray *ray);
212 float wsr88d_get_wavelength(Wsr88d_ray *ray);
213 float wsr88d_get_frequency(Wsr88d_ray *ray);
214 void wsr88d_keep_hi_prf_dz();
215 void wsr88d_no_hi_prf_dz();
216
217 int no_command (char *cmd);
218 FILE *uncompress_pipe (FILE *fp);
219 FILE *compress_pipe (FILE *fp);
220 int rsl_pclose(FILE *fp);
221
222 #endif