]> Pileus Git - ~andy/rsl/blob - CHANGES
9266df354aafd2a3561d179279cb74b579e4afe7
[~andy/rsl] / CHANGES
1 /* Changes for RSL
2  *
3  *---------------------------------------------------------------------
4  * v1.41 In progress
5  *
6  * 1. wsr88d_m31.c: Simplified the WSR-88D ray structure and supporting code.
7  *    Removed function read_data_moment.
8  *    Added function get_wsr88d_unamb_and_nyq_vel.
9  * 2. Added support for Sigmet 2-byte data types, as well as HydroClass 1 and 2 byte
10  *    types.
11  *    Files involved: nsig_to_radar.c, nsig.c, nsig.h, volume.c.
12  *    [TODO: dual PRF mods]
13  * 3. Completed DORADE ingest.  Files involved: dorade_to_radar.c, dorade.c, volume.c.
14  * 4. prune.c: Added global variable prune_radar and two functions to set or unset:
15  *      RSL_prune_radar_on()
16  *      RSL_prune_radar_off()
17  *---------------------------------------------------------------------
18  * v1.40 Released 10/10/2008
19  *
20  * 1. wsr88d_m31.c (load_wsr88d_m31_into_radar): Corrected a potential problem
21  *    in which the end of sweep or volume might occur at a point in the program
22  *    that was isolated from the code that handles that condition.
23  *    Store vcp in radar header.
24  * 2. rsl.h: Added vcp to radar header structure for WSR-88D.
25  * 3. nsig_to_radar.c: Corrected a problem involving Extended Header, which
26  *    when present, caused elevation in ray header to be set to 0.
27  * 4. wsr88d_m31.c (wsr88d_load_ray_into_radar): Changed the way we determine
28  *    whether or not to keep the reflectivity field (we don't want it from
29  *    Doppler split cuts).  The previous method was inadequate for VCP 121.
30  * 5. read_write.c (RSL_write_radar_fp, RSL_write_volume, RSL_write_sweep)
31  *    (RSL_write_ray): Initialize header_buf to zero to avoid junk in output
32  *    files.  This provides clean outputs for comparing in test situations.
33  *---------------------------------------------------------------------
34  * v1.39 Released 07/24/2008
35  *
36  * 1. Added wsr88d_m31.c.  It contains routines to handle new Message Type 31
37  *    in WSR-88D Level II Build 10.
38  * 2. wsr88d_to_radar.c: Modified to call message 31 routine.
39  * 3. wsr88d.c: Added code for VCPs 211, 212, 213.
40  * 4. lassen_to_radar.c: Added a fix for PhiDP provided by Scott Collis of BMRC.
41  *
42  *---------------------------------------------------------------------
43  * v1.38 Released 11/29/2007
44  *
45  * 1. wsr88d.c (wsr88d_read_sweep): Modified to handle unusual message packets
46  *    at start of WSR-88D files from some future GPM sites.
47  *
48  *---------------------------------------------------------------------
49  * v1.37 Released 06/19/2007 (Severity: low)
50  *
51  * 1. radar_to_uf.c, uf_to_radar.c: Modified to use Local Use Header to store
52  *    and retrieve WSR-88D VR azimuth.  This is necessary because WSR-88D runs
53  *    separate scans for DZ and VR at lower elevations, which means that they
54  *    have different azimuths for a given ray.  Thanks go to Pat Kennedy of CSU
55  *    for discovering this problem and for bringing it to our attention.
56  * 2. lassen_load_sweep in lassen_to_radar.c: Removed 1.4 dB correction for
57  *    reflectivity--BMRC version no longer uses it.
58  *
59  *---------------------------------------------------------------------
60  * v1.36 Released 08/29/2006 (Severity: low)
61  *
62  * 1. Forgot to put the modified wsr88d_locations.dat file into previous
63  *    release.
64  *
65  *---------------------------------------------------------------------
66  * v1.35 Released 08/28/2006 (Severity: low)
67  *
68  * 1. lassen_to_radar.c: fixed a bug in lassen_load_sweep where sweep index
69  *    was being used for sweep number in headers.
70  * 2. radar.c: Modified RSL_get_volume to return volume for any field type.
71  *    It had been limited to velocity, spectrum width and reflectivity types.
72  * 3. Added SQ_INDEX for Signal Quality Index field.  Files modified: rsl.h,
73  *    volume.c, nsig_to_radar.c, nsig.h, uf_to_radar.c, radar_to_uf.c.
74  * 4. wsr88d_locations.dat modified to change height units from feet to meters.
75  *    Thanks go to Dave Makofski for finding and fixing that one.
76  *
77  *---------------------------------------------------------------------
78  * v1.34 Released 02/15/2006 (Severity: low)
79  *
80  * 1. wsr88d.c: Fixed a bug in checking msg_type.  The problem occurred while
81  *    processing data from Houston, which recently switched over to the new
82  *    Open RDA (ORDA) being implemented by NEXRAD.  Msg_type is in the
83  *    righthand byte of a two-byte word, the left containing Channel ID,
84  *    but the full two-byte value was being used to check msg_type.  This
85  *    became a problem when ORDA used a non-zero value for Channel ID.
86  * 2. wsr88d.c and wsr88d_to_radar.c: Added information for new VCPs 12 and
87  *    121.
88  * 3. Added Huntsville site to wsr88d_locations.dat.
89  *
90  *---------------------------------------------------------------------
91  * v1.33 Began 02/25/2004.  Released 08/27/2004 (Severity: low)
92  *
93  * 1. Modified wsr88d_to_radar.c and anyformat_to_radar.c to handle change in
94  *    WSR-88D header record for Level II Build 5 data format.
95  * 2. Fixed a bug in wsr88d.c, wsr88d_read_sweep, which caused the last ray
96  *    of sweep to be deleted along with empty rays in second tilt and above.
97  *
98  *---------------------------------------------------------------------
99  * v1.32 Began 11/05/2003.  Released 02/13/2004 (Severity: low)
100  *
101  * 1. Changed computation of sweep seconds in nsig_to_radar.c to eliminate
102  *    rounding error.
103  * 2. wsr88d_to_radar.c: removed call to wsr88d_get_wavelength, which computed
104  *    the WSR-88D wavelength when parameters were available, or returned a
105  *    constant otherwise.  Replaced with constant wavelength of 10 cm. Thanks to
106  *    Joe Holmes of SIGMET for noticing differing wavelengths between fields.
107  * 3. Added ingest for Rainbow format.  Only handles DZ.
108  *
109  *---------------------------------------------------------------------
110  * v1.31 Began 04/30/2003.  Released 09/03/2003 (Severity: low)
111  *
112  * 1. nsig_to_radar.c: removed unused #define, made some cosmetic changes in
113  *    code and comment alignment.
114  * 2. Makefile.am: Added line to install include-directory under target
115  *    install-exec-hook.
116  * 3. Added code to configure.in to fix yywrap unresolved reference that
117  *    occurred when installing rsl when the TSDIS toolkit was not installed.
118  *
119  *---------------------------------------------------------------------
120  * v1.30 Began 07/30/2001.  Released 03/13/2003 (Severity: low)
121  *
122  * 1. Increased the size of parameter arrays in nsig.c as recommended by
123  *    Paul Kucera, to accommodate NPOL polarimetric parameters.
124  * 2. Fixed a bug in nsig_endianess in nsig.c. 
125  * 3. Modified uf_to_radar to compute unambiguous range using PRF.  Reduced
126  *    UF record length by removing extra byte at end of record.  Made to handle
127  *    4-digit years (previously assumed 2-digit, as declared in UF documention).
128  * 4. Modified hdf_to_radar to use more accurate value for sweep.h.nrays.
129  * 5. Corrected computation in function wsr88d_get_azimuth_rate in wsr88d.c.
130  * 6. Fixed bug in sweep rate computation in wsr88d.c
131  * 7. Changed wsr88d_ray_to_float in wsr88d.c to use field data pointers
132  *    provided in the data, instead of computing offsets.  The latter method is
133  *    incorrect according to NOAA Radar Operations Center.
134  * 8. Modified radar_to_uf to get fixed angle for mandatory header from value
135  *    stored in ray.  Previously used average elevation of sweep.
136  * 9. Added examples/adjust_gate_size.c, and added enhanced version of qlook.c
137  *    which uses it.
138  *10. Fixed problem in which rsl libraries could not be built if a library
139  *    didn't already exist in the target directory.  Brought configure.in up to
140  *    date with autoconf version 2.53 standards.  Removed acconfig.h.
141  *11. Removed outdated email addresses found in comments.
142  *
143  *---------------------------------------------------------------------
144  * v1.29 Began 09/19/2000.  Released 4/3/2001 (Severity: low)
145  *
146  * 1. Modified radar_to_hdf_1.c maskBuild() to build MZ mask differently:
147  *    maskBuild was checking where CZ and DZ volumes were equal 
148  *    to build MZ volume (mask).  Now, maskBuild just checks where 
149  *    CZ volume == BADVAL, for runtime speed, and because the comparison between
150  *    CZ and DZ volumes was corrupted by the addition of qcParm[ZCAL] to
151  *    each CZ range bin in level_1_qc.c qualityControl().  This change is
152  *    compatible with Danny Rosenfeld's algorithm by which CZ range bins
153  *    are set to BADVAL.
154  * 2. Included Stacy Brodzik's modifications for storing calibration constants 
155  *    in UF (radar_to_uf.c, uf_to_radar.c).
156  * 3. Corrected version string and units for sweep rate written to UF mandatory
157  *    header in radar_to_uf.c, thanks to Joseph Holmes of Sigmet for catching
158  *    the inaccuracies.  Corrected rounding error in latitude/longitude for UF
159  *    mandatory header in same program.  Modified assignments of sweep rate
160  *    and/or azimuth rate in uf_to_radar.c and hdf_to_radar.c
161  *
162  *---------------------------------------------------------------------
163  * v1.28 Began 03/23/2000. Released: 7/24/2000 (Severity: low)
164  *
165  * 1. Added 3 functions to volume.c :
166  *    RSL_add_dbz_offset_to_volume() , RSL_add_dbz_offset_to_sweep(),
167  *    RSL_add_dbz_offset_to_ray()
168  * 2. Modified nsig.h , nsig_to_radar.c , volume.c to handle sigmet's
169  *    RhoHV and PhiDP fields.
170  * 3. Modified volume.c to fix problem with subsequent calls to
171  *    read_these_sweeps()
172  * 4. Modified uf_to_radar.c to compute unambiguous range for
173  *    Radar structure.
174  *
175  *---------------------------------------------------------------------
176  *
177  * v1.27 Began 01/11/2000.  Released: 2/17/2000 (Severity: low)
178  *
179  * 1. Modified files radar_to_hdf_1.c and radar_to_hdf_2.c
180  *    to accomodate random ray lengths, eg, Berrimah data.
181  *
182  *----------------------------------------------------------------------
183  * v1.26 Began 12/11/1999.  Released: 12/21/1999 (Severity: low)
184  *
185  * 1. Configuration change for rapic.l and rapic.y.
186  * 2. Changed dependency for rsl.h and wsr88d.h
187  *
188  *----------------------------------------------------------------------
189  * v1.25 Began 11/30/1999.  Released: 12/10/1999 (Severity: medium)
190  *
191  * 1. Merged branch v1.24.1.
192  * 2. Added configure/configure.in/Makefile.in.
193  * 3. Added Makefile.am (automake) and other related files.
194  * 4. Configuration is a snap:
195  *
196  *       configure --prefix=/some/dir/to/install
197  *       make install
198  *
199  *----------------------------------------------------------------------
200  * v1.24.1 Began 8/1/1999.  Released: 11/30/1999 (Severity: new features)
201  *
202  * 1. Introduced radar->h.project[24] -- project name.
203  * 2. Added dorade ingest -- RSL_dorade_to_radar.
204  * 3. Added examples/kwaj_subtract_one_day.c  -- fix KWAJEX dates.
205  * 4. Removed rsl_popen/pclose routines from gzip.c.  I found
206  *    a way to eliminate the 'Broken pipe' message, the message
207  *    reappeared in linux 2.2.* series, by flushing the
208  *    stream when looking at the magic numbers in anyformat_to_radar.c.
209  * 5. HDF ROUTINES ARE REMOVED.  I have moved them to gvs for level_1.
210  *    See gvs/src/gvslib/.  That's where they live now.  The interface
211  *    RSL_hdf_to_radar and RSL_radar_to_hdf remain as hooks.  If
212  *    you have libgvs, then you can specify -DHAVE_TSDIS_TOOLKIT in 
213  *    the Makefile.
214  *
215  *----------------------------------------------------------------------
216  * v1.24 Began 6/25/1999.  Released: 6/28/1999 (Severity: bug fix)
217  *
218  * 1. UF ingest improperly set the Fixed angle.
219  * 2. Removed max_reasonable_dbz (60) from gts.c.  The app must decide
220  *    what a max allowable dbz is.
221  *
222  *----------------------------------------------------------------------
223  * v1.23 Began 3/31/1999.  Released: 4/2/1999 (Severity: upgrade)
224  *
225  * 1. Added EDGE format ingest.  This requires the library ETOR
226  *    which is obtained from Enterprise Electronics.
227  *    To build this component, set -DHAVE_EDGE in Makefile.
228  *
229  *----------------------------------------------------------------------
230  * v1.22 Began 3/4/1999.  Released: 3/4/1999 (Severity: bux fix)
231  *
232  * 1. Forgot to set the global 'rsl_kdp_wavelen' in nsig_to_radar.c.
233  *
234  *----------------------------------------------------------------------
235  * v1.21 Began 02/16/1999.  Released: 3/4/1999 (Severity: minor bux fix)
236  *
237  * 1. UF code didn't recognize VE, now it does.
238  * 2. RSL_SPEED_OF_LIGHT unifies c throughout the library.
239  * 3. Modification to KDP processing for Sigmet.  New
240  *    F and INVF functions.
241  *
242  *----------------------------------------------------------------------
243  * v1.20 Began 11/12/98.  Released: 01/25/1999 (Severity: bug fix/upgrade)
244  *
245  * 1. Fixed RADTEC ingest. Does RHI too, but,
246  *    RSL doesn't have any good RHI image routines.
247  *
248  * 2. Added: RSL_set_color_table
249  *           RSL_get_color_table
250  *
251  * 3. Added: '-b x' option to any_to_gif.  This makes images black below
252  *    x dbz.  This is a simple noise filter.
253  *----------------------------------------------------------------------
254  * v1.19 Began 9/15/98.  Released: 9/23/98 (Severity: bug fix)
255  *
256  * 1. Modified file volume.c . New INV_F, _F routines for diff refl.
257  *
258  * 2. Created examples/images to hold a base-line set of images
259  *    to compare when running 'run_tests'.  Modified run_tests
260  *    to compare images.
261  *
262  *----------------------------------------------------------------------
263  * v1.18 Began 4/28/98.  Released: 8/13/98 (Severity: upgrade)
264  *
265  * 1. Added routines: 
266  *      RSL_radtec_to_radar   -- in radtec_to_radar.c
267  *      RSL_fix_time          -- in volume.c
268  *
269  * 2. Added files:
270  *      radtec.c
271  *      radtec.h
272  *      radtec_to_radar.c
273  *
274  * 3. Modified image generation.  Images are produced out to 'range'
275  *    specified.  Each image pixels is no longer 1km, but radius/range.
276  *
277  * 4. any_to_gif can now accept range and image size arguments.
278  *
279  * 5. RADTEC requires PKWARE routines explode and crc32.
280  *    RADTEC is built into RSL, if you specify -DHAVE_PKWARE in 
281  *    the Makefile.  When using RADTEC, you must link your application
282  *    staticly; with -static.
283  *
284  *    Contact PKWARE at 414-354-8699.  
285  *
286  * 6. Modified radar_to_hdf_1.c. Removed ZDR data from 1C-51 HDF.
287  *
288  * 7. Moved HDF_FILE_VERSION definition from toolkit_1BC-51_appl.h
289  *    into the application level_1.c
290  *
291  *----------------------------------------------------------------------
292  * v1.17 Began 4/23/98.  Released: 4/28/98 (Severity: upgrade)
293  *
294  * 1. Finally received info regarding KDP (KD_INDEX) for SIGMET.
295  *    Assumming the units are similar for LASSEN.  Boosted nsig_to_radar
296  *    to recognize KDP.  It is really KDP * wavelength.  
297  *    The units are deg*cm/km.  You must divide out the wavelength,
298  *    if that is desired.
299  *
300  * 2. BADVAL/NOECHO mod for nsig_to_radar.c.  This should affect
301  *    the values that may be stored in any possible UF output.
302  *
303  * WTD : lassen_to_radar.c  - check the ZDR conversion, if any.  Do
304  *       we need this?
305  * WTD : RHI
306  *
307  *----------------------------------------------------------------------
308  * v1.16 Began 3/6/98.  Released: 4/21/98 (Severity: bug fix/upgrade)
309  *
310  * 1. Changed how any_to_gif output's filenames produced.  Now, they
311  *    are written to stdout.  -v (verbose) and -V (all volume) options
312  *    are added.  Changed image_gen.c (RSL_volume_to_gif) to output
313  *    filenames to stdout.
314  *
315  * 2. You really do need 'bison' (GNU yacc), 'flex' (GNU lex) and
316  *    make (GNU make) to build this library.  This has been true
317  *    since v1.15 when I introduced the rapic format.  These programs
318  *    are superior to those on your stock Unix system, so take the
319  *    time to install them.
320  *
321  * 3. README explains how to apply patches.
322  *
323  * 4. Eliminated the reduce/reduce conflict in rapic.y
324  *
325  * 5. Year 2000 compliant.
326  *
327  * 6. I forgot the format in sprintf.  See rapic.y.
328  *
329  *----------------------------------------------------------------------
330  * v1.15 Began 2/20/98.  Released: 3/4/98 (Severity: bug fix/upgrade)
331  *
332  * 1. Michael Whimpey from BMRC, Australia changed code, for the
333  *    different callibrations, between, Pre_mctex, mctex, Gunn_Pt
334  *    periods. Please see code where there is m.whimpey.  See
335  *    lassen_to_radar.c
336  *
337  * 2. Added RAPIC format ingest.  RSL_rapic_to_radar.
338  *    I used GNU Bison (YACC) and GNU Flex (LEX) to code the RAPIC ingest.
339  *    This format is used by the Berrimah radar.  See rapic_to_radar.c,
340  *    rapic_routines.c, rapic.y, and rapic.l.
341  *    Not tested w/ older YACC and LEX found on older Unix systems.
342  *
343  * 3. Fixed a bug regarding the reading of stdin streams.  Now
344  *    you can read compressed or uncompressed files from stdin.
345  *    Previously, you couldn't specify NULL as a filename and
346  *    have it work reliably in all cases for any file format.
347  *    This bug was found by accident and it is nothing you should
348  *    be worried about in earlier RSL releases.  The reason you need
349  *    not worry about it is because 'RSL_anyformat_to_radar' cannot
350  *    accept NULL as a filename.  For you to notice this, you must
351  *    have called the specific ingest routine for the format
352  *    being read: RSL_lassen_to_radar, for example.
353  *
354  * 4. Bug in the UF ingest.  The scale_factor needs to be float.
355  *    When it was 'int', round off errors (truncation) were
356  *    happening.  This affected the Velocity data, only.  The reflectivity
357  *    data seemed unaffected, because, the magnitude of the values
358  *    was high enough to avoid truncation.
359  *----------------------------------------------------------------------
360  * v1.14 Began 2/2/98.  Released: 2/3/98 (Severity: upgrade)
361  *
362  * 1. Added calibration for Gunn Point radar.   Assumes that
363  *    the radar name will be 'Gunn_Pt'.
364  *
365  *----------------------------------------------------------------------
366  * v1.13 Began 1/16/98.  Released: 1/26/98 (Severity: minor bug fix)
367  *
368  * 01/16/98
369  *
370  * 1. radar_to_hdf_1.c: Changed decision algorithm regarding
371  *    whether or not to write a VOS into a 1C-51 HDF file.
372  *    1C-51 HDF VOS time_slot status is encoded within the
373  *    metaData field 'TK_GEN_DATE_INPUT_FILES'.
374  *
375  *----------------------------------------------------------------------
376  * v1.12 Began 1/12/98.  Released: 1/12/98 (Severity: minor bug fix)
377  *
378  * 1. Changed HDF metadata item for empty granules.
379  *
380  *----------------------------------------------------------------------
381  * v1.11 Began 12/17/97.  Released: 12/17/97 (Severity: minor bug fix)
382  * 
383  * 1. Increased the size of pipecmd in RSL_write_gif and TK_MAX_FILENAME to 256.* 2. Modified image_gen.c to increase the data range of Zdr values.
384  * 3. Bug fix in radar_to_hdf_1.c: No longer dumps core for "tiny" sweeps
385             having fewer than 5 rays.
386  *
387  *----------------------------------------------------------------------
388  * v1.10 Began 8/27/97.  Released: 10/21/97 (Severity: minor upgrade)
389  * 
390  * 1. Modified ZDR image generation: rsl.h, image_gen.c, ZDR color tables.
391  * 2. Added South Africa data format ingest.  Not possible to 
392  *    interface in RSL_anyformat_to_radar, at this time.  The format
393  *    is primitive and I need to convert RVPC to dBZ.
394  * 3. Modified HDF component to maintain integrity of anomalous_condition
395  *    flags. (RFVAL, APFLAG, NOECHO, BADVAL)
396  *    Files: toolkit_1BC-51_appl.h, hdf_to_radar.c, radar_to_hdf_2.c
397  * 4. Modified radar_to_hdf_1.c for TSDIS/DAAC metadata requirements.
398  * 5. Modified any_to_gif.c to output site and date/time for image filenames.
399  * 6. Added QC algorithm parameter. Modified files:
400  *    toolkit_1BC-51_appl.h, radar_to_hdf_1.c, radar_to_hdf_2.c,
401  *    hdf_to_radar.c
402  *
403  *----------------------------------------------------------------------
404  * v1.9 Began 8/18/97.  Released: 8/18/97 (Severity: bug fix)
405  *
406  * 1. Mofified radar_to_hdf_1.c : Metadata mods for TSDIS.
407  *
408  *----------------------------------------------------------------------
409  * v1.8 Began 7/30/97.  Released: 8/05/97 (Severity: upgrade)
410  *
411  * 1. Added RSL_read_these_sweeps.  Specify specific sweep numbers for
412  *    ingest. This drastically speeds up ingest, if you're only interested
413  *    in the first or first couple of sweeps.  For example, making 
414  *    base scan images.
415  *          wsr88d -done
416  *          UF     -done
417  *          sigmet -done
418  *          lassen -done
419  *          HDF    -done
420  *          toga   -done
421  *          mcgill -done.  BUT, apparently, mcgill ingest is broken!!!
422  *                         When did this happen?
423  *
424  * 2. Added RSL_load_zdr_color_table();
425  *    Includes color tables for this field.  See colors/
426  *
427  * 3. More HDF mods; more warning messages.  
428  *
429  * 4. The TRMM Office has fixed several bugs in the TSDIS toolkit.
430  *    For proper HDF creation, that conform to TSDIS HDF specifications,
431  *    you will need toolkit 4.5r1.1.
432  *
433  *    Toolkit 4.5r1.1 is an unofficial release; the TRMM office will
434  *    pass this out upon request.
435  *
436  *----------------------------------------------------------------------
437  * v1.7 Began 7/23/97.  Released: 7/25/97 (Severity: bug fix)
438  *
439  * 1. Handles corrupt SIGMET files more gracefully.
440  *
441  * 2. All lat/lon (degree,minute,second) triplets have the same sign.
442  *    Except, if UF, then what ever the file tells me and if they're
443  *    not all the same sign, then you'll have
444  *    to correct the UF w/ an RSL application.  In other words, UF
445  *    stores the lat/lon as deg/min/sec and they have their own signs;
446  *    Strict UF have deg/min/sec all w/ the same sign, anyway.
447  *
448  * 3. Minor changes to HDF component of RSL.
449  *----------------------------------------------------------------------
450  * v1.6 Began 5/02/97.  Released: 7/23/97 (Severity: bug fix)
451  *
452  * 1. wsr88d_to_radar.c -- Was too permissive. No longer defaults to KMLB.
453  *    If unable to establish a valid site based on callID or first_file,
454  *    returns NULL.
455  *
456  * 2. 18 Jul 97 Kolander
457  *    Modified radar_to_uf.c & uf_to_radar.c : Fixed some incorrect and
458  *    missing sweep and ray header values. Salvaged some numerical precision.
459  *
460  * 3. Fixed a time problem in nsig_to_radar.c.  Daylight savings time.
461  *
462  * 4. Saves lat/lon on each ray for UF.
463  *
464  *--------------------
465  * 16 Jun 97 Kolander
466  *
467  * Modifications to radar parameter calulations in:
468  * wsr88d_to_radar.c, wsr88d.h, wsr88d.c, nsig_to_radar.c,
469  * lassen_to_radar.c, rsl.h
470  *
471  *  Modified HDF-related files:
472  *    hdf_to_radar.c toolkit_1BC-51_appl.h
473  *  and  split file 'radar_to_hdf.c' into two files:
474  *    radar_to_hdf_1.c and radar_to_hdf_2.c
475  *  Can handle oddly sized and/or corrupt VOSs.
476  *----------------------------------------------------------------------
477  * v1.5 Began 3/17/97.  Released: 4/30/97 (Severity: minor upgrade)
478  *  
479  * 1. Additional error checking in wsr88d.c to warn when number of gates
480  *    expected is exceeded.
481  * 2. Changes by Mike Kolander affect the HDF component of RSL.  This
482  *    version of RSL works with the TSDIS toolkit 4.0.
483  * 3. Changes to carpi and cube functions, see below.
484  *-------------------------
485  * Date: 26 Mar 97  kolander
486  *
487  * Files: radar_to_hdf.c, hdf_to_radar.c
488  *   Moved QC parameters out of the metadata string into VOS comments
489  *   field.
490  *
491  * Files: rsl.h, anyformat_to_radar.c
492  *   Moved enum File_type definition from anyformat_to_radar.c into
493  *   rsl.h
494  *--------------------------
495  * Date: 17 Mar 97  kolander
496  *
497  * File: rsl.h
498  *   Changed carpi structure:
499  *     Added f, invf fields.
500  *     (Carpi_value **)data is now a doubly indexed array 'data[nrow][ncol]'
501  *   Changed slice structure:
502  *     Added f, invf fields.
503  *     (Slice_value **)data is now a doubly indexed array 'data[nrow][ncol]'
504  *   Added function prototypes for:
505  *      RSL_free_carpi, RSL_free_cube, RSL_free_slice, RSL_new_cube,
506  *      RSL_new_slice, RSL_carpi_to_cart, RSL_carpi_to_gif,
507  *      RSL_carpi_to_pict, RSL_carpi_to_ppm, RSL_carpi_to_pgm
508  *
509  * File: cube.c
510  *   Added functions:
511  *     RSL_free_slice, RSL_new_slice, RSL_new_cube, RSL_free_cube
512  *   Modified functions:
513  *     RSL_volume_to_cube, RSL_get_slice_from_cube
514  *
515  * File: carpi.c
516  *   Added functions:
517  *      RSL_free_carpi 
518  *   Modified functions:
519  *      RSL_new_carpi, RSL_find_rng_azm, RSL_cappi_to_carpi
520  *
521  * File: image_gen.c
522  *   Added functions: 
523  *     (These are modified clones of the sweep image_gen functions.)
524  *     RSL_carpi_to_cart, RSL_carpi_to_gif, RSL_carpi_to_pict,,
525  *     RSL_carpi_to_ppm, RSL_carpi_to_pgm
526  *
527  *----------------------------------------------------------------------
528  * v1.4 Began 12/24/96.  Released: 3/7/97 (Severity: bug fix)
529  *
530  * 1. Some WSR88D files have a 'radial status' of 28.  This is un-
531  *    documented.  I assume it means some catastrophic reset has occured.
532  *    Therefore, the code that counts the number of rays is modified
533  *    to rely on the 'ray_num' reported upon reading the file.
534  *    Also, I assume that when the status tells me that I'm reading
535  *    the 'start of a new elevation' (status == 0) that all subsequent
536  *    records will overwrite previously stored rays.
537  *
538  *    I've seen this status number(28) occur, rarely, in the
539  *    WSR88D data.  See wsr88d.c.
540  *
541  * 2. Removed kwaj component.  - Mike.
542  *
543  * 3. Installs toolkit_1BC-51_appl.h in INCDIR.  This file is needed
544  *    only if you plan to use the HDF component.
545  *
546  * 4. Fixes a freeing bug in nsig.c.  Added member nparams to the 
547  *    NSIG_Sweep structure to track this for the free routine.
548  *
549  * 5. Ray indexing bug fixed in wsr88d_to_radar.c which produced an
550  *    invalid time when the first wsr88d ray was null.  Basically, using
551  *    'i' instead of 'iray'.
552  *----------------------------------------------------------------------
553  * v1.3 Began 08/26/96.  Released: 12/17/96 (Severity: upgrade)
554  * 
555  * 1. Lassen field 'Zdr' loaded into RSL 'ZD' field, not the RSL 'DR' 
556  *    field, as originally envisioned within HDF functions. Henceforth, 
557  *    'ZD' represents (linear) reflectivity depolarization ratio:
558  *      ZD = 10log(Z_horiz/Z_vert) in units dB
559  *    as opposed to the circular depolarization ratio.
560  *    
561  *    What exactly are the RSL 'LR' and 'DR' fields??
562  *    
563  *    
564  *    For consistency of field nomenclature:
565  *    
566  *    Renamed 'CR' to 'CD'.  (corrected ZDR for 1C-51)
567  *            'MR' to 'MD'.   (1C-51 mask for ZDR)
568  *    
569  *    CD_F returns ZD_F
570  *    CD_INVF returns ZD_INVF
571  *    
572  * 2. Sort by time forgot to compare the hour field.  Minor fix.
573  *
574  * 3. Fix z_to_r to return proper value.   
575  *
576  * 4. Lassen ingest: fix the sign of deg/min/sec so they match.
577  *    Trusting that the sign of the deg is correct.
578  *
579  * 5. Added RSL_select_fields.  This reduces memory requirements
580  *    upon ingest.  You can select, "all" (default), "none" (just to
581  *    get header info) or "dz", "vr", ...
582  *
583  *    WHAT?    STATUS?
584  *    lassen   done
585  *    wsr88d   done
586  *    UF       done
587  *    nsig     done
588  *    nsig2    done
589  *    kwaj     not applicable as it only has DZ.
590  *    hdf      done
591  *    mcgill   not applicable as it only has DZ.
592  *    toga     not done.  If you want to do this, feel free.
593  *
594  * 6. Uses 'gzip -1'.  This cuts the time for making UF files in half.
595  *
596  * 7. Renamed 'makefile' to 'Makefile'
597  *
598  * 8. The HDF component has changed drastically and is not compatable
599  *    with previous versions.  It may change again, contingent upon
600  *    the TSDIS toolkit 3.5.2.1 (as of 12/17/96).  Expect minor changes
601  *    to the HDF component in the future.
602  *
603  * 9. Pruning of sweeps and rays now sets moved object pointers to
604  *    NULL.  See prune.c
605  *
606  *10. Updated nsig_to_radar.c to check for ant_scan_mode.  If mode is
607  *    RHI, then return NULL because RSL can't handle RHIs. --Paul
608  *
609  *11. Split memory management routines for hdf processing. --Mike K.
610  *----------------------------------------------------------------------
611  * v1.2 Began 08/26/96.  Released: 9/6/96 (Severity: minor bug-fix upgrade)
612  *
613  * 1. Eliminated zero sized arrays in lassen.h.  SGI 'cc' can't
614  *    handle zero sized arrays.  This brings back the -pedantic
615  *    compile flag.   
616  *
617  * 2. Implemented popen and pclose (called rsl_popen and rsl_pclose)
618  *    to eliminate the annoying message 'Broken pipe.' on SGI and HP
619  *    computers.
620  *
621  * 3. The HDF component is incompatable with earlier versions because
622  *    of the use of additional fields.  It now uses the MASK fields
623  *    and calibration information.  It should be considered that the 
624  *    HDF component is in a state of flux.
625  *
626  * 4. Minor bug in nsig.c wherein when rays are missing (0 sized)
627  *    that not all rays present will be ingested.  This is fixed.
628  *
629  * 5. Copyrighted the software.
630  *
631  * 6. 'anyformat_to_radar' can recognize HDF files.
632  *
633  *----------------------------------------------------------------------
634  * v1.1 Began 08/21/96.  Released: 08/22/96 (Severity: SERIOUS bug fix)
635  *      If you have already upgraded to RSL v1.0.1, then this is a minor
636  *      upgrade.
637  *
638  * 1. I should have left well enough alone.  But, getting rid
639  *    of rsl.h.template in favor of only having rsl.h has revealed
640  *    a serious bug.
641  *
642  *    THIS BUG IS IN V1.0 ONLY.
643  *
644  *    The type for 'Range' could be built into
645  *    the RSL differently than how your application is built.
646  *    For instance, if RSL is built with USE_TWO_BYTE_PRECISION, then
647  *    your application will think 'Range' is a one byte storage class,
648  *    because the default RSL configuration is to use one byte storage.
649  *
650  *    This bug slipped through all the tests that I perform and was 
651  *    discovered only when using the radar_to_hdf component of RSL.
652  *    Thanks to Mike Kolander for finding this one. 
653  *
654  *    Configuration instructions are changed so that you must edit
655  *    rsl.h to use one byte precision.
656  *
657  * 2. All MCTEX fields are recognized and loaded into Radar.
658  *    h.f and h.invf are modeled after LASSEN conversion functions.
659  * 3. Added radar_to_hdf.o to makefile.
660  * 4. In examples/any_to_gif.c, outputs all fields.
661  * 5. Three convience arrays are defined in rsl.h.
662  *    a. RSL_ftype[];
663  *    b. RSL_f_list[];
664  *    c. RSL_invf_list[];
665  *    Each array is MAX_RADAR_VOLUMES long and contain: strings 
666  *    representing the field type, a pointer
667  *    to the F function, and a pointer to the INVF function.
668  *
669  *    Usage is conditional by defining USE_RSL_VARS before including
670  *    rsl.h.  Use:
671  *       #define USE_RSL_VARS
672  *       #include "rsl.h"
673  *
674  *    Normally, you shouldn't worry about this.
675  *
676  * 6. Removed -pedantic compile flag because LASSEN code has a 0
677  *    sized array -- no warnings.
678  *----------------------------------------------------------------------
679  * v1.0 Began 04/19/96.  Released: 8/18/96 (Severity: minor upgrade)
680  *
681  * 1. Ignore SIGPIPE when making images.
682  * 2. Can read UF files of MCTEX data.  This UF file contains
683  *    RH and PH fields.  This is LASSEN data that has been converted
684  *    to UF via a sun program.  It is the LASSEN II format.
685  * 3. Fixed date/time == 0 when calling uf_to_radar multiple times.
686  *    The second and subsequent calls produced 0 for the
687  *    radar->h.year/month/day and radar->h.hour/min/second.
688  * 4. Always allocate MAX_RADAR_VOLUMES for new radars during ingest.
689  *    This will allow one to test any volume index for presence.
690  * 5. Set the default functions to DZ_F.  This sets CZ_F correctly.
691  *    It is unclear if the other conversion fuctions are properly
692  *    defined.
693  * 6. Pure UF file ingest bug fixes.
694  * 7. Added RSL_hdf_to_radar - Mike Kolander.
695  * 8. Added RSL_radar_to_hdf - Mike Kolander.
696  * 9. New field type: XZ for X-band Reflectivity.
697  * 10. Working version of nsig_to_radar. - Paul Kucera.
698  *     This version works on both big endian and little endian (Linux),
699  *     and, for both version 1 and version 2 formats.  Version 2
700  *     files are generated on big-endian machines (so far, SGI Iris 
701  *     computers), whereas, Version 1 files were written on
702  *     little-endian DEC computers.  Two routines are provided:
703  *
704  *     RSL_nsig_to_radar(char *infile);
705  *     RSL_nsig2_to_radar(char *infile);
706  *
707  *     Nsig ingest can handle nsig files/tapes that were
708  *     written on a DEC (little endian) or an SGI (big endian).
709  *     It is handled automatically by examination of the 'magic' bytes.
710  *     You will note that the byte-ordering in the file is dependant
711  *     on which machine wrote the tape or file.  The New-SIGMET 
712  *     documentation does not specify which byte-ordering is to be used
713  *     when the file is written.
714  *
715  *     Re-wrote nsig.c and beefed up nsig.h.  Now, there is an 
716  *     interface to read an entire nsig sweep.  You can loop through
717  *     the returned sweep and pick your values, and load RSL.
718  *     This re-write was done to make reading version 2 files easier.
719  *     Additionally, all NSIG code for version 1 and version 2 files
720  *     is centrally located in:
721  *           nsig.h
722  *           nsig.c
723  *           nsig_to_radar.c
724  *     To have both versions supported in the same files, I use #ifdef
725  *     and the C preprocessor.  'nsig.h' is saturated with #ifdef NSIG_VER2
726  *     constructs.  Thus, only one source is maintained for both NSIG versions.
727  *
728  * 11. Added RSL_print_version();
729  * 12. Added docs for users guide, hdf.
730  * 13. Added html 'grouping by functionality' page.
731  * 14. Restores stdin and stdout when creating pipes.
732  *     The pipe readers need to loop until no data available, because
733  *     'read/fread' will not get all the data in one call.
734  * 15. Added moving platform headers to Ray structure:
735  *      float pitch;       Pitch angle.
736  *      float roll;        Roll  angle.
737  *      float heading;     Heading.
738  *      float pitch_rate;  (angle/sec)
739  *      float roll_rate;   (angle/sec)
740  *      float heading_rate;  (angle/sec)
741  *      float lat;           Latitude (degrees)
742  *      float lon;           Longitude (degrees)
743  *      int   alt;           Altitude (m)
744  *      int   rvc;           Radial velocity correction (units of velocity)
745  *
746  *     This information typically comes from NSIG.  For other formats
747  *     the values are all zero.
748  * 16. Read version 1.3 and 1.4 of LASSEN data.  RSL_lassen_to_radar.
749  *     This means that RSL can read MCTEX data.
750  * 17. Users manual.  Walk a novice through a simple example and explain
751  *     what header information is important.  Teach how to take advantage
752  *     of the library.
753  * 18. Eliminated the #ifeq in makefile.  Thus, rsl.h.template is removed
754  *     and rsl.h is resurrected.
755  *----------------------------------------------------------------------
756  * v0.45 Began 03/26/96.  Froze: 03/27/96  (Severity: minor)
757  *
758  * 1. Fixed broken pipe problem on HP and SGI.  Cause unknown.
759  *    All I did was to remove the pclose in any_format_to_radar.c
760  *    It seems that if there is any data left in the pipe that a 
761  *    SIGPIPE is sent when trying to close the pipe.
762  *    On SGI's this causes a core dump.  This bug is difficult to
763  *    reproduce.
764  * 2. Nsig ingest is severly broken.  It always was.  Work in
765  *    progress.
766  * 3. It is important that TSDIS get this version to run on their SGI
767  *    as it prevents a core dump.  Normally, this shouldn't affect 
768  *    anyone.
769  *----------------------------------------------------------------------
770  * v0.44 Began 03/19/96.  Froze: 03/19/96.
771  *
772  * 1. In prune.c, pointers that are pruned are now set to NULL.
773  *    This elimated core dumps associated with trying to free structues.
774  * 2. On gzip-ed UF output, stdout is flushed before the pipe is opened.
775  * 3. Added reverse.c -- Reverse the order of the sweep pointers in
776  *    a volume.
777  *----------------------------------------------------------------------
778  * v0.43 Began 03/01/96.  Froze: 03/05/96.
779  *
780  * 1. farea.c -- nbins fix.
781  * 2. On UF output, checks for NOECHO.
782  *
783  *----------------------------------------------------------------------
784  * v0.42 Began 11/27/95.  Froze: 02/16/96.
785  *
786  * 1. Removed '#include <strings.h>'.
787  * 2. Added a couple of missing prototypes in rsl.h.template.
788  * 3. Added:
789  *     Ray    *RSL_prune_ray   (Ray  *ray);
790  *     Sweep  *RSL_prune_sweep (Sweep  *s);
791  *     Volume *RSL_prune_volume(Volume *v);
792  *     Radar  *RSL_prune_radar (Radar  *r);
793  *
794  *     These routine remove dataless substructures.  Prompted by
795  *     poor NCAR ingest routines for UF files; it is wise to prune
796  *     a Radar prior to calling RSL_radar_to_uf.  Therefore, if 
797  *     software cannot read the UF files created by RSL, then try these
798  *     prune functions before outputting the UF file.  In either case,
799  *     RSL_radar_to_uf produces valid UF files.
800  * 4. Removed trigraph in mcgill.c.
801  * 5. Fixed lassen ingest problem on Linux.  I think XDR has a bug
802  *    where bit fields are not loaded properly.  This is a kludge fix.
803  * 6. Removed column.c.  Code not mature and takes way too much
804  *    RAM.  Included in the removal are the vertical structure routines.
805  *    The code has been moved to the application (qcwin).
806  * 7. RSL_get_first_ray_of_sweep now returns when the ray number is 1 or
807  *    0.  This drasitically speeds the routine.
808  * 8. Increased the UF buffer size from 4096 to 16384.
809  *----------------------------------------------------------------------
810  * v0.41 Began 11/01/95.  Froze: 11/20/95.
811  *
812  * 1. Minor doc changes.  More up to date with implementation.
813  * 2. Implemented 'radar_type' in the radar_header structure.  Values
814  *    are strings and are: "wsr88d", "lassen", "uf", "nsig", "mcgill",
815  *    "kwajalein", "toga".
816  * 3. Increased range of data (internal storage conversion functions)
817  *    when using 2 byte storage.  Some nsig data can have values below the 
818  *    default wsr88d function range.
819  * 4. 'farea.c' -- Volumes are used to compute the fractional area.
820  *                 This matches the latest specification of the function.
821  * 5. Automatically uncompress files.  Transparently sets up
822  *    a decompression pipe.  If the input is not stdin, then 'anyformat_to...'
823  *    can peek inside a compressed file and determine what ingest routine to
824  *    use.  Reading copmressed files from disk and internally uncompressing
825  *    them turns out to be the fastest form of ingesting wsr88d (only format
826  *    timed) data on my 486.  However, I get mixed results on the HP 755.
827  *    'anyformat_to...' uses 'gunzip' to peek inside compressed files.
828  * 6. Can make gzip-ed UF files.  The new routine is 'RSL_radar_to_uf_gzip'.
829  *    Also, RSL_radar_to_uf_fp takes a file pointer.  Thus, you can
830  *    define your own output filter.
831  * 7. Added RSL_write_radar_fp, RSL_write_radar_gzip.
832  *----------------------------------------------------------------------
833  * v0.40 Began 10/24/95.  Froze: 10/24/95.
834  *
835  * 1. Type cast for Sweep_header and Ray_header was removed so that
836  *    stock 'cc' on SGI could digest the code.  File: column.c. Why?
837  *
838  * Version 0.39 was short lived. :-)
839  *----------------------------------------------------------------------
840  * v0.39 Began 7/1/95.  Froze: 10/24/95.
841  *
842  * 1. Mcgill library is not separate.  Included in rsl in whole.
843  * 2. Interpolation routines added.
844  * 3. Added RSL_load_height_color_table  -- and the colors/*height.clr
845  * 4. Added RSL_load_rainfall_color_table  -- and the colors/*rainfall.clr
846  * 5. Removed RSL_print_{volume,sweep,ray}
847  * 6. Removed some unused routines.
848  * 7. Vertical_structure is its own type composed of Vertical_sweeps and
849  *    Vertical_rays (columns).
850  * 8. Added doc/internal_routines.html.
851  * 9. UF is exchangable between big and little endian.  Finally, this
852  *    has been fixed.  Now UF can be generated on little endian machines
853  *    and read on big endian (the UF generated is in big endian format even
854  *    on the little endian machine).  And, visa versa.
855  *10. New version of RSL_get_vertical_structure in column.c.  Doc's updated.
856  *11. Fixed bug in radar_to_uf.  When the number of actual sweeps (and perhaps
857  *    volumes) is less than the determined max of the entire radar structure,
858  *    then the pointers may be erroneous.  Paul caught this flounder.
859  *12. Added RSL_uf_to_radar_fp.  The FILE *fp version of the UF ingest.
860  *    Also, passing NULL to RSL_uf_to_radar means to read from stdin.
861  *13. Added NOECHO flag for f and invf.  Currently, defined for UF, NSIG and
862  *    Kwaj data.
863  *14. Included source for libraries: wsr88d, lassen, tg, nsig, mcgill,
864  *    and kwajlein. Now linking needs only: -lrsl -lm
865  *15. Simplified the configuration procedure.  All configuration
866  *    is specified from 'makefile'.  See README for new install instructions.
867  *16. Removed ray_status, sec_num, atm_att, min_dif, sys_cal from ray
868  *    header.  These are not used and specific for wsr88d.
869  *17. Summary of routine that handle NULL filenames as STDIN.
870  *        RSL_wsr88d_to_radar
871  *        RSL_uf_to_radar         -- calls --> RSL_uf_to_radar_fp
872  *        RSL_lassen_to_radar
873  *        RSL_nsig_to_radar
874  *        RSL_toga_to_radar
875  *        RSL_mcgill_to_radar
876  *18. Removed RSL_get_sweep_index_from_volume.
877  *19. Removed RSL_X_ray_indexes.  Actually, just renamed the routine
878  *    to 'construct_sweep_hash_table'.  The hash table retains the hi and
879  *    low ray pointers for closest ray comparison.  Angle diff's removed.
880  *20. Removed hash table implementation in the Sweep structure.  It
881  *    is now implemented internally in RSL.
882  *21. BADVAL valued depends on Range type.  Picked to be out of range.
883  *
884  *----------------------------------------------------------------------
885  * v0.38 Began 6/1/95.  Froze 6/29/95.
886  *
887  * 1. Makes 2's compliment, instead of 1's compliment, in sweep_to_cart.
888  * 2. Modifications to eth functions.
889  * 3. Added routine RSL_get_column. See column.c.
890  * 4. Added Column data structure.
891  * 5. Static pointer for image generation.  Free up image pointer and
892  *    reallocate.  Otherwise, we've got a memory leak when making many
893  *    images.
894  * 6. Added Paul's and Dennis's modifications of the cappi routines.
895  *    I modified the cappi structure so that Sweep is a substructure.
896  *    This makes image generation and get_value_from_cappi easy to implement.
897  * 7. Added a test program in examples/cappi_image.c to test cappi
898  *    generation.
899  * 8. Change doc/ for the cappi routines.  Routines added/modified are:
900  *      float RSL_get_value_from_cappi(Cappi *cappi, float rng, float azm);
901  *      int RSL_fill_cappi(Volume *v, Cappi *cap, int method);
902  *      void RSL_free_cappi(Cappi *c);
903  *      Cappi *RSL_new_cappi(Sweep *sweep, float height);
904  *      Cappi *RSL_cappi_at_h(Volume  *v, float height, float max_range);
905  *      Carpi *RSL_cappi_to_carpi(Cappi *cappi, float dx, float dy,
906  * 9. Carpi structure modified to be compatable with cappi routines.
907  * 10. Added RSL_get_gr_slantr_h.  -> range.c
908  * 11. RSL_uf_to_radar only recognizes UF files.
909  * 12. RSL_uf_to_radar handles TRUE UF, 2 and 4 byte record length delimeters.
910  * 13. Minor bug fix in ray_indexes.c to handle RHI input.  The number of
911  *     hash table entries is now a function of the beam_width and not the
912  *     number of rays.
913  * 14. Bug fix in rebin_velocity_sweep.  New velocity color tables.
914  *     'examples/qlook.c' added.  Yet another image generation program;
915  *     redundant.
916  * 15. RSL_uf_to_radar allocated additional space for sweeps, when the
917  *     initial allocation is not enough.
918  * 16. Added a programmers guide.  See programmers_guide.html.
919  * 17. Get_closest routines removed.
920  * 18. Added RSL_kwaj_to_radar.  -- Mike Kolander.
921  * 19. Added docs for RSL_kwaj_to_radar.
922  *
923  * Note: Since v0.37 we've been using h.f and h.invf for the storage
924  * functions and, thus, the library is not compatable with earlier
925  * versions.  All subsequent version are, however, compatable.
926  * This means, code that used v0.36 and earlier will break (not
927  * even link) with v0.37 or later.
928  *
929  * You must now use:
930  *    ray->h.f(ray->range[i]) instead of F(ray->range[i])
931  * and
932  *    ray->h.invf(x) instead of INVF(x).
933  *
934  *----------------------------------------------------------------------
935  * v0.37 Began 5/24/95.  Froze 5/29/95.
936  *
937  * 1. Removed RSL_float_to_char; too specific.
938  * 2. Implemented seperate conversion functions for each field type.
939  *    This added h.f and h.invf to Volume, Sweep and Ray headers.
940  *    The ingest routines optionally define there own conversion function.
941  *    Most of the time, though, I use the default: wsr88d conversions.
942  *      Tested: wsr88d, lassen, mcgill, UF, rsl.
943  *      Coded but not tested: toga, nsig.
944  * 3. Added ETH routines:
945  *      Sweep *RSL_get_eth_sweep(Volume *v,float et_point);
946  *      float RSL_get_echo_top_height(Volume *v,float azim,float grange, float et_point);
947  * 4. If using #define USE_TWO_BYTE_PRECISION, uses 100 as a storage
948  *    factor.  Now, there is no loss of precision when converting between
949  *    internal and float.  Before there was just a minor round off when
950  *    using any data that used anything other than 1/2 dbz precision.
951  *    Using 100 is more than enough.
952  *----------------------------------------------------------------------
953  * v0.36 Began 5/19/95. Froze 5/19/95.
954  *
955  * 1. Magic in anyformat_to_radar was slightly different than expected
956  *    for lassen data.  Tested on lassen data.
957  * 2. DEFAULT is to use 2 byte storage precision.  See rsl.h.
958  * 3. Several changes to get_closest routines -- Flanigan.
959  *
960  *----------------------------------------------------------------------
961  * v0.35 Began 5/18/95. Froze 5/18/95.
962  *
963  * 1. Checks iazim validity in ray_indexes.c.  Bad angles use to cause
964  *    core dumps.
965  * 2. wsr88d_to_radar can handle bogus filenames and callid's.
966  *
967  *----------------------------------------------------------------------
968  * v0.34 Began 5/17/95. Froze 5/18/95.
969  * 
970  * 1. Modified the bscan interface.
971  *
972  * 2. Fixed a minor nrays bookkeeping bug in radar_to_uf.
973  *
974  * 3. Updated Sweep searching routines.
975  *
976  * 4. Added get_closest and get_next_closest ray searching routines.
977  *    Updated RSL_get_ray_from_sweep so that it uses the 
978  *    new_get_closest function.
979  *
980  *----------------------------------------------------------------------
981  * v0.33 Began 5/12/95. Froze 5/16/95.
982  *
983  * 1. Configure for building using 2 byte precision instead of 1 byte.
984  *    This should quell any accuracy problems associated with the
985  *    functions F and INVF.
986  *
987  * 2. Added 'RSL_mcgill_to_radar'.  Link with -lmcgill.
988  *
989  * 3. Bug fix in cube.c, cappi.c, and carpi.c.
990  *----------------------------------------------------------------------
991  *
992  * v0.32 Began 5/5/95. Froze 5/12/95.
993  *
994  *    1. Compiles with -Wall -ansi -pedantic.
995  *    2. Minor bug fixes in get_win.c
996  *    3. Compiles on SGI, 486, SUN, HP using gcc or stock cc.
997  *----------------------------------------------------------------------
998  * v0.31 Began 4/28/95. Froze 5/5/95.
999  *
1000  *    1. Added ray_high and ray_low Azimuth_hash pointers
1001  *       to Azimuth_hash data structure and code in the
1002  *       the routine RSL_sweep_ray_indexes to set these
1003  *       pointers.  ray_low points to the Azimuth_hash
1004  *       with the next lowest ray_angle, with ray_high
1005  *       points to the next highest.
1006  *
1007  *    2. Created internal routine dir_angle_diff.  Returns
1008  *       negitive difference if the second angle in 
1009  *       the parameter list is counter-clockwise to the
1010  *       first angle.  Returns positive is second 
1011  *       angle is clockwise tk first angle.
1012  *    
1013  *    3. Added internal routine the_closest_hash.  This
1014  *       routine returns the an Azimuth_hash
1015  *       data structure that contains the closest
1016  *       ray to the requested angle.
1017  *
1018  *    4. Added two routines:  RSL_get_closest_ray_from_sweep and
1019  *       RSL_get_next_closest_ray_from_sweep.
1020  *
1021  *        5. Added routines: RSL_get_window_from_radar, 
1022  *       RSL_get_window_from_volume, RSL_get_window_from_sweep, and 
1023  *       RSL_get_window_from_ray.
1024  *    
1025  *    6. Modified farea.c.
1026  *    7. Isolated contruction of azimuth table linked list.
1027  *    8. Fixed get_sweep NULL sweep reference (See patch v0_29_3 also).
1028  *    9. Compiles on HP CC, SGI CC, GNU CC.  I had to #ifdef the
1029  *       varargs declaration in anyformat_to_radar.c.  Why?
1030  *   10. Added examples/killer_sweep.c.  This randomizes the azimuth
1031  *       values of each ray.  The output checks the sortedness of the
1032  *       hi and low links in the hash table.
1033  *   11. Added doc/...closest...   doc/...next_closest...
1034  *
1035  *-------------------------------------------------------------------------
1036  * v0.30 Began 4/20/95.  Froze 4/27/95
1037  *
1038  *    0. IMPORTANT: Renamed libradar.a to librsl.a.  Also, radar.h to rsl.h.
1039  *    1. Removed NOTFOUND_H reference in the get_ray function.
1040  *    2. Simplified get_sweep.
1041  *    3. Uses within 1/2 beam_width test in get_ray_from_sweep.
1042  *    4. Checks -1 and +1 bin in azimuth hash table to really find the
1043  *       closest ray that is within 1/2 beam_width of the target azim.
1044  *       Surprisingly, it shortened the get_value_from_sweep routine.
1045  *
1046  *    5. Added anyformat_to_radar.c.  Uses magic information to determine
1047  *       the file format.  Handles: UF, RSL, WSR88D, LASSEN.  Toga may
1048  *       be difficult.  Unknown, yet, for NSIG.  Alan will get me that
1049  *       information.
1050  *    6. Added beam_width to the ray structure.
1051  *-------------------------------------------------------------------------
1052  * v0.29.1 Began 4/18/95. Froze 4/18/95.
1053  *
1054  *  1. Bug fix in endian.c.  Needed to initialize the word.val to 0.
1055  *  2. Bug fix in radar_to_uf.c.  little_endian() call.
1056  *  3. Added Azumuth_hash to structure list in doc/.
1057  *  4. Other minor changes.
1058  *-------------------------------------------------------------------------
1059  * v0.29 Began 3/1/94. Froze ??/??/??
1060  *
1061  *  0. Thanks to Dennis Flanigan for helping with this release.
1062  *
1063  *  1. Modified sort_rays.c.  By Dennis Flanigan, Jr.
1064  *     a. Added h.sorted_flag to Volume and Sweep header structures.
1065  *
1066  *     b. Added routines:
1067  *        int     ray_sort_compare_by_time(Ray **r1,Ray **r2);
1068  *        int     sweep_sort_compare(Sweep **s1, Sweep **s2)
1069  *        Sweep  *RSL_sort_rays_by_time(Sweep *s);
1070  *        Volume *RSL_sort_sweeps_in_volume(Volume *v)
1071  *        Volume *RSL_sort_volume(Volume *v)
1072  *        Radar  *RSL_sort_radar(Radar *r)
1073  *
1074  *     c. Routines that sort data structures now set the 
1075  *        number of structures in the parent data structure.
1076  *
1077  *     d. Fixed: nsweeps was not being set correctly by
1078  *        RSL_sort_sweeps_in_volume.
1079  *
1080  *  2. Removed sort calls in the ingest routines:  (whatever)_to_radar.
1081  *
1082  *  3. Removed the auxillary trig tables in image_gen.c.  It's just a 
1083  *     memory hog.
1084  *
1085  *  4. Changed the extension of the tar archives to .tgz.  This
1086  *     allows netscape to ftp the file rather than displaying it :-)
1087  *
1088  *  5. Added variables in the sweep data structures to represent
1089  *     the half of the beam width angles.  These variables are 
1090  *     vert_half_bw and horz_half_bw.   Also added code to all
1091  *     RSL ingest routines (something_to_radar) to set these values.
1092  *     The half angle values are used in the volume.c searching routines.
1093  *
1094  *  6. Added h.indexes to Sweep structure.  This is a simple hash
1095  *     table for making azimuth lookup cake.  So far, I've only
1096  *     got the malloc part placed in the routines that create the
1097  *     radar structure.  Added the file 'ray_indexes.c'.  This changes
1098  *     RSL_get_value_from_ray.
1099  *
1100  *     Code affected: 
1101  *        Modify code:
1102  *           RSL_copy...
1103  *           RSL_free...
1104  *           RSL_clear...
1105  *           RSL_sort..??? really???
1106  *           RSL_get...
1107  *           RSL_{write,read}_radar
1108  *           RSL_get_ray???
1109  *
1110  *        Modify doc
1111  *           RSL_sweep_struct.html
1112  *
1113  *  7. Updated doc/.
1114  *
1115  *  8. Added CHECK_LIST.
1116  *
1117  *  9. Changed the name from radar-v0.?? to rsl-v0.??.
1118  * 
1119  *  
1120  *-------------------------------------------------------------------------
1121  * v0.28 Began 7/23/94.  Froze  2/16/95
1122  * Changes:
1123  *
1124  *  1. Support for little endian machines (*86 PC's using Linux).
1125  *     Includes 'endian.c' in 'uf_to_radar.c' and 'radar_to_uf'.  It is not
1126  *     needed in 'lassen.c' because that program uses xdr to transfer the
1127  *     data.  Nor is it required in 'wsr88d_to_radar.c', 'nsig_to_radar.c'
1128  *     nor 'toga_to_radar.c' because the support for little endian is in
1129  *     the respective libraries: libwsr88d.a, libnsig.a, libtg.a.
1130  *
1131  *     Requires:
1132  *         wsr88d_v1.12.taz
1133  *         lassen_v1.0.taz
1134  *         libnsig_v1.3.taz
1135  *         libtg_v1.1.taz
1136  *
1137  *     In order to make this library compatable with versions on either
1138  *     big endian or little endian machines, it will be adopted that all
1139  *     output will be in big endian format.  Little endian machines will
1140  *     have to do the extra work of swapping bytes upon input as well as
1141  *     swapping bytes on output.  I could adopt to use the xdr library,
1142  *     however, it seems too complicated for the simple task of always
1143  *     guarenteeing that the output is in big endian format.  After all,
1144  *     we only support one output format: UF.  (Well, we will make our own
1145  *     radar format output in big endian format too, but we keep that
1146  *     knowledge hush hush).
1147  * 
1148  *  2. Documentation in the seperate directory complete for all routines
1149  *     in the RSL.  Documentation froze at v0.27 and is in HTML format.
1150  *     The documentation version number will be updated to match the version
1151  *     number of the most current release of RSL.  Note: The live link is
1152  *     in /PUBLIC/httpd/htdocs/trmm_office/software/radar/quick_reference.
1153  *     It is a symbolic link to ~/proj/trmm/radar/doc/v0.xx.
1154  *
1155  *  3. Added RSL_ prefix to all documentation.  This renamed the HTML files
1156  *     to begin with RSL_, also.
1157  *
1158  *  4. Prefixed all routines with RSL_.  Status is that it builds.
1159  *  5. Combined radar.h, cube.h and volume.h into radar.h.
1160  *
1161  *-------------------------------------------------------------------------
1162  * v0.27 Began 7/23/94.  Froze 9/13/94.
1163  * Changes:
1164  *
1165  *  1. Beam width calculation in get_value_from_sweep is not 1/2 on either
1166  *     side.  No provision for best fit.  See WTD #2.
1167  *  2. Added sort_rays.c.  Sort rays in a sweeps and volumes.
1168  *  3. Added Vset_earth_radius.  Set global variable 'Re' (Default: 4/3R).
1169  *  4. Added trig modification of get_slantr_and_h.
1170  *  5. Added sort rays call to: toga_to_radar, wsr88d_to_radar,
1171  *     uf_to_radar, lassen_to_radar.
1172  *  6. Added cube.c.  By Mike Kolander.
1173  *  7. Added carpi.c
1174  *  8. Added toga_to_radar.c.  By Mike Kolander.
1175  *  9. Signed all source files.
1176  * 10. Quieted some image print statements.  See image_gen.c.
1177  * 11. Changed wsr88d_to_radar so it takes 'first_file' or the 4 character
1178  *     call sign (eg. KMLB).
1179  * 12. Fixed makefile so it removes libradar.a before building.  This prevents
1180  *     duplicate object files, only the long filenamed ones, from
1181  *     appearing in the archive file.
1182  * 13. Added gts.c.  By Dave Wolff.
1183  * 14. Fixed minor round off error in 'uf_to_radar' which caused a 0 dBZ spike.
1184  * 15. Added histogram.c.  By Dave Wolff.
1185  * 16. Added nsig_to_radar.c.  By Alan McConnell.
1186  * 
1187  * WTD:
1188  *
1189  *
1190  *   2. Vget_value_from_sweep.  When the beam width is increased we
1191  *      want to return the value that is the best fit for a ray and not
1192  *      just the first fit.  Currently when the beam width is really
1193  *      large then we will pick the wrong beam for the desired point.
1194  *
1195  *   3. Add the following to the ray header:
1196  *        - u,v for ray.
1197  *        - offset for azim, range, elev (for moving radar)
1198  *        - lat/lon (for moving radar)
1199  *
1200  *   4. Bilinear interpolation.
1201  *   6. Modify get_ray_above to return a good ray so that QC doesn't zap points
1202  *      near the radar.
1203  *   7. Optimize/Improve the get_value routine.
1204  *   8. Remove V prefix to routine names?
1205  *  10. Fix why there are bands of missing data when making images.
1206  *  11. Specify resolution when making images.
1207  *  14. Update: doc's (in HTML), README, etc.
1208  *  16. NEED *TESTING* suite of programs.
1209  *
1210  * Proposed changes for v0.28
1211  *  1. Add support for little endian machines (386, 486, etc.)
1212  *  2. F(x, DZ) or ray->f.dz(x).  I.e., object function conversion functions.
1213  *
1214  *
1215  *-------------------------------------------------------------------------
1216  * v0.26 Began 7/23/94.
1217  * Changes:
1218  *  1. Adding cappi_to_carpi.
1219  *  2. Enhanced the Cappi structure; not the same as a sweep anymore.
1220  *
1221  *-------------------------------------------------------------------------
1222  * v0.26 Began 7/13/94. Froze 7/20/93.
1223  * Changes:
1224  *  1. Units for wavelength, in radar_to_uf, changed from meters to cm;
1225  *     as they should be.
1226  *  2. Library runs quietly.  No noisy print statements.  Call
1227  *     radar_verbose_on() and radar_verbose_off() to control printing.
1228  *-------------------------------------------------------------------------
1229  * v0.25 Began 7/1/94.  Froze 7/1/94
1230  * Changes:
1231  *  1. Modifications to makefile to add portibility to building on 
1232  *     other systems w/o gcc.  Change to CFLAGS.
1233  *  2. Passes lint.
1234  *  3. Moved documents radar.ez and volume.ez to ../doc (../doc_RCS).
1235  *     This means that the version of the documentation will not be kept
1236  *     up to the version of the RSL library.  Only changes to the doc. will
1237  *     force a new version of the documentation.  I'll want to see if this
1238  *     is a good idea.
1239  *-------------------------------------------------------------------------
1240  * v0.24 Began 6/29/94.  Froze 6/29/94
1241  * Changes:
1242  *  1. radar_to_uf, uf_to_radar.  Fixed inconsistant use of BADVAL vs.
1243  *     UF_NO_DATA.  The latter is check and used.
1244  *  2. Added function:
1245  *       float get_nyquist_from_radar(Radar *radar);
1246  *     Useful, for loading non-velocity fields with PRF, PRT and NYQUIST.
1247  *  3. Made the makefile more general and added comments.
1248  *
1249  *  WTD:
1250  *  1. Modify wsr88d_to_radar to fill PRF, PRT and NYQUIST values in
1251  *     non-velocity rays.
1252  *-------------------------------------------------------------------------
1253  * v0.23 Began 6/27/94.  Froze 6/27/94
1254  * Changes:
1255  *  1. First distribution release.
1256  *  2. Added README w/ installation instructions.
1257  *  3. Made example_main and colors directories.
1258  *  4. Shortened lassen.h to be close to minimial.
1259  *  5. Modified makefile to only make libradar.a.  Example_main/ has it's
1260  *     own makefile.
1261  *-------------------------------------------------------------------------
1262  * v0.22 Began 6/24/94.  Froze 6/24/94
1263  * Changes:
1264  *  1. radar_to_uf/uf_to_radar PRF/PRT calculation corrected.
1265  *
1266  *-------------------------------------------------------------------------
1267  * v0.21 Began 6/24/94.  Froze 6/24/94
1268  * Changes:
1269  *  1. radar_to_uf: prf now in microseconds.
1270  *  2. uf_to_radar: prf now converted from microseconds to seconds.
1271  *
1272  *-------------------------------------------------------------------------
1273  * v0.20
1274  * Changes:
1275  *   Need to determine the changes.  
1276  *-------------------------------------------------------------------------
1277  * v0.19 Began 6/17/94.  Froze: 6/17/94.
1278  * Changes:
1279  *  1. Fixed NULL access in write_radar subroutine.
1280  *
1281  *-------------------------------------------------------------------------
1282  * v0.19 Began 6/15/94.  Froze: 6/15/94.
1283  * Changes:
1284  *  1. Check for NULL in Vget_ray_from_sweep fixes a segmentation fault on
1285  *     Sun.
1286  *-------------------------------------------------------------------------
1287  * v0.18 Began 6/11/94.  Froze: 6/12/94 2pm.
1288  * Changes:
1289  *  1. Minor changes in volume.c.  Vget_value_from_sweep now uses the
1290  *     beam_width for matching rays.  See Vget_sweep too.
1291  *  2. cappi.c sets the beam_width.
1292  *  3. Added radar types.  There is no sure fire way to set
1293  *     radar->h.radar_type to one of these values automatically, ie. from
1294  *     information in the input file.  It may have to be done by the
1295  *     application; a runtime parameter, option.
1296  *     Types are:
1297  *         TOGACOARE_TOGA_SIGMET
1298  *                 TOGACOARE_MIT_SIGMET
1299  *                 TRMM_DARWIN_LASSEN
1300  *                 DARWIN_TOGA_SIGMET
1301  *                 TRMM_MELBOURNE_WSR88D
1302  *                 TRMM_KWAJALEIN_SIGMET
1303  *                 TRMM_HOUSTON_WSR88D
1304  *  4. Added function:
1305  *         Sweep *Vget_first_sweep_of_volume(Volume *v);
1306  *  5. Placed the wsr88d code in wsr88d_to_radar.c (removed from radar.c).
1307  *
1308  * WORK TO DO:
1309  *  1. Rework Vget_value_from_sweep to do a better search for the value.
1310  *
1311  *-------------------------------------------------------------------------
1312  * v0.17 Began 6/10/94.  Froze 6/10/94 3:30pm.
1313  * Changes:
1314  *  1. Corrected the pulse width calculation in uf_to_radar and in
1315  *     radar_to_uf.
1316  *-------------------------------------------------------------------------
1317  * v0.16 Began 6/10/94.  Froze 6/10/94 12:30pm.
1318  * Changes:
1319  *  1. Minor changes to radar.c because v1.3 of the wsr88d library is
1320  *     now using WSR88D_DZ, WSR88D_VR, WSR88D_SW as the field type mask.
1321  *     REFLECTIVITY, VELOCITY and SPECTRUM_WIDTH are not used.
1322  *
1323  *-------------------------------------------------------------------------
1324  * v0.15 Began 6/7/94.  Froze 6/7/94 1pm.
1325  * Changes:
1326  *  1. Discovered that the range to bin1 calculation in radar_to_uf.c and
1327  *     uf_to_radar.c was incorrect.  See fh[2] and fh[3].
1328  *
1329  *-------------------------------------------------------------------------
1330  * v0.14 Began 6/2/94.  Froze 6/2/94 1pm.
1331  * Changes:
1332  *  1. Modified the date for the Radar structure for UF reading to reflect
1333  *     the time of the first ray.  It was the generation time of the radar
1334  *     structure, however, Dave Wolff insists that it reflect the time of
1335  *     the first ray.  Modification to 'uf_to_radar.c'
1336  *
1337  *-------------------------------------------------------------------------
1338  * v0.13 Began 6/2/94.  Froze 6/2/94 11am.
1339  * Changes:
1340  *  1. Modified radar_to_uf.c to undo the faking of the headers.  This is
1341  *     the correct way.
1342  *
1343  *-------------------------------------------------------------------------
1344  * v0.12 Began 5/31/94.  Froze 5/31/94 7pm.
1345  * Changes:
1346  *  1. Check for malloc errors in Vnew* routines.
1347  *  2. Fixed a nasty bug in radar_to_uf.  I was letting 'j' get to high
1348  *     for a particular ray in a sweep.  'j' is looping on the maximum
1349  *     rays possible.  I noticed this bug only after Vcopy_volume to 
1350  *     replace a radar->v[i].
1351  *-------------------------------------------------------------------------
1352  * v0.11 Began 5/27/94.  Froze 5/27/94 12:50pm.
1353  * Changes:
1354  *  1. Modified radar_to_uf.c to fake header information when fields do
1355  *     exist, eventually, but not in the current sweep.  This is to allow
1356  *     brain dead UF ingestors (Zeb, RDSS, etc.) to read the UF file; they
1357  *     assume that whatever fields exist in the first UF sweep is constant
1358  *     throughout the file.
1359  *
1360  *  2. Added functions to volume.c
1361  *       Ray *Vget_first_ray_of_sweep(Sweep *s);
1362  *       Ray *Vget_first_ray_of_volume(Volume *v);
1363  *
1364  *-------------------------------------------------------------------------
1365  * v0.10 Began 5/26/94.  Froze 5/27/94 9am.
1366  * Changes:
1367  *  1. Modified the names of the INDEX and MASK variables.
1368  *
1369  * ZT     Total Reflectivity (dBZ)               ZT_INDEX
1370  *        May be uncommon, but important
1371  *
1372  * DZ     Reflectivity (dBZ), may contain some   DZ_INDEX
1373  *        signal-processor level QC and/or      
1374  *        filters. This field would contain 
1375  *        Darwin's CZ, or WSR88D's standard 
1376  *        reflectivity. In other words, unless
1377  *        the field is described otherwise, it
1378  *        should always go here. In essence, this
1379  *        is the "cleanest" reflectivity field
1380  *        for a radar.
1381  *
1382  * DR     Differential reflectivity              DR_INDEX
1383  *        DR and LR are for dual-polarization
1384  *        radars only. Unitless or in dB.
1385  *
1386  * LR     Another form of differential ref       LR_INDEX
1387  *        called LDR, not sure of units
1388  *
1389  * CZ     QC Reflectivity (dBZ), contains
1390  *        post-processed QC'd data               CZ_INDEX
1391  *
1392  * VR     Radial Velocity (m/s)                  VR_INDEX
1393  *
1394  * SW     Spectral Width (m2/s2)                 SW_INDEX
1395  *
1396  *  2. Fixed some MAX_RADAR_VOLUMES references in the wsr88d_to_radar code.
1397  *
1398  *-------------------------------------------------------------------------
1399  * v0.9 Began 5/25/94.  Froze: 5/26/94, 10am.
1400  * Changes:
1401  *  1. Added lassen_to_radar.c
1402  *  2. Added lassen.h
1403  *
1404  *-------------------------------------------------------------------------
1405  * v0.8 Began 5/23/94. Froze: 5/24/94, 10am.
1406  * Changes:
1407  *  1. F and INVF handle APFLAG.
1408  *  2. Image generation creates unsigned char images.
1409  *  3. 255-val for negative dBz (val < 0).
1410  *
1411  *-------------------------------------------------------------------------
1412  * v0.7 Began 4/30/94. Froze: 5/20/94.
1413  *
1414  *  Changes:
1415  *
1416  *   1. Uses char storage for data values, to reduce RAM allocation.
1417  *
1418  *   2. F(x) ((x-2)/2. - 64.)
1419  *      0 is for BADVAL. Bad value.
1420  *      1 is for RFVAL.  Range folded.
1421  *
1422  *   3. Added functions:
1423  *        Vfloat_to_char(float *x, unsigned char *c, int n);
1424  *        float F(unsigned char c);
1425  *        unsigned char INVF(float x);   -- Inverse of F.
1426  *        Radar *uf_to_radar(char *infile);
1427  *        void radar_to_uf(Radar *radar, char *outfile);
1428  *
1429  *   4. Minor bug fix in wsr88d_to_radar routine.  It was setting the
1430  *      number of volumes to six even though we were only asking for 3.
1431  *
1432  *   5. Changed the value of BADVAL to 0500 (Octal 500).  This is
1433  *      a value higher than 255 (the maximum byte value) but small enough
1434  *      to that when a scale factor (typically 100) is applied, the result
1435  *      does not exceed the I*2 (short) magnitude.  I needed this for the
1436  *      UF programs.  I could have tested for BADVAL, RFVAL, etc., and not
1437  *      applied a scale factor when loading the UF buffer, however, changing
1438  *      BADVAL and scaling everything was more general. 
1439  *
1440  *   6. Made some slight modifications to the Radar header and Volume header.
1441  *
1442  *-------------------------------------------------------------------------
1443  * v0.6 Began 4/16/94.  Froze: 4/30/94.
1444  *
1445  *  Changes:
1446  *
1447  *   1. Azimuth angles range from -180,180 to 0,360.
1448  *   2. New color index binning function for velocity.  -nyquist,nyquist
1449  *      using 15 bin values.  See Vrebin_velocity_sweep.
1450  *   3. Added the following routines:
1451  *  
1452  *       Memory management.
1453  *         Ray    *Vcopy_ray(Ray    *r);
1454  *         Sweep  *Vcopy_sweep(Sweep  *s);
1455  *         Volume *Vcopy_volume(Volume *v);
1456  *         Radar  *clear_radar(Radar *r);
1457  *   void Vget_groundr_and_h(float slant_r, float elev, float *gr, float *h);
1458  *   void Vget_slantr_and_elev(float gr, float h, float *slant_r, float *elev);
1459  *   void Vget_slantr_and_h(float gr, float elev, float *slant_r, float *h);
1460  *
1461  *       Image generation preparation.
1462  *         void Vrebin_velocity_ray   (Ray    *r);  /* Modifies r */
1463  *         void Vrebin_velocity_sweep (Sweep  *s);  /* Modifies s */
1464  *         void Vrebin_velocity_volume(Volume *v);  /* Modifies v */
1465  *
1466  *       Color table functions.
1467  *         void load_red_table(char *infile);
1468  *         void load_green_table(char *infile);
1469  *         void load_blue_table(char *infile);
1470  *
1471  *   4. Added 4/3Re calculation to Vget_slantr_and_elev and Vget_groundr...
1472  *   5. Checked for null in the Vclear routines.
1473  *
1474  *-------------------------------------------------------------------------
1475  * v0.5 Began 4/7/94
1476  *
1477  *  Changes:
1478  *
1479  *   1. Color table functions taken out of the image routines.
1480  *      You must call load_refl_table(), load_vel_table(), load_sw_table()
1481  *      to load the appropriate color table before making color images.
1482  *      There are seperate color tables for R, V, S.  See volume.h.
1483  *
1484  *   2. Range is now used in Vsweep_to_cart.
1485  *   3. Gate size (pixel resolution in km) is now used.
1486  *   4. Added range to cappi_at_h function.  It is the effective range.
1487  *   5. Added the following routines:
1488  *
1489  *       Read radar from disk.
1490  *         Ray    *read_ray   (FILE *fp);
1491  *         Sweep  *read_sweep (FILE *fp);
1492  *         Volume *read_volume(FILE *fp);
1493  *         Radar  *read_radar (char *infile);
1494  *
1495  *       Write radar to disk
1496  *         int write_ray   (Ray    *r, FILE *fp);
1497  *         int write_sweep (Sweep  *s, FILE *fp);
1498  *         int write_volume(Volume *v, FILE *fp);
1499  *         int write_radar (Radar  *r, char *outfile);
1500  *
1501  *       Area calculations
1502  *         float Varea_of_ray(Ray *r, float lo, float hi, float range);
1503  *         float Vfractional_area_of_sweep(Sweep *s, float lo, float hi, float range);
1504  *
1505  *       Pixel fractions  
1506  *         Vfraction_of_ray(Ray *r, float lo, float hi, float range);
1507  *         Vfraction_of_sweep(Sweep *s, float lo, float hi, float range);
1508  *         Vfraction_of_volume(Volume *v, float lo, float hi, float range);
1509  *
1510  *
1511  *   6. radar.c calls wsr88d_get_site to get additional wsr88d information
1512  *      not included in the file.  Routines compliments of Dan Austin.
1513  *   7. Added RFVAL.  Range Folded value.  Any base data value of 0 is
1514  *      data below SNR thresholds set for that specific base data.  Any
1515  *      data value of 1 is data considered range ambiguous (folded).
1516  *      A color table entry needs to be picked to represent this value.
1517  *
1518  *   To do:
1519  *   o I have to do something about MAX_RADAR_VOLUMES.  We really should
1520  *     rely on radar->h.nvolumes;
1521  *
1522  *   o Add 4/3Rearth calculation to get value routines.
1523  *   o Incorporate nsig_to_radar.  Dennis Flanigan is writing that interface.
1524  *   o Add fraction of area function.
1525  *   o Add the following functions:  ??? really ???
1526  *      Sweep *Vget_closest_sweep(Volume *v, float elev);
1527  *      Ray   *Vget_closest_ray(Sweep *s, float azim);
1528  *      float  Vget_closest_value_in_beam(Ray *ray, float range);
1529  *      float  Vget_closest_value(Ray *ray, float range);
1530  *        (I'm not sure how this will be different than Vget_value)
1531  *       
1532  *   o Sort the rays so locating azimuth is trivial; instead of a search
1533  *     algorithm as it is now.  Hey, would a binary search be good enough or
1534  *     do we need some hashing function?  Is the lookup fast enough already?
1535  *   o Add CAPPI at h.  (Option for bilinear interpolation about h).
1536  *-------------------------------------------------------------------------
1537  * v0.4 Began 3/23/94  Froze: 4/7/94
1538  *
1539  *  Changes:
1540  *
1541  *   1. Made Sweep (sweep) and Ray (ray) members an array of pointers.
1542  *      This changes the syntax of the access to be
1543  *      v->sweep[is]->ray[ir]->range[ibin] instead of 
1544  *      v.sweep[is].ray[ir].range[ibin].  The benifit of this is to
1545  *      be able to dynamically specify the number of sweeps or rays,
1546  *      even volumes for the Radar structure, and not allocate a maximum.
1547  *      This makes Vnew_sweep and Vnew_ray useful.
1548  *
1549  *   2. Added the following functions:
1550  *       Volume *Vget_volume(Radar *r, int itype);
1551  *              itype = REFLECTIVITY, VELOCITY, or SPECTRUM_WIDTH, etc.
1552  *     
1553  *       Sweep *Vget_sweep(Volume *v, float theta);
1554  *       Ray   *Vget_ray  (Volume *v, float theta, float azimuth);
1555  *       float Vget_value(Volume *v, float theta, float azimuth, float range);
1556  *       Ray   *Vget_ray_from_sweep(Sweep *s, float azimuth, float range);
1557  *       float Vget_value_from_sweep(Sweep *s, float azimuth, float range);
1558  *       float Vget_value_from_ray(Ray *r, float range);
1559  *       float Vget_value_at_h(Volume *v, float azim, float grnd_r, float h);
1560  *
1561  *       Ray    *QC_ray   (Ray       *ray, int radar_type);
1562  *       Sweep  *QC_sweep (Sweep   *sweep, int radar_type);
1563  *       Volume *QC_volume(Volume *volume, int radar_type);
1564  *
1565  *       Radar  *QC_radar (Radar   *radar);
1566  *
1567  *       void write_gif(char *outfile, char *image, int xdim, int ydim, char c_table[256][3]);
1568  *       void write_pict(char *outfile, char *image, int xdim, int ydim, char c_table[256][3]);
1569  *       char *Vsweep_to_cart(Sweep *s, int xdim, int ydim, float range);
1570  *       void Vsweep_to_gif(Sweep *s, char *outfile, int xdim, int ydim, float range);
1571  *       void Vsweep_to_pict(Sweep *s, char *outfile, int xdim, int ydim, float range);
1572  *       void Vvolume_to_gif(Volume *v, char *basename, int xdim, int ydim, float range);
1573  *       char *Vsweep_to_cart(
1574  *   3. When a sweep does not have any rays with any bins, then NULL is
1575  *      assigned to that Sweep pointer.  This occurs for reflectivity for
1576  *      the 2-nd sweep index (as defined by the data) where the is no
1577  *      reflectivity data, only doppler and spectrum width.  Velocity and
1578  *      spectrum width data do not exist for sweep number 1 (index 0).
1579  *
1580  *   4. Speed ups in Vto_cart_sweep.  Math is precomputed and saved in
1581  *      arrays for faster lookup.  Still the ppmtogif is a snail and it
1582  *      overwhelms the runtime.  I only saw a 35 second improvment with
1583  *      these new arrays when outputting 20 gif images.  I think the -O
1584  *      compile flag is doing a good job.
1585  *
1586  *   5. Added CAPPI at h.  Routine in cappi.c.  Cappi type is syntatically
1587  *      identical to the Sweep type.
1588  *
1589  *       Cappi *cappi_at_h(Volume *v, float h);
1590  *
1591  *   6. Make builds libradar.a which contains radar.c, volume.c, cappi.c and
1592  *      image_gen.c.  Builds on SGI, SUN and HP.
1593  *
1594  *   7. Add QC routines.  See 2. above for the list.  Currently they are
1595  *      place holding functions with only QC_ray needing to be coded.
1596  *      Paul Kucera will take care of that.
1597  *
1598  *   8. Improvments to radar.ez and volume.ez.
1599  *
1600  *  To do:
1601  *   o Add the following functions:
1602  *      Sweep *Vget_closest_sweep(Volume *v, float elev);
1603  *      Ray   *Vget_closest_ray(Sweep *s, float azim);
1604  *      float  Vget_closest_value_in_beam(Ray *ray, float range);
1605  *      float  Vget_closest_value(Ray *ray, float range);
1606  *        (I'm not sure how this will be different than Vget_value)
1607  *       
1608  *   o Add range resolution to the image generation subroutines.
1609  *   o Add range resolution to all the 'get_value' routines.
1610  *   o Sort the rays so locating azimuth is trivial; instead of a search
1611  *     algorithm as it is now.  Hey, would a binary search be good enough or
1612  *     do we need some hashing function?  It the lookup fast enough already?
1613  *   o Add CAPPI at h.  (Option for bilinear interpolation about h).
1614  *
1615  *-------------------------------------------------------------------------
1616  * v0.3 Began 3/22/94 Froze 3/23/94.
1617  *  
1618  *  Changes:
1619  *  1. Implimented the Radar structure.  The heart of it is an array of
1620  *     Volume pointers.
1621  *  2. Using 'data_mask' which is a bitwise ( | operator in C ) of
1622  *     REFL_MASK, VEL_MASK, or SW_MASK, you can get any field type volume:
1623  *     reflectivity, doppler velocity, or spectrum width respectively.
1624  *  3. Load volume, sweep and ray header information.
1625  *  4. Added Radar header information; need a good definition of say date and
1626  *     time.
1627  *
1628  *  Work to do:
1629  *   - Improve carteasean image generation.
1630  *      Input: radar range, pix_width, pix_height.  No distortion.
1631  *       - Need to specify the output GIF filename as options.
1632  *       - Incorporate Vto_fraction (?? name ??) Dave's new function.
1633  *-------------------------------------------------------------------------
1634  * v0.2 Began 3/21/94  Froze 3/22/94.
1635  *
1636  *  I am freezing this here because both BSCAN and CARTESEAN image generation
1637  *  works.  You have to hand edit the source to restrict the number of 
1638  *  Sweeps that are converted to images, currently only sweep 0.  The inclusion
1639  *  of sweep/ray header information and the collection of doppler and spectrum
1640  *  width data requires substantial effort and will be in the next version.
1641  *  This version freeze is a check point.
1642  *  
1643  *  Changes:
1644  *  1. Name rsphere change to volume.
1645  *  2. File rsphere.c changed to volume.c.  (Moved the RCS file rsphere.c,v
1646  *     to the graveyard directory in RCS/
1647  *  3. Added color gif support.  Reads red.clr, green.clr, blue.clr files.
1648  *     This renamed the Vto_cart_pgm function to Vto_cart_gif.  It is likely
1649  *     that ppm support is not needed.  We'll see.
1650  *  4. Fixes minor glitches in output images where the tan is undefined.
1651  *  5. Added BSCAN production as GIF files.
1652  *  6. Output sweep.xx file names; sweep.00.gif, etc.  and bscan.00.gif too.
1653  *
1654  *  Work to do:
1655  *    - Add routines to get volumes for doppler and spectrum width. (Radar lib?)
1656  *    - Improve carteasean image generation.
1657  *        Input: radar range, pix_width, pix_height.  No distortion.
1658  *    - Add sweep header information.
1659  *      - Need to specify the output GIF filename as options.
1660  *      - Incorporate Vto_fraction (?? name ??) Dave's new function.
1661  *
1662  *-------------------------------------------------------------------------
1663  *v0.1 3/21/94 by John Merritt.
1664  *  1. First development version of the radar and rsphere library. 
1665  *     Includes test driver.  radar.ez and rsphere.ez document the
1666  *     functionality of the programs.  This version exists to check point
1667  *     the development.
1668  *-------------------------------------------------------------------------
1669  */