]> Pileus Git - ~andy/rsl/blobdiff - volume.c
RSL v1.44
[~andy/rsl] / volume.c
index 4c17f95c4d438ac00570c4c44c5bdf37a4946403..c2072ba499eb5cebb170e405b0811d9a7d9ba7d1 100644 (file)
--- a/volume.c
+++ b/volume.c
@@ -89,16 +89,23 @@ extern int radar_verbose_flag;
  * The conversion functions may NOT be macros.
  */
 
+/* Modification to properly convert DM field (DEK 21 Nov 2012) */
+
 #ifdef USE_TWO_BYTE_PRECISION
 #define F_FACTOR 100.0
 #define F_DR_FACTOR 1000.0
 #define F_DZ_RANGE_OFFSET 50
+#define F_DM_RANGE_OFFSET 130   /* DEK */
 #else
 #define F_FACTOR 2.0
 #define F_DR_FACTOR 10.0
 #define F_DZ_RANGE_OFFSET 32
 #endif
 
+/* #define F_VR_OFFSET 63.5 */
+#define F_VR_OFFSET 127.0
+#define F_DR_OFFSET 12.0
+
 /* IMPORTANT: This is the offset from reserved values. This
  *            number must be exactly (or >=) the number of
  *            reserved values in XX_F and XX_INVF.
@@ -110,7 +117,7 @@ extern int radar_verbose_flag;
 
 float DZ_F(Range x) {
   if (x >= F_OFFSET) /* This test works when Range is unsigned. */
-       return (((float)x-F_OFFSET)/F_FACTOR - F_DZ_RANGE_OFFSET);  /* Default wsr88d. */
+    return (((float)x-F_OFFSET)/F_FACTOR - F_DZ_RANGE_OFFSET);  /* Default wsr88d. */
   if (x == 0) return BADVAL;
   if (x == 1) return RFVAL;
   if (x == 2) return APFLAG;
@@ -118,12 +125,24 @@ float DZ_F(Range x) {
   return BADVAL;  /* Can't get here, but quiets the compiler. */
 }
 
