]> Pileus Git - ~andy/rsl/blob - src/rsl.h
Merge branch 'master' into aweather
[~andy/rsl] / src / rsl.h
1 /*
2     NASA/TRMM, Code 910.1.
3     This is the TRMM Office Radar Software Library.
4     Copyright (C) 1996  John H. Merritt
5                         Space Applications Corporation
6                         Vienna, Virginia, a NASA/GSFC on-site contractor.
7
8     This library is free software; you can redistribute it and/or
9     modify it under the terms of the GNU Library General Public
10     License as published by the Free Software Foundation; either
11     version 2 of the License, or (at your option) any later version.
12
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16     Library General Public License for more details.
17
18     You should have received a copy of the GNU Library General Public
19     License along with this library; if not, write to the Free
20     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22 #ifndef _rsl_h
23 #define _rsl_h
24
25 /* Are we building the library? */
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 /**********************************************************************/
31 /* Configure: Define USE_TWO_BYTE_PRECISION to have RSL store internal*/
32 /*            values with two bytes.  Otherwise, use one byte.        */
33 /*            It is a good idea to use two byte precision.            */
34 /*            See 'makefile' for an additional explaination.          */
35 /*                                                                    */
36 /**********************************************************************/
37 #define USE_TWO_BYTE_PRECISION
38
39
40 /**********************************************************************/
41 /* Configure: Define the file name of the red,green, and blue color   */
42 /*            color tables.  This maps reflectance to color.          */
43 /*            This should be $(LIBDIR)/colors, from the makefile      */
44 /*            so you shouldn't have to modify anything here.          */
45 /**********************************************************************/
46 #ifndef COLORDIR
47 #define COLORDIR DATADIRRSL "/colors"
48 #endif
49
50 /* These are the color table indexes. See RSL_set/get_color_table. */
51 #define RSL_RED_TABLE   0
52 #define RSL_GREEN_TABLE 1
53 #define RSL_BLUE_TABLE  2
54
55 /* The default color tables for reflectivity, velocity, spectral width,
56  * height, rainfall, and zdr.
57  */
58 #define REFL_RED_FILE       COLORDIR "/red_reflectivity.clr"
59 #define REFL_GREEN_FILE     COLORDIR "/grn_reflectivity.clr"
60 #define REFL_BLUE_FILE      COLORDIR "/blu_reflectivity.clr"
61 #define VEL_RED_FILE        COLORDIR "/red_velocity.clr"
62 #define VEL_GREEN_FILE      COLORDIR "/grn_velocity.clr"
63 #define VEL_BLUE_FILE       COLORDIR "/blu_velocity.clr"
64 #define SW_RED_FILE         COLORDIR "/red_spectral_width.clr"
65 #define SW_GREEN_FILE       COLORDIR "/grn_spectral_width.clr"
66 #define SW_BLUE_FILE        COLORDIR "/blu_spectral_width.clr"
67 #define HEIGHT_RED_FILE     COLORDIR "/red_height.clr"
68 #define HEIGHT_GREEN_FILE   COLORDIR "/grn_height.clr"
69 #define HEIGHT_BLUE_FILE    COLORDIR "/blu_height.clr"
70 #define RAINFALL_RED_FILE   COLORDIR "/red_rainfall.clr"
71 #define RAINFALL_GREEN_FILE COLORDIR "/grn_rainfall.clr"
72 #define RAINFALL_BLUE_FILE  COLORDIR "/blu_rainfall.clr"
73
74 /* Added by D. Wolff 07/31/97 */
75 #define ZDR_RED_FILE   COLORDIR "/red_zdr.clr"
76 #define ZDR_GREEN_FILE COLORDIR "/grn_zdr.clr"
77 #define ZDR_BLUE_FILE  COLORDIR "/blu_zdr.clr"
78
79 /*************************************************************************/
80 /*  You should not have to change anything below this line.
81  *  The rest is my fault.
82  */
83 /*************************************************************************/
84 #include <stdio.h>
85
86 /*
87  * Magic numbers.  These are used to uniquely identify the type of 
88  * values present in a particular structure: Volume, Sweep, Ray.
89  * The magic numbers V_DZ, V_VR, V_SW, etc.  represent Volume magic
90  * numbers for the field types DZ, VR, SW, etc.  Similiar magic numbers
91  * are implimented for Sweep, and Ray.  The magic number is the first word
92  * of the data structure.  These magic number may determine which conversion
93  * function is used, see volume.c and the end of this file for the
94  * conversion functions. (As of v0.39 -- NOT YET IMPLEMENTED.)
95  */
96 enum Rsl_magic_num {
97   V_DZ, V_VR, V_SW, V_CZ, V_ZT, V_DR, V_LR,
98   S_DZ, S_VR, S_SW, S_CZ, S_ZT, S_DR, S_LR,
99   R_DZ, R_VR, R_SW, R_CZ, R_ZT, R_DR, R_LR
100 };
101
102 /* File format types recognized by RSL. */
103 enum File_type {UNKNOWN, WSR88D_FILE, UF_FILE, LASSEN_FILE,
104                 TOGA_FILE, NSIG_FILE_V1, NSIG_FILE_V2,
105                 RSL_FILE, MCGILL_FILE, HDF_FILE, RAPIC_FILE,
106                 RADTEC_FILE, DORADE_FILE, RAINBOW_FILE};
107
108 /* Pick a BADVAL that is out of range. That is, the range
109  * of the conversion cannot include these reserved values.
110  * Typically, pick a number that cannot be stored in the Range data type.
111  */
112 #ifdef USE_TWO_BYTE_PRECISION
113   typedef unsigned short Range;
114 #define BADVAL  (float)0x20000
115 #else
116   typedef unsigned char Range;
117 #define BADVAL  (float)0500     /* non-meaningful value (500 octal) */
118 #endif
119
120 #define RFVAL (BADVAL-1) /* Range folded value.  See rfival. */
121 #define APFLAG (BADVAL-2)
122 #define NOTFOUND_H (BADVAL-3)
123 #define NOTFOUND_V (BADVAL-4)
124 #define NOECHO (BADVAL-5) /* For nsig and UF -32, for kwaj -30 */
125 #define RSL_SPEED_OF_LIGHT 299792458.0 /* m/s */
126
127 typedef struct {
128   int   month; /* Time for this ray; month (1-12). */
129   int   day;   /* Time for this ray; day (1-31).   */
130   int   year;  /* Time for this ray; year (eg. 1993). */
131   int   hour;  /* Date for this ray; hour (0-23). */
132   int   minute;/* Date for this ray; minute (0-59).*/
133   float sec;   /* Date for this ray; second + fraction of second. */
134   float unam_rng;  /* Unambiguous range. (KM). */
135   float azimuth;   /* Azimuth angle (degrees). Must be positive.
136                     * 0=North, 90=east, -90/270=west.
137                     * This angle is the mean azimuth for the whole ray.
138                     * E.g. for NSIG the beginning and end azimuths are averaged.
139                     */
140   int   ray_num;    /* Ray no. within elevation scan. */
141   float elev;       /* Elevation angle. (degrees). */
142   int   elev_num;   /* Elevation no. within volume scan. */
143   
144   int   range_bin1; /* Range to first gate.(meters) */
145   int   gate_size;  /* Data gate size (meters)*/
146   
147   float  vel_res;   /* Doppler velocity resolution */
148   float sweep_rate; /* Sweep rate. Full sweeps/min. */
149   
150   int prf;          /* Pulse repetition frequency, in Hz. */
151   int prf2;         /* Second PRF, for Sigmet dual PRF */
152   float azim_rate;  /* Sweep rate in degrees/sec. */
153   float fix_angle;  /* Elevation angle for the sweep. (degrees). */
154   float pitch;      /* Pitch angle. */
155   float roll;       /* Roll  angle. */
156   float heading;    /* Heading. */
157   float pitch_rate; /* (angle/sec) */
158   float roll_rate;  /* (angle/sec) */
159   float heading_rate; /* (angle/sec) */
160   float lat;          /* Latitude (degrees) */
161   float lon;          /* Longitude (degrees) */
162   int   alt;          /* Altitude (m) */
163   float rvc;          /* Radial velocity correction (m/sec) */
164   float vel_east;     /* Platform velocity to the east (negative for west) (m/sec) */
165   float vel_north;    /* Platform velocity to the north (negative south) (m/sec) */
166   float vel_up;       /* Platform velocity toward up (negative down) (m/sec) */
167   int   pulse_count; /* Pulses used in a single dwell time. */
168   float pulse_width; /* Pulse width (micro-sec). */
169   float beam_width;  /* Beamwidth in degrees. */
170   float frequency;   /* Carrier freq. GHz. */
171   float wavelength;  /* Wavelength. Meters. */
172   float nyq_vel;     /* Nyquist velocity. m/s */
173   float (*f)(Range x);       /* Data conversion function. f(x). */
174   Range (*invf)(float x);    /* Data conversion function. invf(x). */
175   int   nbins;               /* Number of array elements for 'Range'. */
176 } Ray_header;
177
178
179 typedef struct {              
180    Ray_header h;
181    Range *range;    /* range[0..nbins-1] 
182                      * For wsr88d file:
183                      * 0..460 for reflectivity, 0..920 for velocity and
184                      * spectrum width.
185                      */
186    } Ray;
187
188
189 typedef struct _azimuth_hash {
190   Ray *ray; 
191   struct _azimuth_hash *next, *ray_high, *ray_low;
192 } Azimuth_hash;
193
194 typedef struct {
195   Azimuth_hash **indexes;
196   int nindexes;
197 } Hash_table;
198
199
200 typedef struct {
201   int sweep_num;   /* Integer sweep number.  This may be redundant, since
202                     * this will be the same as the Volume.sweep array index.*/
203   float elev;      /* Elevation angle (mean) for the sweep. Value is -999 for
204                     * RHI. */
205   float azimuth;   /* Azimuth for the sweep (RHI). Value is -999 for PPI. */
206   float beam_width;  /* This is in the ray header too. */
207   float vert_half_bw;  /* Vertical beam width divided by 2 */
208   float horz_half_bw;  /* Horizontal beam width divided by 2 */
209
210   int nrays;
211   float (*f)(Range x);       /* Data conversion function. f(x). */
212   Range (*invf)(float x);    /* Data conversion function. invf(x). */
213 } Sweep_header;
214
215 typedef struct {           
216   Sweep_header h;   
217   Ray **ray;               /* ray[0..nrays-1]. */
218 } Sweep;
219
220 typedef struct {
221   char *type_str;  /* One of:'Reflectivity', 'Velocity' or 'Spectrum width' */
222   int nsweeps;
223   float calibr_const;        /* Calibration constant.  HDF specific. */
224   float (*f)(Range x);       /* Data conversion function. f(x). */
225   Range (*invf)(float x);    /* Data conversion function. invf(x). */
226 } Volume_header;
227
228 typedef struct {
229     Volume_header h;           /* Specific info for each elev. */
230                                /* Includes resolution: km/bin. */
231     Sweep **sweep;             /* sweep[0..nsweeps-1]. */
232 } Volume;
233
234
235
236 typedef Range Carpi_value;
237 typedef Range Cappi_value;
238
239 typedef struct {
240   int   month;            /* (1-12). */
241   int   day;              /* (1-31).   */
242   int   year;             /* (eg. 1993). */
243   int   hour;             /* (0-23). */
244   int   minute;           /* (0-59).*/
245   float sec;              /* second + fraction of second. */
246   float dx, dy;           /* Size of cell in km. */
247   int   nx, ny;           /* Number of cells. */
248   int   radar_x, radar_y; /* Location of center of radar. */
249   float height;           /* Height of this Carpi. */
250   float lat, lon;         /* Lat/lon of lower left corner of Carpi. */
251   char  radar_type[50];   /* Radar types. */
252   int   field_type;       /* Same as for Radar. */
253   int   interp_method;    /* ??? string describing interpolation method. */
254   float (*f)(Carpi_value x);    /* Data conversion function. f(x). */
255   Carpi_value (*invf)(float x); /* Data conversion function. invf(x). */
256   Carpi_value **data;     /* data[ny][nx] */
257 } Carpi;
258
259 /** Cappi data structure info **/
260 /*  Paul A. Kucera            **/
261
262 /* Element in location array of Cappi data structure.
263  * Each element is elvation and range to data value.
264  */
265 typedef struct 
266    {
267    float elev;        /* elevation angle */
268    float srange;       /* slant range !!! */
269    }
270 Er_loc;
271
272 /* Cappi data structure.
273  */
274 typedef struct {
275   int    month;       /* Begin time for this Cappi; month (1-12). */
276   int    day;         /* Begin time for this Cappi; day (1-31).   */
277   int    year;        /* Begin time for this Cappi; year (eg. 1993). */
278   int    hour;        /* Begin date for this Cappi; hour (0-23). */
279   int    minute;      /* Begin date for this Cappi; minute (0-59).*/
280   float  sec;         /* Begin date for this Cappi; second + frac. of second.*/
281   float  height;        /* Height for this Cappi in m */
282   float  lat;
283   float  lon;
284   int    field_type;    /* Value of Constant ??_INDEX */
285   char   radar_type[50];   /* Value of Constant radar->h.radar_type */
286   int    interp_method; /* ??? string describing interpolation method. */
287   Er_loc *loc;          /* elevation and range coordinate array */
288   Sweep  *sweep;        /* Pointers to rays of data */
289 } Cappi;
290
291 /* The Cube data type. */
292
293 typedef Range Cube_value;
294 typedef Range Slice_value;
295
296 typedef struct 
297 {
298     float lat, lon;
299     float dx, dy, dz;
300     int nx, ny, nz;
301     char *data_type;
302     Carpi **carpi;         /* Pointers to carpi[0] thru carpi[nz-1] */
303 } Cube;
304
305 typedef struct
306 {
307     float dx, dy;
308     int nx, ny;
309     char *data_type;
310   float (*f)(Slice_value x);    /* Data conversion function. f(x). */
311   Slice_value (*invf)(float x); /* Data conversion function. invf(x). */
312     Slice_value **data;           /* data[ny][nx]. */
313 } Slice;
314
315 typedef struct {
316   int nbins;
317   int low;
318   int hi;
319   int ucount;
320   int ccount;
321   int *data;
322 } Histogram;
323
324 enum scan_mode {PPI, RHI};
325
326 typedef struct {
327   int month, day, year;
328   int hour, minute;
329   float sec; /* Second plus fractional part. */
330   char radar_type[50]; /* Type of radar.  Use for QC-ing the data.
331                         * Supported types are:
332                         * "wsr88d", "lassen", "uf",
333                         * "nsig", "mcgill",
334                         * "kwajalein", "rsl", "toga",
335                         * "rapic", (rapic is Berrimah Austrailia)
336                         * "radtec", (SPANDAR radar at Wallops Is, VA)
337                         * "dorade",
338                         * "south_africa".
339                         * Set by appropriate ingest routine.
340                         */
341   int nvolumes;
342
343   int number;        /* arbitrary number of this radar site */
344   char name[8];      /* Nexrad site name */
345   char radar_name[8]; /* Radar name. */
346   char project[24];   /* Project identifier. */
347   char city[15];     /* nearest city to  radar site */
348   char state[3];     /* state of radar site */
349   char country[15];
350   int latd;   /* degrees of latitude of site */
351   int latm;   /* minutes of latitude of site */
352   int lats;   /* seconds of latitude of site */
353   int lond;   /* degrees of longitude of site */
354   int lonm;   /* minutes of longitude of site */
355   int lons;   /* seconds of longitude of site */
356   int height; /* height of site in meters above sea level*/
357   int spulse; /* length of short pulse (ns)*/
358   int lpulse; /* length of long pulse (ns) */
359   int scan_mode; /* 0 = PPI, 1 = RHI */
360   int vcp;    /* Volume Coverage Pattern (for WSR-88D only) */
361 } Radar_header;
362
363
364 typedef struct {
365   Radar_header h;
366   Volume **v;  /* Array 0..nvolumes-1 of pointers to Volumes.
367                       * 0 = DZ_INDEX = reflectivity.
368                       * 1 = VR_INDEX = velocity.
369                       * 2 = SW_INDEX = spectrum_width.
370                       * 3 = CZ_INDEX = corrected reflectivity.
371                       * 4 = ZT_INDEX = uncorrected reflectivity.
372                       * 5 = DR_INDEX = differential refl.
373                       * 6 = LR_INDEX = another differential refl.
374                       * 7 = ZD_INDEX = another differential refl.
375                       * 8 = DM_INDEX = received power.
376                       * 9 = RH_INDEX = RhoHV: Horz-Vert power corr coeff
377                       *10 = PH_INDEX = PhiDP: Differential phase angle
378                       *11 = XZ_INDEX = X-band reflectivity.
379                       *12 = CD_INDEX = Corrected DR.
380                       *13 = MZ_INDEX = DZ mask for 1C-51 HDF.
381                       *14 = MR_INDEX = DR mask for 1C-51 HDF.
382                       *15 = ZE_INDEX = Edited reflectivity.
383                       *16 = VE_INDEX = Edited velocity.
384                       *17 = KD_INDEX = KDP: Specific differential phase, deg/km.
385                       *18 = TI_INDEX = TIME (unknown)  for MCTEX data.
386                       *19 = DX_INDEX
387                       *20 = CH_INDEX
388                       *21 = AH_INDEX
389                       *22 = CV_INDEX
390                       *23 = AV_INDEX
391                       *24 = SQ_INDEX = Signal Quality Index (Sigmet)
392                       *25 = VS_INDEX = Radial Velocity Combined  (DORADE)
393                       *26 = VL_INDEX = Radial Velocity Combined  (DORADE)
394                       *27 = VG_INDEX = Radial Velocity Combined  (DORADE)
395                       *28 = VT_INDEX = Radial Velocity Combined  (DORADE)
396                       *29 = NP_INDEX = Normalized Coherent Power (DORADE)
397                       *30 = HC_INDEX = HydroClass (Sigmet)
398                       *31 = VC_INDEX = Radial Velocity Corrected (Sigmet)
399                       *32 = V2_INDEX = Radial Velocity for VCP 121 second Doppler cut.
400                       *33 = S2_INDEX = Spectrum Width  for VCP 121 second Doppler cut.
401                       *34 = V3_INDEX = Radial Velocity for VCP 121 third Doppler cut.
402                       *35 = S3_INDEX = Spectrum Width  for VCP 121 third Doppler cut.
403                       *42 = ET_INDEX = Total Power Enhanced (Sigmet)
404                       *43 = EZ_INDEX = Clutter Corr. Reflectivity Enhanced (Sigmet)
405                 */
406
407 } Radar;
408
409 /*
410  * DZ     Reflectivity (dBZ), may contain some     DZ_INDEX
411  *        signal-processor level QC and/or      
412  *        filters. This field would contain 
413  *        Darwin's CZ, or WSR88D's standard 
414  *        reflectivity. In other words, unless
415  *        the field is described otherwise, it
416  *        should always go here. In essence, this
417  *        is the "cleanest" reflectivity field
418  *        for a radar.
419  *
420  * VR     Radial Velocity (m/s)                    VR_INDEX
421  *
422  * SW     Spectral Width (m2/s2)                   SW_INDEX
423  *
424  * CZ     QC Reflectivity (dBZ), contains
425  *        post-processed QC'd data                 CZ_INDEX
426  *
427  * ZT     Total Reflectivity (dBZ)                 ZT_INDEX
428  *        Reflectivity unfiltered for clutter...
429  *        This is UZ in UF files.
430  *
431  * DR     Differential reflectivity                DR_INDEX
432  *        DR and LR are for dual-polarization
433  *        radars only. Unitless or in dB.
434  *
435  * LR     Another form of differential ref         LR_INDEX
436  *        called LDR, not sure of units
437  *
438  * ZD     ZDR: Reflectivity Depolarization Ratio   ZD_INDEX
439  *        ZDR = 10log(ZH/ZV)  (dB)
440  *
441  * DM     Received power measured by the radar.    DM_INDEX
442  *        Units are dBm.
443  *
444  * RH     RhoHV: Horz-Vert power correlation       RH_INDEX
445  *        coefficient. (0 to 1) See volume.c
446  *
447  * PH     PhiDP: Differential phase angle.         PH_INDEX
448  *        (0 to 180 deg in steps of 0.71)
449  *        See volume.c
450  *
451  * XZ     X-band reflectivity                      XZ_INDEX
452  *
453  * CD     Corrected ZD reflectivity (differential) CD_INDEX
454  *        contains QC'ed data
455  *
456  * MZ     DZ mask volume for HDF 1C-51 product.    MZ_INDEX
457  *
458  * MD     ZD mask volume for HDF 1C-51 product.    MD_INDEX
459  *
460  * ZE     Edited Reflectivity.                     ZE_INDEX
461  *
462  * VE     Edited Velocity.                         VE_INDEX
463  *
464  * KD     KDP (deg/km) Differencial Phase          KD_INDEX
465  *            (Sigmet, Lassen)
466  *
467  * TI     TIME (unknown)  for MCTEX data.          TI_INDEX
468  *
469  * SQ     SQI: Signal Quality Index. (Sigmet)      SQ_INDEX
470  *        Decimal fraction from 0 to 1, where 0
471  *        is noise, 1 is noiseless.
472  *
473  * VS     Radial Velocity, Short PRT (m/s) (DORADE)   VS_INDEX
474  *
475  * VL     Radial Velocity, Long PRT (m/s)  (DORADE)   VL_INDEX
476  *
477  * VG     Radial Velocity, combined (m/s)  (DORADE)   VG_INDEX
478  *
479  * VT     Radial Velocity, combined (m/s)  (DORADE)   VT_INDEX
480  *
481  * NP     Normalized Coherent Power.       (DORADE)   NP_INDEX
482  *
483  * HC     HydroClass: enumerated class.    (Sigmet)   HC_INDEX
484  *
485  * VC     Radial Velocity corrected for    (Sigmet)   VC_INDEX
486  *        Nyquist unfolding. 
487  */
488
489 /*
490  * The number of *_INDEX must never exceed MAX_RADAR_VOLUMES.
491  * Increase MAX_RADAR_VOLUMES appropriately, for new ingest formats.
492  *
493  * Also, when adding new *_INDEXes, you must update the following three arrays
494  * located near the end of this file: RSL_ftype, RSL_f_list, and  RSL_invf_list.
495  * You also need to modify volume.c, updating the initialization of array
496  * rsl_qfield by adding a '1' for each new volume index.
497  */
498
499 #define MAX_RADAR_VOLUMES 44
500
501 #define DZ_INDEX 0
502 #define VR_INDEX 1
503 #define SW_INDEX 2
504 #define CZ_INDEX 3
505 #define ZT_INDEX 4
506 #define DR_INDEX 5
507 #define LR_INDEX 6
508 #define ZD_INDEX 7
509 #define DM_INDEX 8
510 #define RH_INDEX 9
511 #define PH_INDEX 10
512 #define XZ_INDEX 11
513 #define CD_INDEX 12
514 #define MZ_INDEX 13
515 #define MD_INDEX 14
516 #define ZE_INDEX 15
517 #define VE_INDEX 16
518 #define KD_INDEX 17
519 #define TI_INDEX 18
520 #define DX_INDEX 19
521 #define CH_INDEX 20
522 #define AH_INDEX 21
523 #define CV_INDEX 22
524 #define AV_INDEX 23
525 #define SQ_INDEX 24
526 #define VS_INDEX 25
527 #define VL_INDEX 26
528 #define VG_INDEX 27
529 #define VT_INDEX 28
530 #define NP_INDEX 29
531 #define HC_INDEX 30
532 #define VC_INDEX 31
533 #define V2_INDEX 32
534 #define S2_INDEX 33
535 #define V3_INDEX 34
536 #define S3_INDEX 35
537 #define CR_INDEX 36
538 #define CC_INDEX 37
539 #define PR_INDEX 38
540 #define SD_INDEX 39
541 #define ZZ_INDEX 40
542 #define RD_INDEX 41
543 #define ET_INDEX 42
544 #define EZ_INDEX 43
545
546
547 /* Prototypes for functions. */
548 /* Alphabetical and grouped by object returned. */
549
550
551 Radar *RSL_africa_to_radar(char *infile);
552 Radar *RSL_anyformat_to_radar(char *infile, ...);
553 Radar *RSL_dorade_to_radar(char *infile);
554 Radar *RSL_fix_radar_header(Radar *radar);
555 Radar *RSL_get_window_from_radar(Radar *r, float min_range, float max_range,float low_azim, float hi_azim);
556 Radar *RSL_hdf_to_radar(char *infile);
557 Radar *RSL_hdf_to_radar_unQC(char *infile);
558 Radar *RSL_kwaj_to_radar(char *infile);
559 Radar *RSL_lassen_to_radar(char *infile);
560 Radar *RSL_mcgill_to_radar(char *infile);
561 Radar *RSL_new_radar(int nvolumes);
562 Radar *RSL_nsig_to_radar(char *infile);
563 Radar *RSL_nsig2_to_radar(char *infile);
564 Radar *RSL_prune_radar(Radar *radar);
565 Radar *RSL_radtec_to_radar(char *infile);
566 Radar *RSL_rainbow_to_radar(char *infile);
567 Radar *RSL_rapic_to_radar(char *infile);
568 Radar *RSL_read_radar(char *infile);
569 Radar *RSL_sort_radar(Radar *r);
570 Radar *RSL_toga_to_radar(char *infile);
571 Radar *RSL_uf_to_radar(char *infile);
572 Radar *RSL_uf_to_radar_fp(FILE *fp);
573 Radar *RSL_wsr88d_to_radar(char *infile, char *call_or_first_tape_file);
574
575 Volume *RSL_clear_volume(Volume *v);
576 Volume *RSL_copy_volume(Volume *v);
577 Volume *RSL_fix_volume_header(Volume *v);
578 Volume *RSL_get_volume(Radar *r, int type_wanted);
579 Volume *RSL_get_window_from_volume(Volume *v, float min_range, float max_range, float low_azim, float hi_azim);
580 Volume *RSL_new_volume(int max_sweeps);
581 Volume *RSL_prune_volume(Volume *v);
582 Volume *RSL_read_volume(FILE *fp);
583 Volume *RSL_reverse_sweep_order(Volume *v);
584 Volume *RSL_sort_rays_in_volume(Volume *v);
585 Volume *RSL_sort_sweeps_in_volume(Volume *v);
586 Volume *RSL_sort_volume(Volume *v);
587 Volume *RSL_volume_z_to_r(Volume *z_volume, float k, float a);
588
589 Sweep *RSL_clear_sweep(Sweep *s);
590 Sweep *RSL_copy_sweep(Sweep *s);
591 Sweep *RSL_fix_sweep_header(Sweep *sweep);
592 Sweep *RSL_get_closest_sweep(Volume *v,float sweep_angle,float limit);
593 Sweep *RSL_get_eth_sweep(Volume *v,float et_point,float max_range);
594 Sweep *RSL_get_first_sweep_of_volume(Volume *v);
595 Sweep *RSL_get_sweep(Volume *v, float elev);
596 Sweep *RSL_get_window_from_sweep(Sweep *s, float min_range, float max_range, float low_azim, float hi_azim);
597
598 Sweep *RSL_new_sweep(int max_rays);
599 Sweep *RSL_prune_sweep(Sweep *s);
600 Sweep *RSL_read_sweep (FILE *fp);
601 Sweep *RSL_sort_rays_in_sweep(Sweep *s);
602 Sweep *RSL_sort_rays_by_time(Sweep *s);
603 Sweep *RSL_sweep_z_to_r(Sweep *z_sweep, float k, float a);
604
605 Ray *RSL_clear_ray(Ray *r);
606 Ray *RSL_copy_ray(Ray *r);
607 Ray *RSL_get_closest_ray_from_sweep(Sweep *s,float ray_angle,float limit);
608 Ray *RSL_get_first_ray_of_sweep(Sweep *s);
609 Ray *RSL_get_first_ray_of_volume(Volume *v);
610 Ray *RSL_get_closest_ray_from_sweep(Sweep *s,float ray_angle,float limit);
611 Ray *RSL_get_next_ccwise_ray(Sweep *s, Ray *ray);
612 Ray *RSL_get_next_cwise_ray(Sweep *s, Ray *ray);
613 Ray *RSL_get_ray(Volume *v, float elev, float azimuth);
614 Ray *RSL_get_ray_above(Volume *v, Ray *current_ray);
615 Ray *RSL_get_ray_below(Volume *v, Ray *current_ray);
616 Ray *RSL_get_ray_from_sweep(Sweep *s, float azim);
617 Ray *RSL_get_window_from_ray(Ray *r, float min_range, float max_range, float low_azim, float hi_azim);
618 Ray *RSL_new_ray(int max_bins);
619 Ray *RSL_prune_ray(Ray *ray);
620 Ray *RSL_ray_z_to_r(Ray *z_ray, float k, float a);
621 Ray *RSL_read_ray   (FILE *fp);
622
623
624 float RSL_area_of_ray(Ray *r, float lo, float hi, float min_range, float max_range);
625 float RSL_fraction_of_ray(Ray *r, float lo, float hi, float range);
626 float RSL_fraction_of_sweep(Sweep *s, float lo, float hi, float range);
627 float RSL_fraction_of_volume(Volume *v, float lo, float hi, float range);
628 float RSL_fractional_area_of_sweep(Sweep *s, float lo, float hi, float min_rng, float max_rng);
629 float RSL_get_echo_top_height(Volume *v,float azim,float grange, float et_point);
630 float RSL_get_linear_value(Volume *v,float srange,float azim,float elev,float limit);
631 float RSL_get_nyquist_from_radar(Radar *radar);
632 float RSL_get_range_of_range_index(Ray *ray, int index);
633 float RSL_get_value(Volume *v, float elev, float azimuth, float range);
634 float RSL_get_value_at_h(Volume *v, float azim, float grnd_r, float h);
635 float RSL_get_value_from_cappi(Cappi *cappi, float rng, float azm);
636 float RSL_get_value_from_ray(Ray *ray, float r);
637 float RSL_get_value_from_sweep(Sweep *s, float azim, float r);
638 float RSL_z_to_r(float z, float k, float a);
639
640 int RSL_fill_cappi(Volume *v, Cappi *cap, int method);
641 int RSL_get_ray_index_from_sweep(Sweep *s, float azim,int *next_closest);
642 int RSL_get_sweep_index_from_volume(Volume *v, float elev,int *next_closest);
643 int RSL_radar_to_hdf(Radar *radar, char *outfile);
644 int RSL_write_histogram(Histogram *histogram, char *outfile);
645 int RSL_write_ray(Ray *r, FILE *fp);
646 int RSL_write_sweep(Sweep *s, FILE *fp);
647 int RSL_write_radar(Radar *radar, char *outfile);
648 int RSL_write_radar_gzip(Radar *radar, char *outfile);
649 int RSL_write_volume(Volume *v, FILE *fp);
650
651 unsigned char *RSL_rhi_sweep_to_cart(Sweep *s, int xdim, int ydim, float range, 
652                                      int vert_scale);
653 unsigned char *RSL_sweep_to_cart(Sweep *s, int xdim, int ydim, float range);
654
655 void RSL_add_dbz_offset_to_ray(Ray *r, float dbz_offset);
656 void RSL_add_dbz_offset_to_sweep(Sweep *s, float dbz_offset);
657 void RSL_add_dbz_offset_to_volume(Volume *v, float dbz_offset);
658 void RSL_bscan_ray(Ray *r, FILE *fp);
659 void RSL_bscan_sweep(Sweep *s, char *outfile);
660 void RSL_bscan_volume(Volume *v, char *basename);
661 void RSL_find_rng_azm(float *r, float *ang, float x, float y);
662 void RSL_fix_time (Ray *ray);
663 void RSL_float_to_char(float *x, Range *c, int n);
664
665 void RSL_free_cappi(Cappi *c);
666 void RSL_free_carpi(Carpi *carpi);
667 void RSL_free_cube(Cube *cube);
668 void RSL_free_histogram(Histogram *histogram);
669 void RSL_free_ray(Ray *r);
670 void RSL_free_slice(Slice *slice);
671 void RSL_free_sweep(Sweep *s);
672 void RSL_free_radar(Radar *r);
673 void RSL_free_volume(Volume *v);
674 void RSL_get_color_table(int icolor, char buffer[256], int *ncolors);
675 void RSL_get_groundr_and_h(float slant_r, float elev, float *gr, float *h);
676 void RSL_get_slantr_and_elev(float gr, float h, float *slant_r, float *elev);
677 void RSL_get_slantr_and_h(float gr, float elev, float *slant_r, float *h);
678 void RSL_load_color_table(char *infile, char buffer[256], int *ncolors);
679 void RSL_load_height_color_table();
680 void RSL_load_rainfall_color_table();
681 void RSL_load_refl_color_table();
682 void RSL_load_vel_color_table();
683 void RSL_load_sw_color_table();
684 void RSL_load_zdr_color_table();
685 void RSL_load_red_table(char *infile);
686 void RSL_load_green_table(char *infile);
687 void RSL_load_blue_table(char *infile);
688 void RSL_print_histogram(Histogram *histogram, int min_range, int max_range,
689                          char *filename);
690 void RSL_print_version();
691 void RSL_radar_to_uf(Radar *r, char *outfile);
692 void RSL_radar_to_uf_gzip(Radar *r, char *outfile);
693 void RSL_radar_verbose_off(void);
694 void RSL_radar_verbose_on(void);
695 void RSL_read_these_sweeps(char *csweep, ...);
696 void RSL_rebin_velocity_ray(Ray *r);
697 void RSL_rebin_velocity_sweep(Sweep *s);
698 void RSL_rebin_velocity_volume(Volume *v);
699 void RSL_rebin_zdr_ray(Ray *r);
700 void RSL_rebin_zdr_sweep(Sweep *s);
701 void RSL_rebin_zdr_volume(Volume *v);
702 void RSL_rhi_sweep_to_gif(Sweep *s, char *outfile, int xdim, int ydim, float range, 
703                           int vert_scale);
704 void RSL_select_fields(char *field_type, ...);
705 void RSL_set_color_table(int icolor, char buffer[256], int ncolors);
706 void RSL_sweep_to_gif(Sweep *s, char *outfile, int xdim, int ydim, float range);
707 void RSL_sweep_to_pgm(Sweep *s, char *outfile, int xdim, int ydim, float range);
708 void RSL_sweep_to_pict(Sweep *s, char *outfile, int xdim, int ydim, float range);
709 void RSL_sweep_to_ppm(Sweep *s, char *outfile, int xdim, int ydim, float range);
710 void RSL_volume_to_gif(Volume *v, char *basename, int xdim, int ydim, float range);
711 void RSL_volume_to_pgm(Volume *v, char *basename, int xdim, int ydim, float range);
712 void RSL_volume_to_pict(Volume *v, char *basename, int xdim, int ydim, float range);
713 void RSL_volume_to_ppm(Volume *v, char *basename, int xdim, int ydim, float range);
714 void RSL_write_gif(char *outfile, unsigned char *image,
715                    int xdim, int ydim, char c_table[256][3]);
716 void RSL_write_pgm(char *outfile, unsigned char *image,
717                    int xdim, int ydim);
718 void RSL_write_pict(char *outfile, unsigned char *image,
719                     int xdim, int ydim, char c_table[256][3]);
720 void RSL_write_ppm(char *outfile, unsigned char *image,
721                    int xdim, int ydim, char c_table[256][3]);
722
723 Cappi *RSL_new_cappi(Sweep *sweep, float height);
724 Cappi *RSL_cappi_at_h(Volume  *v, float height, float max_range);
725
726 Carpi *RSL_cappi_to_carpi(Cappi *cappi, float dx, float dy,
727                           float lat, float lon,
728                           int nx, int ny, int radar_x, int radar_y);
729 Carpi *RSL_new_carpi(int nrows, int ncols);
730 Carpi *RSL_volume_to_carpi(Volume *v, float h, float grnd_r,
731                            float dx, float dy, int nx, int ny,
732                            int radar_x, int radar_y, float lat, float lon);
733
734 Cube *RSL_new_cube(int ncarpi);
735 Cube *RSL_volume_to_cube(Volume *v, float dx, float dy, float dz,
736                          int nx, int ny, int nz, float grnd_r,
737                          int radar_x, int radar_y, int radar_z);
738
739 Slice *RSL_new_slice(int nrows, int ncols);
740 Slice *RSL_get_slice_from_cube(Cube *cube, int x, int y, int z);
741
742
743 Histogram *RSL_allocate_histogram(int low, int hi);
744 Histogram *RSL_get_histogram_from_ray(Ray *ray, Histogram *histogram,
745                                       int low, int hi, int min_range,
746                                       int max_range);
747 Histogram *RSL_get_histogram_from_sweep(Sweep *sweep, Histogram *histogram, 
748                                         int low, int hi, int min_range,
749                                         int max_range);
750 Histogram *RSL_get_histogram_from_volume(Volume *volume, Histogram *histogram,
751                                          int low, int hi, int min_range,
752                                          int max_range);
753 Histogram *RSL_read_histogram(char *infile);
754
755 int no_command (char *cmd);
756 FILE *uncompress_pipe (FILE *fp);
757 FILE *compress_pipe (FILE *fp);
758 int rsl_pclose(FILE *fp);
759
760 /* Carpi image generation functions. These are modified clones of the
761      corresponding sweep image generation functions.
762 */
763 unsigned char *RSL_carpi_to_cart(Carpi *carpi, int xdim, int ydim,
764                                                                  float range);
765 void RSL_carpi_to_gif(Carpi *carpi, char *outfile, int xdim, int ydim,
766                                             float range);
767 void RSL_carpi_to_pict(Carpi *carpi, char *outfile, int xdim, int ydim,
768                                              float range);
769 void RSL_carpi_to_ppm(Carpi *carpi, char *outfile, int xdim, int ydim,
770                                             float range);
771 void RSL_carpi_to_pgm(Carpi *carpi, char *outfile, int xdim, int ydim,
772                                             float range);
773
774 /* Internal storage conversion functions. These may be any conversion and
775  * may be dynamically defined; based on the input data conversion.
776  */
777 float DZ_F(Range x);
778 float VR_F(Range x);
779 float SW_F(Range x);
780 float CZ_F(Range x);
781 float ZT_F(Range x);
782 float DR_F(Range x);
783 float LR_F(Range x);
784 float ZD_F(Range x);
785 float DM_F(Range x);
786 float RH_F(Range x);
787 float PH_F(Range x);
788 float XZ_F(Range x);
789 float CD_F(Range x);
790 float MZ_F(Range x);
791 float MD_F(Range x);
792 float ZE_F(Range x);
793 float VE_F(Range x);
794 float KD_F(Range x);
795 float TI_F(Range x);
796 float DX_F(Range x);
797 float CH_F(Range x);
798 float AH_F(Range x);
799 float CV_F(Range x);
800 float AV_F(Range x);
801 float SQ_F(Range x);
802 float VS_F(Range x);
803 float VL_F(Range x);
804 float VG_F(Range x);
805 float VT_F(Range x);
806 float NP_F(Range x);
807 float HC_F(Range x);
808 float VC_F(Range x);
809 float SD_F(Range x);
810
811 Range DZ_INVF(float x);
812 Range VR_INVF(float x);
813 Range SW_INVF(float x);
814 Range CZ_INVF(float x);
815 Range ZT_INVF(float x);
816 Range DR_INVF(float x);
817 Range LR_INVF(float x);
818 Range ZD_INVF(float x);
819 Range DM_INVF(float x);
820 Range RH_INVF(float x);
821 Range PH_INVF(float x);
822 Range XZ_INVF(float x);
823 Range CD_INVF(float x);
824 Range MZ_INVF(float x);
825 Range MD_INVF(float x);
826 Range ZE_INVF(float x);
827 Range VE_INVF(float x);
828 Range KD_INVF(float x);
829 Range TI_INVF(float x);
830 Range DX_INVF(float x);
831 Range CH_INVF(float x);
832 Range AH_INVF(float x);
833 Range CV_INVF(float x);
834 Range AV_INVF(float x);
835 Range SQ_INVF(float x);
836 Range VS_INVF(float x);
837 Range VL_INVF(float x);
838 Range VG_INVF(float x);
839 Range VT_INVF(float x);
840 Range NP_INVF(float x);
841 Range HC_INVF(float x);
842 Range VC_INVF(float x);
843 Range SD_INVF(float x);
844
845 /* Type identifiers and function tables */
846 extern char *RSL_ftype[];
847 extern float (*RSL_f_list[])(Range x);
848 extern Range (*RSL_invf_list[])(float x);
849
850 /* Secret routines that are quite useful and useful to developers. */
851 void radar_load_date_time(Radar *radar);
852 int big_endian(void);
853 int little_endian(void);
854 void swap_4_bytes(void *word);
855 void swap_2_bytes(void *word);
856 Hash_table *hash_table_for_sweep(Sweep *s);
857 int hash_bin(Hash_table *table,float angle);
858 Azimuth_hash *the_closest_hash(Azimuth_hash *hash, float ray_angle);
859 Hash_table *construct_sweep_hash_table(Sweep *s);
860 double       angle_diff(float x, float y);
861 int rsl_query_field(char *c_field);
862
863 /* Functions for controlling handling of WSR-88D split cuts. */
864 void RSL_wsr88d_merge_split_cuts_on();
865 void RSL_wsr88d_merge_split_cuts_off();
866 void RSL_wsr88d_keep_short_refl();
867 int wsr88d_merge_split_cuts_is_set();
868
869 Radar *wsr88d_merge_split_cuts(Radar *radar);
870
871 /* Debugging prototypes. */
872 void poke_around_volume(Volume *v);
873
874 /* SYSTEM: left out prototypes? */
875 extern int pclose (FILE *f); /* From stdio.h */
876
877 #endif