Exemplo n.º 1
0
int call_list(char *name)
{
   int      c = 0;
   Coord_list list = NULL;

   /* get the list by name */
   while (c < num_lists && list == NULL){
      if(strcmp(coord_lists[c]->name, name) == 0){
         list = coord_lists[c];
         }
      c++;
      }

   if(list == NULL){
      fprintf(stderr, "Couldn't find list called '%s'\n\n", name);
      return 0;
      }

   /* copy the co-ords into the main (0) list */
   for(c = 0; c < list->n_pts; c++){
      add_coord_to_list(0, list->pts[c].coord[0],
                        list->pts[c].coord[1], list->pts[c].coord[2]);
      }

   return 1;
   }
void Add_bin_to_RR_Polar_Grid (Compact_dp_basedata_elev* inbuf,
                               int azm,     int rng,
                               int*         num_bins_filled,
                               float        elev_angle_deg,
                               char         Beam_Blockage[BLOCK_RAD][MX_RNG],
                               Rate_Buf_t*  rate_out,
                               HHC_Buf_t*   hhc_out,
                               float    exzone[MAX_NUM_ZONES][EXZONE_FIELDS],
                               unsigned short* max_no_of_gates,
                               struct listitem_t* *hybrid_list,
                               short         beam_edge_top[MAX_AZM],
                               float*        RateZ_table)
{
   int       blockage_azm, blockage_rng;
   int       blocked_percent;
   short     hc_type;
   float     azm_angle;
   Moments_t bin_moments;          /* the moments for this [azm][rng] */
   float     IRRate = QPE_NODATA;

   #ifdef QPERATE_DEBUG
      fprintf ( stderr, "Beginning Add_bin_to_RR_Polar_Grid() ...........\n" );
   #endif

   /* Checking if radial is not good, add coordinates to list then
    * skip this sample bin. */

   azm_angle = (float) inbuf->radial[azm].bdh.azimuth;

   if((inbuf->radial_is_good[azm] == FALSE) ||
      (azm_angle < 0.)                      ||
      (azm_angle > 360.))
   {
      #ifdef QPERATE_DEBUG
         fprintf(stderr,"Missing radial - ( %d, %d ) = %d\n",azm, rng,
                         inbuf->radial_is_good[azm]);
      #endif

      add_coord_to_list(hybrid_list, azm, rng);

      return;
   }

   /* The blockage azimuth angle (azm_angle) is in tenths of a degree.
    * The Blockage Algorithm computes beam blockage for every 1 km
    * range bin and for every 0.1 deg.
    *
    * NOTE: blockage_azm is deliberately rounded to the nearest integer
    * to ensure that the range of values falls within the array
    * limits of 0 to 3599. */

   blockage_azm = (int) RPGC_NINT (azm_angle * 10.0);

   /* Make sure array index not over boundary */

   if(blockage_azm > 3599)
      blockage_azm = 3599;

   /* Convert range bin index from 250m to 1km */

   blockage_rng = (int) (rng / 4);

   #ifdef QPERATE_DEBUG
      fprintf(stderr,
             "AZMRNG(%d, %d) azm_angle: %6.2f; %s %d; blockage_rng: %d\n",
              azm, rng/4, azm_angle,
              "blockage_azm:",
              blockage_azm, blockage_rng);
   #endif

   /* Obtain the beam blockage value for each bin, convert from char to int.
    * NOTE: blocked_percent is a percentage (i.e 4%). */

   blocked_percent = (int) Beam_Blockage[blockage_azm][blockage_rng];

   /* Fetch the bin_moments */

   read_Moments(inbuf, azm, rng, &bin_moments, max_no_of_gates);

   hc_type = bin_moments.HydroClass;

   /* (AEL 1.1.2.4) If the hydrometeor is:
    *
    * Ground Clutter or Unknown, or
    *
    * if the blocked percentage is too high, or
    *
    * if it's in an exclusion zone,
    *
    * we need to go to a higher elevation and try again.
    *
    * 20080317 Based on a conversation with Brian Klein,
    *          we check RhoHV inside compute_IRRate().
    *
    * 20080609 You can get the default hydroclass of QPE_NODATA
    *          when the rng (919) > number of gates (592).
    *
    * Default Kdp_max_beam_blk: 70% */

   if((hc_type != GC)                                                   &&
      (hc_type != UK)                                                   &&
      (hc_type != QPE_NODATA)                                           &&
      (blocked_percent < rate_out->qpe_adapt.dp_adapt.Kdp_max_beam_blk) &&
      (is_Excluded (azm_angle, slant_rng_m[rng], elev_angle_deg,
         rate_out, exzone) == FALSE))
   {
      /* Compute instantaneous rainfall rate */

      IRRate = compute_IRRate(azm, rng, blocked_percent,
                              rate_out, &bin_moments,
                              beam_edge_top, RateZ_table);

      /* Due to a flaw in the R(KDP) algorithm, it is possible to compute
       * negative rainfall rates. This condition will catch that error.
       * Also, if something goes wrong with the other R() computations,
       * such as a too high or low Z, then compute_IRRate () function
       * will return QPE_NODATA, indicating to try at a higher elevation. */

      if((IRRate < 0.0) || (IRRate == QPE_NODATA)) /* no rate calculated */
      {
         add_coord_to_list(hybrid_list, azm, rng);
      }
      else /* a rate was calculated, AEL 3.1.2.5 */
      {
         /* Is IRRate enough to include in the rain area calculation?
          * Precip. could be 0.0 depending on the hydroclass - we don't
          * want to trigger precip. detection from tiny or 0 rates.
          *
          * The minimum a rain gauge can detect is 0.01 in.
          *
          * The default hydromet_prep.alg rain_dbz_thresh = 20.0 dBZ,
          * which under the standard R(Z) = 0.456 mm/hr.
          *
          * Default Paif_rate: 0.5 mm/hr */

         if(IRRate > rate_out->qpe_adapt.dp_adapt.Paif_rate)
         {
            /* Increment area sum, AEL 3.1.3 */

            rate_out->rate_supl.sum_area += get_BinArea(rng);
         }

         /* Check to see if the rate > a maximum rate. AEL 3.1.2.5 */

         if(IRRate > rate_out->qpe_adapt.dp_adapt.Max_precip_rate)
         {
            IRRate = rate_out->qpe_adapt.dp_adapt.Max_precip_rate;
         }

         /* Save the rate (in) and hydroclass in their output buffers */

         rate_out->RateComb[azm][rng] = IRRate * MM_TO_IN;

         hhc_out->HybridHCA[azm][rng] = hc_type;

         ++(*num_bins_filled);

      } /* end a rate was calculated */

   } /* end if the bin can calculate a rate */
   else /* we CANNOT use this sample bin, add it into list. AEL 3.1.2.3 */
   {
      add_coord_to_list(hybrid_list, azm, rng);
   } /* end else the bin can't calculate a rate */

   #ifdef QPERATE_DEBUG
      fprintf (stderr , "Exit Add_bin_to_RR_Polar_Grid() ..........\n");
   #endif

} /* end Add_bin_to_RR_Polar_Grid() ========================= */