+
+float DM_F(Range x) {
+  if (x >= F_OFFSET) /* This test works when Range is unsigned. */
+        return (((float)x-F_OFFSET)/F_FACTOR - F_DM_RANGE_OFFSET);  /* DEK  */
+  if (x == 0) return BADVAL;
+  if (x == 1) return RFVAL;
+  if (x == 2) return APFLAG;
+  if (x == 3) return NOECHO;
+  return BADVAL;  /* Can't get here, but quiets the compiler. */
+}
+
+
 float VR_F(Range x) {
   float val;
   if (x >= F_OFFSET) { /* This test works when Range is unsigned. */
-       val = (((float)x-F_OFFSET)/F_FACTOR - 63.5);  /* Default wsr88d coding. */
-       /*      fprintf(stderr, "x=%d, val=%f\n", x, val); */
-       return val;
+    val = (((float)x-F_OFFSET)/F_FACTOR - F_VR_OFFSET);  /* Default wsr88d coding. */
+    /*  fprintf(stderr, "x=%d, val=%f\n", x, val); */
+    return val;
   }
   if (x == 0) return BADVAL;
   if (x == 1) return RFVAL;
@@ -135,8 +154,8 @@ float VR_F(Range x) {
 float DR_F(Range x) {    /* Differential reflectivity */
   float val;
   if (x >= F_OFFSET) { /* This test works when Range is unsigned. */
-       val = (((float)x-F_OFFSET)/F_DR_FACTOR - 12.0);
-       return val;
+    val = (((float)x-F_OFFSET)/F_DR_FACTOR - F_DR_OFFSET);
+    return val;
   }
   if (x == 0) return BADVAL;
   if (x == 1) return RFVAL;
@@ -147,7 +166,7 @@ float DR_F(Range x) {    /* Differential reflectivity */
 
 float LR_F(Range x) {/* From MCTEX */
   if (x >= F_OFFSET)  /* This test works when Range is unsigned. */
-       return (float) (x - 250.)/6.;
+    return (float) (x - 250.)/6.;
   if (x == 0) return BADVAL;
   if (x == 1) return RFVAL;
   if (x == 2) return APFLAG;
@@ -155,6 +174,11 @@ float LR_F(Range x) {/* From MCTEX */
   return BADVAL;
  }
 
+float HC_F(Range x) {  /* HydroClass (Sigmet) */
+  if (x == 0) return BADVAL;
+  return (float)x;
+}
+
 /****************************
  Sigmet RhoHV : one_byte values
 > RohHV = sqrt((N-1)/253)
@@ -167,8 +191,9 @@ float LR_F(Range x) {/* From MCTEX */
 *******************************/
 float RH_F(Range x) {
   if (x == 0) return BADVAL;
-  return (float)(sqrt((double)((x-1.0)/253.0)));
- }
+  /* return (float)(sqrt((double)((x-1.0)/253.0))); */
+  return (float)x / 100.;
+}
 
 /***************************** 
   Sigmet PhiDP : one_byte values
@@ -182,42 +207,40 @@ float RH_F(Range x) {
 ******************************/
 float PH_F(Range x) {
   if (x == 0) return BADVAL;
-  return (float)(180.0*((x-1.0)/254.0));
+  /*return (float)(180.0*((x-1.0)/254.0));*/ 
+  return x/10.;
  }
 
+/* TODO: Should this be 5. cm. instead of 0.5?  Or maybe 10. cm.? */
 float rsl_kdp_wavelen = 0.5; /* Default radar wavelen = .5 cm.  See
                               * nsig_to_radar.c for the code that sets this.
-                                                         */
+                              */
+/* KD_F for 1 or 2 byte. */
 float KD_F(Range x)
 {
-  if (x >= F_OFFSET) {
-       x -= F_OFFSET;
-       if (rsl_kdp_wavelen == 0.0) return BADVAL;
-       if (x < 128)
-         return (float)(
-                                        -0.25 * pow((double)600.0,(double)((127-x)/126.0))
-                                        )/rsl_kdp_wavelen;
-       else if (x > 128)
-         return (float)(
-                                         0.25 * pow((double)600.0,(double)((x-129)/126.0))
-                                        )/rsl_kdp_wavelen;
-       else
-         return 0.0;
-  }
   if (x == 0) return BADVAL;
-  if (x == 1) return RFVAL;
-  if (x == 2) return APFLAG;
-  if (x == 3) return NOECHO;
-  return BADVAL;
+  return x/100.;
 }
 
-float SQ_F(Range x) {
-  if (x >= F_OFFSET) return (float)((x - F_OFFSET)/10000.);
+/* Normalized Coherent Power (DORADE) */
+float NP_F(Range x)
+{
   if (x == 0) return BADVAL;
-  if (x == 1) return RFVAL;
-  if (x == 2) return APFLAG;
-  if (x == 3) return NOECHO;
-  return BADVAL;  /* Can't get here, but quiets the compiler. */
+  return (float)(x - 1) / 100.;
+}
+
+/* Standard Deviation (for Dual-pole QC testing.) */
+float SD_F(Range x)
+{
+  if (x == 0) return BADVAL;
+  return (float)x / 100.;
+}
+
+/* Signal Quality Index */
+float SQ_F(Range x)
+{
+  if (x == 0) return BADVAL;
+  return (float)(x-1) / 65533.;
 }
 
 float TI_F(Range x)
@@ -240,12 +263,17 @@ float MZ_F(Range x) {  return (float)x; } /* DZ Mask */
 float MD_F(Range x) {  return MZ_F(x); }  /* ZD Mask */
 float ZE_F(Range x) {  return DZ_F(x); }
 float VE_F(Range x) {  return VR_F(x); }
-float DM_F(Range x) {  return DZ_F(x); }
+/* float DM_F(Range x) {  return DZ_F(x); }   DEK */
 float DX_F(Range x) {  return DZ_F(x); }
 float CH_F(Range x) {  return DZ_F(x); }
 float AH_F(Range x) {  return DZ_F(x); }
 float CV_F(Range x) {  return DZ_F(x); }
 float AV_F(Range x) {  return DZ_F(x); }
+float VS_F(Range x) {  return VR_F(x); }
+float VL_F(Range x) {  return VR_F(x); }
+float VG_F(Range x) {  return VR_F(x); }
+float VT_F(Range x) {  return VR_F(x); }
+float VC_F(Range x) {  return VR_F(x); }
 
 
 
@@ -260,16 +288,28 @@ Range DZ_INVF(float x)
   if (x == RFVAL)  return (Range)1;
   if (x == APFLAG)  return (Range)2;
   if (x == NOECHO)  return (Range)3;
+  if (x < -F_DZ_RANGE_OFFSET) return (Range)0;
   return (Range)(F_FACTOR*(x+F_DZ_RANGE_OFFSET)+.5 + F_OFFSET); /* Default wsr88d. */
 }
 
+Range DM_INVF(float x)
+{
+  if (x == BADVAL) return (Range)0;
+  if (x == RFVAL)  return (Range)1;
+  if (x == APFLAG)  return (Range)2;
+  if (x == NOECHO)  return (Range)3;
+  return (Range)(F_FACTOR*(x+F_DM_RANGE_OFFSET)+.5 + F_OFFSET); /* DEK  */
+}
+
+
 Range VR_INVF(float x)
 {
   if (x == BADVAL) return (Range)0;
   if (x == RFVAL)  return (Range)1;
   if (x == APFLAG)  return (Range)2;
   if (x == NOECHO)  return (Range)3;
-  return (Range)(F_FACTOR*(x+63.5)+.5 + F_OFFSET); /* Default wsr88d coding. */
+  if (x < -F_VR_OFFSET)    return (Range)0;
+  return (Range)(F_FACTOR*(x+F_VR_OFFSET)+.5 + F_OFFSET); /* Default wsr88d coding. */
 }
 
 Range DR_INVF(float x)     /* Differential reflectivity */
@@ -278,7 +318,14 @@ Range DR_INVF(float x)     /* Differential reflectivity */
   if (x == RFVAL)  return (Range)1;
   if (x == APFLAG) return (Range)2;
   if (x == NOECHO) return (Range)3;
-  return (Range)(F_DR_FACTOR*(x + 12.0) + F_OFFSET + 0.5);
+  if (x < -F_DR_OFFSET)    return (Range)0;
+  return (Range)(F_DR_FACTOR*(x + F_DR_OFFSET) + F_OFFSET + 0.5);
+}
+
+Range HC_INVF(float x)  /* HydroClass (Sigmet) */
+{
+  if (x == BADVAL) return (Range)0;
+  return (Range)(x + 0.5); /* Round */
 }
 
 Range LR_INVF(float x) /* MCTEX */
@@ -300,9 +347,11 @@ Range LR_INVF(float x) /* MCTEX */
 > 253   0.9980
 > 254   1.0000
 ****************************/
+/* RH_INVF for 1 or 2 byte data. */
 Range RH_INVF(float x) {
   if (x == BADVAL) return (Range)0;
-  return (Range)(x * x * 253.0 + 1.0 + 0.5);
+  /* return (Range)(x * x * 253.0 + 1.0 + 0.5); */
+  return (Range)(x * 100. +.5);
 }
 
 /******************************
@@ -317,40 +366,36 @@ Range RH_INVF(float x) {
 *******************************/
 Range PH_INVF(float x) {
   if (x == BADVAL) return (Range)0;
-  return (Range)((x / 180.0) * 254.0 + 1.0 + 0.5);
+  /* return (Range)((x / 180.0) * 254.0 + 1.0 + 0.5); */
+  return (Range)(x*10.+ 0.5);
 }
 
+
+/* KD_INVF for 1 or 2 byte data. */
 Range KD_INVF(float x) {
   if (x == BADVAL) return (Range)0;
-  if (x == RFVAL)  return (Range)1;
-  if (x == APFLAG)  return (Range)2;
-  if (x == NOECHO)  return (Range)3;
-  if (rsl_kdp_wavelen == 0.0) return (Range)0;
-  if (x < 0) {
-       x = 127 - 
-         126 * (log((double)-x) - log((double)(0.25/rsl_kdp_wavelen))) /
-         log((double)600.0) +
-         0.5;
-  } else if (x > 0) {
-       x = 129 + 
-         126 * (log((double)x) - log((double)0.25/rsl_kdp_wavelen)) /
-         log((double)600.0) +
-         0.5;
-  } else {
-       x = 128;
-  }
-  x += F_OFFSET;
-  return (Range) x;
-  
+  return (Range)(x * 100. + 0.5);
 }
 
-Range SQ_INVF(float x)  /* Signal Quality Index */
+/* Standard Deviation (for Dual-pole QC testing.) */
+Range SD_INVF(float x)
 {
   if (x == BADVAL) return (Range)0;
-  if (x == RFVAL)  return (Range)1;
-  if (x == APFLAG) return (Range)2;
-  if (x == NOECHO) return (Range)3;
-  return (Range)(x * 10000. + F_OFFSET);
+  return (Range)(x * 100.);
+}
+
+/* Signal Quality Index */
+Range SQ_INVF(float x)
+{
+  if (x == BADVAL) return (Range)0;
+  return (Range)(x * 65533. + 1. +.5);
+}
+
+/* Normalized Coherent Power (DORADE) */
+Range NP_INVF(float x)
+{
+  if (x == BADVAL) return (0);
+  return (Range)(x * 100. + 1.);
 }
 
 Range TI_INVF(float x) /* MCTEX */
@@ -373,12 +418,17 @@ Range MZ_INVF(float x) {  return (Range)x;   } /* DZ Mask */
 Range MD_INVF(float x) {  return MZ_INVF(x); } /* ZD Mask */
 Range ZE_INVF(float x) {  return DZ_INVF(x); }
 Range VE_INVF(float x) {  return VR_INVF(x); }
-Range DM_INVF(float x) {  return DZ_INVF(x); }
+/* Range DM_INVF(float x) {  return DZ_INVF(x); }  DEK */
 Range DX_INVF(float x) {  return DZ_INVF(x); }
 Range CH_INVF(float x) {  return DZ_INVF(x); }
 Range AH_INVF(float x) {  return DZ_INVF(x); }
 Range CV_INVF(float x) {  return DZ_INVF(x); }
 Range AV_INVF(float x) {  return DZ_INVF(x); }
+Range VS_INVF(float x) {  return VR_INVF(x); }
+Range VL_INVF(float x) {  return VR_INVF(x); }
+Range VG_INVF(float x) {  return VR_INVF(x); }
+Range VT_INVF(float x) {  return VR_INVF(x); }
+Range VC_INVF(float x) {  return VR_INVF(x); }
 
 
 
@@ -447,9 +497,9 @@ typedef struct {
 
 #define STATIC
 STATIC int RSL_max_sweeps = 0; /* Initial allocation for sweep_list.
-                                                       * RSL_new_sweep will allocate the space first
-                                                       * time around.
-                                                       */
+                                * RSL_new_sweep will allocate the space first
+                                * time around.
+                                */
 STATIC int RSL_nsweep_addr = 0; /* A count of sweeps in the table. */
 STATIC Sweep_list *RSL_sweep_list = NULL;
 STATIC int RSL_nextents = 0;
@@ -466,7 +516,7 @@ void FREE_HASH_TABLE(Hash_table *table)
   int i;
   if (table == NULL) return;
   for (i=0; i<table->nindexes; i++)
-       FREE_HASH_NODE(table->indexes[i]); /* A possible linked list of Rays. */
+    FREE_HASH_NODE(table->indexes[i]); /* A possible linked list of Rays. */
   free(table->indexes);
   free(table);
 }
@@ -477,7 +527,7 @@ void REMOVE_SWEEP(Sweep *s)
   int j;
   /* Find where it goes, split the list and slide the tail down one. */
   for (i=0; i<RSL_nsweep_addr; i++)
-       if (s == RSL_sweep_list[i].s_addr) break;
+    if (s == RSL_sweep_list[i].s_addr) break;
 
   if (i == RSL_nsweep_addr) return; /* Not found. */
   /* This sweep is at 'i'. */ 
@@ -486,7 +536,7 @@ void REMOVE_SWEEP(Sweep *s)
 
   RSL_nsweep_addr--;
   for (j=i; j<RSL_nsweep_addr; j++)
-       RSL_sweep_list[j] = RSL_sweep_list[j+1];
+    RSL_sweep_list[j] = RSL_sweep_list[j+1];
 
   RSL_sweep_list[RSL_nsweep_addr].s_addr = NULL;
   RSL_sweep_list[RSL_nsweep_addr].hash = NULL;
@@ -499,25 +549,25 @@ int INSERT_SWEEP(Sweep *s)
   int i,j;
 
   if (RSL_nsweep_addr >= RSL_max_sweeps) { /* Current list is too small. */
-       RSL_nextents++;
-       new_list = (Sweep_list *) calloc(100*RSL_nextents, sizeof(Sweep_list));
-       if (new_list == NULL) {
-         perror("INSERT_SWEEP");
-         exit(2);
-       }
+    RSL_nextents++;
+    new_list = (Sweep_list *) calloc(100*RSL_nextents, sizeof(Sweep_list));
+    if (new_list == NULL) {
+      perror("INSERT_SWEEP");
+      exit(2);
+    }
     /* Copy the old list to the new one. */
-       for (i=0; i<RSL_max_sweeps; i++) new_list[i] = RSL_sweep_list[i];
-       RSL_max_sweeps = 100*RSL_nextents;
-       free(RSL_sweep_list);
-       RSL_sweep_list = new_list;
+    for (i=0; i<RSL_max_sweeps; i++) new_list[i] = RSL_sweep_list[i];
+    RSL_max_sweeps = 100*RSL_nextents;
+    free(RSL_sweep_list);
+    RSL_sweep_list = new_list;
   }
   /* Find where it goes, split the list and slide the tail down one. */
   for (i=0; i<RSL_nsweep_addr; i++)
-       if (s < RSL_sweep_list[i].s_addr) break;
-       
+    if (s < RSL_sweep_list[i].s_addr) break;
+    
   /* This sweep goes at 'i'. But first we must split the list. */
   for (j=RSL_nsweep_addr; j>i; j--)
-       RSL_sweep_list[j] = RSL_sweep_list[j-1];
+    RSL_sweep_list[j] = RSL_sweep_list[j-1];
 
   RSL_sweep_list[i].s_addr = s;
   RSL_sweep_list[i].hash = NULL;
@@ -531,7 +581,7 @@ int SWEEP_INDEX(Sweep *s)
   /* Simple linear search; but this will be a binary search. */
   int i;
   for (i=0; i<RSL_nsweep_addr; i++)
-       if (s == RSL_sweep_list[i].s_addr) return i;
+    if (s == RSL_sweep_list[i].s_addr) return i;
   return -1;
 }
 
@@ -547,6 +597,8 @@ Sweep *RSL_new_sweep(int max_rays)
   s->ray = (Ray **) calloc(max_rays, sizeof(Ray*));
   if (s->ray == NULL) perror("RSL_new_sweep, Ray*");
   s->h.nrays = max_rays; /* A default setting. */
+  s->h.elev = -999.;
+  s->h.azimuth = -999.;
   return s;
 }
 
@@ -583,7 +635,7 @@ Sweep *RSL_clear_sweep(Sweep *s)
   int i;
   if (s == NULL) return s;
   for (i=0; i<s->h.nrays; i++) {
-       RSL_clear_ray(s->ray[i]);
+    RSL_clear_ray(s->ray[i]);
   }
   return s;
 }
@@ -592,7 +644,7 @@ Volume *RSL_clear_volume(Volume *v)
   int i;
   if (v == NULL) return v;
   for (i=0; i<v->h.nsweeps; i++) {
-       RSL_clear_sweep(v->sweep[i]);
+    RSL_clear_sweep(v->sweep[i]);
   }
   return v;
 }
@@ -614,7 +666,7 @@ void RSL_free_sweep(Sweep *s)
   int i;
   if (s == NULL) return;
   for (i=0; i<s->h.nrays; i++) {
-       RSL_free_ray(s->ray[i]);
+    RSL_free_ray(s->ray[i]);
   }
   if (s->ray) free(s->ray);
   REMOVE_SWEEP(s); /* Remove from internal Sweep list. */
@@ -626,9 +678,9 @@ void RSL_free_volume(Volume *v)
   if (v == NULL) return;
 
   for (i=0; i<v->h.nsweeps; i++)
-        {
-        RSL_free_sweep(v->sweep[i]);
-        }
+     {
+     RSL_free_sweep(v->sweep[i]);
+     }
   if (v->sweep) free(v->sweep);
   free(v);
 }
@@ -661,7 +713,7 @@ Sweep *RSL_copy_sweep(Sweep *s)
   n_sweep->h = s->h;
 
   for (i=0; i<s->h.nrays; i++) {
-       n_sweep->ray[i] = RSL_copy_ray(s->ray[i]);
+    n_sweep->ray[i] = RSL_copy_ray(s->ray[i]);
   }
   return n_sweep;
 }
@@ -678,7 +730,7 @@ Volume *RSL_copy_volume(Volume *v)
   new_vol->h = v->h;
 
   for (i=0; i<v->h.nsweeps; i++) {
-       new_vol->sweep[i] = RSL_copy_sweep(v->sweep[i]);
+    new_vol->sweep[i] = RSL_copy_sweep(v->sweep[i]);
   }
   return new_vol;
 }
@@ -767,9 +819,9 @@ Ray *RSL_get_next_ccwise_ray(Sweep *s, Ray *ray)
 double cwise_angle_diff(float x,float y)
    {
    /* Returns the clockwise angle difference of x to y.
-       * If x = 345 and y = 355 return 10.  
-       * If x = 345 and y = 335 return 350
-       */
+    * If x = 345 and y = 355 return 10.  
+    * If x = 345 and y = 335 return 350
+    */
    double d;
    
    d = (double)(y - x);
@@ -786,9 +838,9 @@ double cwise_angle_diff(float x,float y)
 double ccwise_angle_diff(float x,float y)
    {
    /* Returns the counterclockwise angle differnce of x to y.
-       * If x = 345 and y = 355 return 350.  
-       * If x = 345 and y = 335 return 10
-       */
+    * If x = 345 and y = 355 return 350.  
+    * If x = 345 and y = 335 return 10
+    */
    double d;
    
    d = (double)(x - y);
@@ -812,48 +864,48 @@ Azimuth_hash *the_closest_hash(Azimuth_hash *hash, float ray_angle)
    if (hash == NULL) return NULL;
 
    /* Set low pointer to hash index with ray angle just below
-       * requested angle and high pointer to just above requested
-       * angle.
-       */
+    * requested angle and high pointer to just above requested
+    * angle.
+    */
 
    /* set low and high pointers to initial search locations*/
    low = hash;         
    high = hash->ray_high;
    
    /* Search until clockwise angle to high is less then clockwise
-       * angle to low.
-       */
+    * angle to low.
+    */
 
    clow   = cwise_angle_diff(ray_angle,low->ray->h.azimuth);
    chigh  = cwise_angle_diff(ray_angle,high->ray->h.azimuth);
    cclow  = ccwise_angle_diff(ray_angle,low->ray->h.azimuth);
 
    while((chigh > clow) && (clow != 0))
-         {
-         if (clow < cclow)
-                {
-                low  = low->ray_low;
-                high = low->ray_high;  /* Not the same low as line before ! */
-                }
-         else
-                {
-                low  = low->ray_high;
-                high = low->ray_high;  /* Not the same low as line before ! */
-                }
-
-         clow   = cwise_angle_diff(ray_angle,low->ray->h.azimuth);
-         chigh  = cwise_angle_diff(ray_angle,high->ray->h.azimuth);
-         cclow  = ccwise_angle_diff(ray_angle,low->ray->h.azimuth);
-         }
+      {
+      if (clow < cclow)
+         {
+         low  = low->ray_low;
+         high = low->ray_high;  /* Not the same low as line before ! */
+         }
+      else
+         {
+         low  = low->ray_high;
+         high = low->ray_high;  /* Not the same low as line before ! */
+         }
+
+      clow   = cwise_angle_diff(ray_angle,low->ray->h.azimuth);
+      chigh  = cwise_angle_diff(ray_angle,high->ray->h.azimuth);
+      cclow  = ccwise_angle_diff(ray_angle,low->ray->h.azimuth);
+      }
 
    if(chigh <= cclow)
-         {
-         return high;
-         }
+      {
+      return high;
+      }
    else
-         {
-         return low;
-         }
+      {
+      return low;
+      }
    }
 
 
@@ -975,8 +1027,8 @@ int hash_bin(Hash_table *table,float angle)
    * why bother?
    */
   while(table->indexes[hash] == NULL) {
-       hash++;
-       if(hash >= table->nindexes) hash = 0;
+    hash++;
+    if(hash >= table->nindexes) hash = 0;
   }
   
   return hash;
@@ -988,13 +1040,13 @@ Hash_table *hash_table_for_sweep(Sweep *s)
 
   i = SWEEP_INDEX(s);
   if (i==-1) { /* Obviously, an unregistered sweep.  Most likely the
-                               * result of pointer assignments.
-                               */
-       i = INSERT_SWEEP(s);
+                * result of pointer assignments.
+                */
+    i = INSERT_SWEEP(s);
   }
 
   if (RSL_sweep_list[i].hash == NULL) { /* First time.  Construct the table. */
-       RSL_sweep_list[i].hash = construct_sweep_hash_table(s);
+    RSL_sweep_list[i].hash = construct_sweep_hash_table(s);
   }
 
   return RSL_sweep_list[i].hash;
@@ -1011,7 +1063,7 @@ Ray *RSL_get_closest_ray_from_sweep(Sweep *s,float ray_angle, float limit)
    /*
     * Return closest Ray in Sweep within limit (angle) specified
     * in parameter list.  Assume PPI mode.
-       */
+    */
    int hindex;
    Hash_table *hash_table;
    Azimuth_hash *closest;
@@ -1028,8 +1080,8 @@ Ray *RSL_get_closest_ray_from_sweep(Sweep *s,float ray_angle, float limit)
    closest = the_closest_hash(hash_table->indexes[hindex],ray_angle);
    
    /* Is closest ray within limit parameter ? If
-       * so return ray, else return NULL.
-       */
+    * so return ray, else return NULL.
+    */
 
    close_diff = angle_diff(ray_angle,closest->ray->h.azimuth);
    
@@ -1084,13 +1136,13 @@ float RSL_get_value_from_ray(Ray *ray, float r)
    if (ray == NULL) return BADVAL;
 
    if(ray->h.gate_size == 0)
-         {
-         if(radar_verbose_flag)
-                {
-                fprintf(stderr,"RSL_get_value_from_ray: ray->h.gate_size == 0\n");
-                }
-         return BADVAL;
-         }
+      {
+      if(radar_verbose_flag)
+         {
+         fprintf(stderr,"RSL_get_value_from_ray: ray->h.gate_size == 0\n");
+         }
+      return BADVAL;
+      }
    
    /* range_bin1 is range to center of first bin */
    bin_index = (int)(((rm - ray->h.range_bin1)/ray->h.gate_size) + 0.5);
@@ -1204,10 +1256,10 @@ Ray *RSL_get_ray_above(Volume *v, Ray *current_ray)
 
    i++;
    while( i < v->h.nsweeps)
-         {
-         if(v->sweep[i] != NULL) break;
-         i++;
-         }
+      {
+      if(v->sweep[i] != NULL) break;
+      i++;
+      }
 
    if(i >= v->h.nsweeps) return NULL;
 
@@ -1233,10 +1285,10 @@ Ray *RSL_get_ray_below(Volume *v, Ray *current_ray)
 
    i--;
    while( i >= 0)
-         {
-         if(v->sweep[i] != NULL) break;
-         i--;
-         }
+      {
+      if(v->sweep[i] != NULL) break;
+      i--;
+      }
 
    if(i < 0) return NULL;
 
@@ -1282,13 +1334,13 @@ Ray *RSL_get_first_ray_of_sweep(Sweep *s)
   smallest_ray_num = 9999999;
   if (s == NULL) return r;
   for (i=0; i<s->h.nrays; i++)
-       if (s->ray[i]) {
-         if (s->ray[i]->h.ray_num <= 1) return s->ray[i];
-         if (s->ray[i]->h.ray_num < smallest_ray_num) {
-               r = s->ray[i];
-               smallest_ray_num = r->h.ray_num;
-         }
-       }
+    if (s->ray[i]) {
+      if (s->ray[i]->h.ray_num <= 1) return s->ray[i];
+      if (s->ray[i]->h.ray_num < smallest_ray_num) {
+        r = s->ray[i];
+        smallest_ray_num = r->h.ray_num;
+      }
+    }
   return r;
 }
 
@@ -1311,7 +1363,7 @@ Sweep *RSL_get_first_sweep_of_volume(Volume *v)
   int i;
   if (v == NULL) return NULL;
   for (i=0; i<v->h.nsweeps; i++)
-       if (RSL_get_first_ray_of_sweep(v->sweep[i])) return v->sweep[i];
+    if (RSL_get_first_ray_of_sweep(v->sweep[i])) return v->sweep[i];
   return NULL;
 }
 
@@ -1332,7 +1384,11 @@ int rsl_qfield[MAX_RADAR_VOLUMES] = {
   1, 1, 1, 1, 1,
   1, 1, 1, 1, 1,
   1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1
+  1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1,
+  1, 1, 1, 1
  };
 
 
@@ -1386,26 +1442,26 @@ void RSL_select_fields(char *field_type, ...)
 
   if (radar_verbose_flag) fprintf(stderr,"Selected fields for ingest:");
   while (c_field) {
-       /* CHECK EACH FIELD. This is a fancier case statement than C provides. */
-       if (radar_verbose_flag) fprintf(stderr," %s", c_field);
-       if (strcasecmp(c_field, "all") == 0) {
-         for (i=0; i<MAX_RADAR_VOLUMES; i++) rsl_qfield[i] = 1;
-       } else if (strcasecmp(c_field, "none") == 0) {
-         for (i=0; i<MAX_RADAR_VOLUMES; i++) rsl_qfield[i] = 0;
-       } else {
-       
-         for (i=0; i<MAX_RADAR_VOLUMES; i++)
-               if (strcasecmp(c_field, RSL_ftype[i]) == 0) {
-                 rsl_qfield[i] = 1;
-                 break; /* Break the for loop. */
-               }
-         
-         if (i == MAX_RADAR_VOLUMES) {
-               if (radar_verbose_flag)
-                 fprintf(stderr, "\nRSL_select_fields: Invalid field name <<%s>> specified.\n", c_field);
-         }
-       }
-       c_field = va_arg(ap, char *);
+    /* CHECK EACH FIELD. This is a fancier case statement than C provides. */
+    if (radar_verbose_flag) fprintf(stderr," %s", c_field);
+    if (strcasecmp(c_field, "all") == 0) {
+      for (i=0; i<MAX_RADAR_VOLUMES; i++) rsl_qfield[i] = 1;
+    } else if (strcasecmp(c_field, "none") == 0) {
+      for (i=0; i<MAX_RADAR_VOLUMES; i++) rsl_qfield[i] = 0;
+    } else {
+    
+      for (i=0; i<MAX_RADAR_VOLUMES; i++)
+        if (strcasecmp(c_field, RSL_ftype[i]) == 0) {
+          rsl_qfield[i] = 1;
+          break; /* Break the for loop. */
+        }
+      
+      if (i == MAX_RADAR_VOLUMES) {
+        if (radar_verbose_flag)
+          fprintf(stderr, "\nRSL_select_fields: Invalid field name <<%s>> specified.\n", c_field);
+      }
+    }
+    c_field = va_arg(ap, char *);
   }
 
   if (radar_verbose_flag) fprintf(stderr,"\n");
@@ -1445,15 +1501,15 @@ int rsl_query_field(char *c_field)
   RSL_invf_list[0] = RSL_invf_list[0];
 
   for (i=0; i<MAX_RADAR_VOLUMES; i++)
-       if (strcasecmp(c_field, RSL_ftype[i]) == 0) {
-         rsl_qfield[i] = 1;
-         break; /* Break the for loop. */
-       }
+    if (strcasecmp(c_field, RSL_ftype[i]) == 0) {
+      rsl_qfield[i] = 1;
+      break; /* Break the for loop. */
+    }
   
   if (i == MAX_RADAR_VOLUMES) { /* We should never see this message for
-                                                                * properly written ingest code.
-                                                                */
-       fprintf(stderr, "rsl_query_field: Invalid field name <<%s>> specified.\n", c_field);
+                                 * properly written ingest code.
+                                 */
+    fprintf(stderr, "rsl_query_field: Invalid field name <<%s>> specified.\n", c_field);
   }
   
   /* 'i' is the index. Is it set? */
@@ -1463,8 +1519,8 @@ int rsl_query_field(char *c_field)
 
 /* Could be static and force use of 'rsl_query_sweep' */
 int *rsl_qsweep = NULL;  /* If NULL, then read all sweeps. Otherwise,
-                                                 * read what is on the list.
-                                                 */
+                          * read what is on the list.
+                          */
 #define RSL_MAX_QSWEEP 500 /* It'll be rediculious to have more. :-) */
 int rsl_qsweep_max = RSL_MAX_QSWEEP;
 
@@ -1503,35 +1559,35 @@ void RSL_read_these_sweeps(char *csweep, ...)
 
 
   if (radar_verbose_flag) fprintf(stderr,"Selected sweeps for ingest:");
-  for (;c_sweep;       c_sweep = va_arg(ap, char *))
-       {
-       /* CHECK EACH FIELD. This is a fancier case statement than C provides. */
-       if (radar_verbose_flag) fprintf(stderr," %s", c_sweep);
-       if (strcasecmp(c_sweep, "all") == 0) {
-         for (i=0; i<RSL_MAX_QSWEEP; i++) rsl_qsweep[i] = 1;
-         rsl_qsweep_max = RSL_MAX_QSWEEP;
-       } else if (strcasecmp(c_sweep, "none") == 0) {
-        /* Commented this out to save runtime -GJW
-         * rsl_qsweep[] already initialized to 0 above.
-         *
-         * for (i=0; i<RSL_MAX_QSWEEP; i++) rsl_qsweep[i] = 0;
-         * rsl_qsweep_max = -1;
-         */
-       } else {
-         i = sscanf(c_sweep,"%d", &isweep);
-         if (i == 0) { /* No match, bad argument. */
-               if (radar_verbose_flag) fprintf(stderr,"\nRSL_read_these_sweeps: bad parameter %s.  Ignoring.\n", c_sweep);
-               continue;
-         }
-
-         if (isweep < 0 || isweep > RSL_MAX_QSWEEP) {
-               if (radar_verbose_flag) fprintf(stderr,"\nRSL_read_these_sweeps: parameter %s not in [0,%d).  Ignoring.\n", c_sweep, RSL_MAX_QSWEEP);
-               continue;
-         }
-
-         if (isweep > rsl_qsweep_max) rsl_qsweep_max = isweep;
-         rsl_qsweep[isweep] = 1;
-       }
+  for (;c_sweep;    c_sweep = va_arg(ap, char *))
+    {
+    /* CHECK EACH FIELD. This is a fancier case statement than C provides. */
+    if (radar_verbose_flag) fprintf(stderr," %s", c_sweep);
+    if (strcasecmp(c_sweep, "all") == 0) {
+      for (i=0; i<RSL_MAX_QSWEEP; i++) rsl_qsweep[i] = 1;
+      rsl_qsweep_max = RSL_MAX_QSWEEP;
+    } else if (strcasecmp(c_sweep, "none") == 0) {
+     /* Commented this out to save runtime -GJW
+      * rsl_qsweep[] already initialized to 0 above.
+      *
+      * for (i=0; i<RSL_MAX_QSWEEP; i++) rsl_qsweep[i] = 0;
+      * rsl_qsweep_max = -1;
+      */
+    } else {
+      i = sscanf(c_sweep,"%d", &isweep);
+      if (i == 0) { /* No match, bad argument. */
+        if (radar_verbose_flag) fprintf(stderr,"\nRSL_read_these_sweeps: bad parameter %s.  Ignoring.\n", c_sweep);
+        continue;
+      }
+
+      if (isweep < 0 || isweep > RSL_MAX_QSWEEP) {
+        if (radar_verbose_flag) fprintf(stderr,"\nRSL_read_these_sweeps: parameter %s not in [0,%d).  Ignoring.\n", c_sweep, RSL_MAX_QSWEEP);
+        continue;
+      }
+
+      if (isweep > rsl_qsweep_max) rsl_qsweep_max = isweep;
+      rsl_qsweep[isweep] = 1;
+    }
   }
 
   if (radar_verbose_flag) fprintf(stderr,"\n");
@@ -1587,9 +1643,9 @@ void RSL_add_dbz_offset_to_ray(Ray *r, float dbz_offset)
   if (r == NULL) return;
   for (ibin=0; ibin<r->h.nbins; ibin++)
   {
-       val = r->h.f(r->range[ibin]);
-       if ( val >= (float)NOECHO ) continue;  /* Invalid value */
-       r->range[ibin] = r->h.invf(val + dbz_offset);
+    val = r->h.f(r->range[ibin]);
+    if ( val >= (float)NOECHO ) continue;  /* Invalid value */
+    r->range[ibin] = r->h.invf(val + dbz_offset);
   }
 }
 
@@ -1603,7 +1659,7 @@ void RSL_add_dbz_offset_to_sweep(Sweep *s, float dbz_offset)
   int iray;
   if (s == NULL) return;
   for (iray=0; iray<s->h.nrays; iray++)
-       RSL_add_dbz_offset_to_ray(s->ray[iray], dbz_offset);
+    RSL_add_dbz_offset_to_ray(s->ray[iray], dbz_offset);
 }
 
 /*********************************************************************/
@@ -1616,5 +1672,5 @@ void RSL_add_dbz_offset_to_volume(Volume *v, float dbz_offset)
   int isweep;
   if (v == NULL) return;
   for (isweep=0; isweep<v->h.nsweeps; isweep++)
-       RSL_add_dbz_offset_to_sweep(v->sweep[isweep], dbz_offset);
+    RSL_add_dbz_offset_to_sweep(v->sweep[isweep], dbz_offset);
 }