Exemplo n.º 1
0
/*****************************************************************************
 * GRIB2InventoryPrint() -- Review 12/2002
 *
 * Arthur Taylor / MDL
 *
 * PURPOSE
 *   Prints to standard out, an inventory of the file, assuming one has an
 * array of inventories of single GRIB messages.
 *
 * ARGUMENTS
 *    Inv = Pointer to an Array of inventories to print. (Input)
 * LenInv = Length of the Array Inv (Input)
 *
 * FILES/DATABASES: None
 *
 * RETURNS: void
 *
 * HISTORY
 *   9/2002 Arthur Taylor (MDL/RSIS): Created.
 *  12/2002 (TK,AC,TB,&MS): Code Review.
 *   1/2004 AAT: Added short form of First level to print out.
 *   3/2004 AAT: Switched from "#, Byte, ..." to "MsgNum, Byte, ..."
 *
 * NOTES
 *****************************************************************************
 */
void GRIB2InventoryPrint (inventoryType *Inv, uInt4 LenInv)
{
   uInt4 i;             /* Counter of which inventory we are printing. */
   double delta;        /* Difference between valid and reference time. */
   char refTime[25];    /* Used to store the formatted reference time. */
   char validTime[25];  /* Used to store the formatted valid time. */

   printf ("MsgNum, Byte, GRIB-Version, elem, level, reference(UTC),"
           " valid(UTC), Proj(hr)\n");
   fflush (stdout);
   for (i = 0; i < LenInv; i++) {
/*      strftime (refTime, 25, "%m/%d/%Y %H:%M", gmtime (&(Inv[i].refTime)));*/
      Clock_Print (refTime, 25, Inv[i].refTime, "%m/%d/%Y %H:%M", 0);
/*      strftime (validTime, 25, "%m/%d/%Y %H:%M",
                gmtime (&(Inv[i].validTime)));*/
      Clock_Print (validTime, 25, Inv[i].validTime, "%m/%d/%Y %H:%M", 0);
      delta = (Inv[i].validTime - Inv[i].refTime) / 3600.;
      delta = myRound (delta, 2);
      if (Inv[i].comment == NULL) {
         printf ("%d.%d, %d, %d, %s, %s, %s, %s, %.2f\n",
                 Inv[i].msgNum, Inv[i].subgNum, Inv[i].start,
                 Inv[i].GribVersion, Inv[i].element, Inv[i].shortFstLevel,
                 refTime, validTime, delta);
         fflush (stdout);
      } else {
         printf ("%d.%d, %d, %d, %s=\"%s\", %s, %s, %s, %.2f\n",
                 Inv[i].msgNum, Inv[i].subgNum, Inv[i].start,
                 Inv[i].GribVersion, Inv[i].element, Inv[i].comment,
                 Inv[i].shortFstLevel, refTime, validTime, delta);
         fflush (stdout);
      }
   }
}
Exemplo n.º 2
0
void genConvSevereCompValues(size_t pnt, char *layoutKey, uChar parameterName, 
                             genMatchType *match, char *severeCompType, 
                             char *severeCompName, xmlNodePtr parameters, 
                             numRowsInfo numRows, int startNum, int endNum)
{
   int i;                             /* Index through match structure. */
   int roundedProbData;               /* Returned rounded probability data. */
   xmlNodePtr convective_hazard = NULL; /* Xml Node Pointer for 
                                         * <convective-hazard> element. */
   xmlNodePtr severe_component = NULL; /* Xml Node Pointer for 
                                        * <severe-component> element. */
   xmlNodePtr value = NULL;           /* Xml Node Pointer for <value> element. */
   char strBuff[30];                  /* Temporary string buffer holding rounded
                                       * data. */

   /* Format the <convective-hazard> element. */
   convective_hazard = xmlNewChild(parameters, NULL, BAD_CAST 
                                   "convective-hazard", NULL);

  /* Format the <severe-component> element. */
   severe_component = xmlNewChild(convective_hazard, NULL, BAD_CAST 
                                  "severe-component", NULL);
   xmlNewProp(severe_component, BAD_CAST "type", BAD_CAST severeCompType);
   xmlNewProp(severe_component, BAD_CAST "units", BAD_CAST "percent");
   xmlNewProp(severe_component, BAD_CAST "time-layout", BAD_CAST layoutKey);

   /* Format the display <name> element. */
   xmlNewChild(severe_component, NULL, BAD_CAST "name", BAD_CAST
               severeCompName);

   /* Loop over all the data values and format them. */
   for (i = startNum; i < endNum; i++)
   {
      if (match[i].elem.ndfdEnum == parameterName && 
	  match[i].validTime >= numRows.firstUserTime &&
          match[i].validTime <= numRows.lastUserTime)
      {
         /* If the data is missing, so indicate in the XML (nil=true). */
         if (match[i].value[pnt].valueType == 2)
         {
            value = xmlNewChild(severe_component, NULL, BAD_CAST "value", 
                    NULL);
            xmlNewProp(value, BAD_CAST "xsi:nil", BAD_CAST "true");
         }
         else if (match[i].value[pnt].valueType == 0) /* Format good data. */
         {
            roundedProbData = (int)myRound(match[i].value[pnt].data, 0);
            sprintf(strBuff, "%d", roundedProbData);
            xmlNewChild(severe_component, NULL, BAD_CAST "value", BAD_CAST 
                        strBuff);
         }
      }
   }
   return;
}
Exemplo n.º 3
0
void genMinRHValues(size_t pnt, char *layoutKey, genMatchType * match,
                    xmlNodePtr parameters, numRowsInfo numRows,
                    int startNum, int endNum)
{
   int i;                     /* Element counter thru match structure. */
   int roundedMinRHData;      /* Returned rounded data. */
   xmlNodePtr humidity = NULL; /* Xml Node Pointer for <humidity>
                                  element. */
   xmlNodePtr value = NULL;   /* Xml Node Pointer for <value> element. */
   char strBuff[30];          /* Temporary string buffer holding rounded
                               * data. */

   /* Format the <humidity> element. */
   humidity = xmlNewChild(parameters, NULL, BAD_CAST "humidity", NULL);
   xmlNewProp(humidity, BAD_CAST "type", BAD_CAST "minimum relative");

   xmlNewProp(humidity, BAD_CAST "units", BAD_CAST "percent");

   xmlNewProp(humidity, BAD_CAST "time-layout", BAD_CAST layoutKey);

   /* Format the display <name> element. */
   xmlNewChild(humidity, NULL, BAD_CAST "name", BAD_CAST
               "Daily Minimum Relative Humidity");

   /* Loop over all the data values and format them. */
   for (i = startNum; i < endNum; i++)
   {
      if (match[i].elem.ndfdEnum == NDFD_MINRH && 
	  match[i].validTime >= numRows.firstUserTime &&
          match[i].validTime <= numRows.lastUserTime)
      {

         /* If the data is missing, so indicate in the XML (nil=true).
          * Also, put some common sense checks on the data.
          */
         if (match[i].value[pnt].valueType == 2 ||
             match[i].value[pnt].data >= 101 ||
             match[i].value[pnt].data < -1 ||
             match[i].value[pnt].data == '\0')
         {
            value = xmlNewChild(humidity, NULL, BAD_CAST "value", NULL);
            xmlNewProp(value, BAD_CAST "xsi:nil", BAD_CAST "true");
         }
         else if (match[i].value[pnt].valueType == 0) /* Format good data. */
         {
            roundedMinRHData = (int)myRound(match[i].value[pnt].data, 0);
            sprintf(strBuff, "%d", roundedMinRHData);
            xmlNewChild(humidity, NULL, BAD_CAST "value", BAD_CAST strBuff);
         }
      }
   }
   return;
}
Exemplo n.º 4
0
void pulse() {
	const signed char bitesize = 30;
	for (unsigned char i=0; i<NUMCH; i++) {
		float rnd = myRand();
		speed[i] += 20*(rnd - .5);	
		if (rnd < 0.01) {
			speed[i] *= 1.1;
		} else { 
			speed[i] = speed[i] * 0.99;
		}
		if (rnd < 0.5 && rnd > 0.4993) { //every 10000 or so, add bias of up to 10000
			buffA[i] = myRand() * 60000 - 30000;
		}
		if (rnd < 0.6 && rnd > 0.599) {
			speed[i] = -speed[i];
		}
			
		
		if (absFloat(speed[i]) > SCHARMAX) {
			speed[i] *= 0.5;
		}
		signed char dBright = myRound(speed[i]);
		if (buffA[i] != 0 && dBright <= SCHARMAX-bitesize && dBright >= -SCHARMAX+bitesize) {
			if (buffA[i] < 0) {
				dBright-=10;
				buffA[i]+=10;
			} else {
				dBright+=10;
				buffA[i]-=10;
			}
			if (absFloat(buffA[i]) < 10) {
				buffA[i] = 0;
			}
		}
		signed char bndRes = boundShort(&brightness[i], &dBright);
		if (bndRes != 0) {
			speed[i] = -.5*speed[i];
		}
	}

}
Exemplo n.º 5
0
void genWindDirectionValues(size_t pnt, char *layoutKey, genMatchType * match,
                            xmlNodePtr parameters, int *maxWindDirection,
                            uChar f_XML, int *numOutputLines,
	                    double *valTimeForWindDirMatch, 
		            numRowsInfo numRows, int startNum, int endNum)
{
   int i; /* Counter thru match structure. */
   int priorElemCount = 0; /* Used to subtract prior elements when looping 
                            * thru matches. */
   int currentDay = 0;  /* Counter used to denote incrementing thru the 
                         * summarization (forecast) periods.*/ 
   int roundedWindDirectionData;  /* Returned rounded data. */
   xmlNodePtr direction = NULL; /* Xml Node Pointer for <direction> element. */
   xmlNodePtr value = NULL;   /* Xml Node Pointer for <value> element. */
   char strBuff[30];          /* Temporary string buffer holding rounded
                               * data. */

   /* If first forecast period is empty (from finding the max wind speed), 
    * assign missing data value. 
    */
   if (f_XML == 3 || f_XML == 4)
   {
      if (valTimeForWindDirMatch[0] == -999.0)
         currentDay = currentDay + 1;
   }
      
   /* If the product is of type DWMLgen, format the <wind_direction> element. 
    */
   if (f_XML == 1 || f_XML == 2|| f_XML == 6)
   {
      direction = xmlNewChild(parameters, NULL, BAD_CAST "direction", NULL);
      xmlNewProp(direction, BAD_CAST "type", BAD_CAST "wind");
      xmlNewProp(direction, BAD_CAST "units", BAD_CAST "degrees true");
      xmlNewProp(direction, BAD_CAST "time-layout", BAD_CAST layoutKey);

      /* Format the display name. */

      xmlNewChild(direction, NULL, BAD_CAST "name", BAD_CAST "Wind Direction");
   }

   /* Loop over all the Wind Direction data values. Format them if the
    * product is of type DWMLgen. Collect them in the maxWindDirection array
    * if the product is of type DWMLgenByDay. 
    */
   for (i = startNum; i < endNum; i++)
   {
      if (match[i].elem.ndfdEnum == NDFD_WD && 
	  match[i].validTime >= numRows.firstUserTime &&
	  match[i].validTime <= numRows.lastUserTime)
      {
         if (f_XML == 1 || f_XML == 2|| f_XML == 6)  /* DWMLgen products. */
         {
            /* If the data is missing, so indicate in the XML (nil=true). */
            if (match[i].value[pnt].valueType == 2)
            {
               value = xmlNewChild(direction, NULL, BAD_CAST "value", NULL);
               xmlNewProp(value, BAD_CAST "xsi:nil", BAD_CAST "true");
            }
            else if (match[i].value[pnt].valueType == 0)  /* Format good
                                                           * data. */
            {
               roundedWindDirectionData =
                     (int)myRound(match[i].value[pnt].data, 0);
               sprintf(strBuff, "%d", roundedWindDirectionData);
               xmlNewChild(direction, NULL, BAD_CAST "value", BAD_CAST strBuff);
            }
         }
         else if ((f_XML == 3 || f_XML == 4) && (currentDay < *numOutputLines))
		                            /* We don't format any wind for
                                             * these products, but simply get
                                             * Max. values for wind speed and
                                             * the wind dir that occured
					     * during the max speed time; for
					     * use in icon determination. */
         {
            if (valTimeForWindDirMatch[currentDay] == match[i].validTime)
            {
               maxWindDirection[currentDay] =
                     (int)myRound(match[i].value[pnt].data, 0);
               currentDay++;
            }
         }
      }
      else
         priorElemCount++;
   }
   return;
}
Exemplo n.º 6
0
void groupRectangles(std::vector<MyRect>& rectList, int groupThreshold, float eps)
{
  if( groupThreshold <= 0 || rectList.empty() )
    return;


  std::vector<int> labels;

  int nclasses = partition(rectList, labels, eps);

  std::vector<MyRect> rrects(nclasses);
  std::vector<int> rweights(nclasses);

  int i, j, nlabels = (int)labels.size();


  for( i = 0; i < nlabels; i++ )
    {
      int cls = labels[i];
      rrects[cls].x += rectList[i].x;
      rrects[cls].y += rectList[i].y;
      rrects[cls].width += rectList[i].width;
      rrects[cls].height += rectList[i].height;
      rweights[cls]++;
    }
  for( i = 0; i < nclasses; i++ )
    {
      MyRect r = rrects[i];
      float s = 1.f/rweights[i];
      rrects[i].x = myRound(r.x*s);
      rrects[i].y = myRound(r.y*s);
      rrects[i].width = myRound(r.width*s);
      rrects[i].height = myRound(r.height*s);

    }

  rectList.clear();

  for( i = 0; i < nclasses; i++ )
    {
      MyRect r1 = rrects[i];
      int n1 = rweights[i];
      if( n1 <= groupThreshold )
	continue;
      /* filter out small face rectangles inside large rectangles */
      for( j = 0; j < nclasses; j++ )
        {
	  int n2 = rweights[j];
	  /*********************************
	   * if it is the same rectangle, 
	   * or the number of rectangles in class j is < group threshold, 
	   * do nothing 
	   ********************************/
	  if( j == i || n2 <= groupThreshold )
	    continue;
	  MyRect r2 = rrects[j];

	  int dx = myRound( r2.width * eps );
	  int dy = myRound( r2.height * eps );

	  if( i != j &&
	      r1.x >= r2.x - dx &&
	      r1.y >= r2.y - dy &&
	      r1.x + r1.width <= r2.x + r2.width + dx &&
	      r1.y + r1.height <= r2.y + r2.height + dy &&
	      (n2 > myMax(3, n1) || n1 < 3) )
	    break;
        }

      if( j == nclasses )
        {
	  rectList.push_back(r1); // insert back r1
        }
    }

}
Exemplo n.º 7
0
void genPopValues(size_t pnt, char *layoutKey, genMatchType *match,
                  xmlNodePtr parameters, numRowsInfo numRows, uChar f_XML,
		  double startTime_cml, int *maxDailyPop, int *numDays, 
                  double currentDoubTime, char *currentHour, int startNum, 
                  int endNum)
{
   int i;                     /* Counter thru match structure. */
   int numNils = 0;           /* Denotes diff between number of data rows and 
				 the number that need to be formatted for the 
				 DWMLgenByDay products. */
   int numFmtdRows = 0;       /* Number of output lines in DWMLgenByDay products. */
   int dayCount = 0;          /* Used to keep count of which summarization
                               * period being processing (two PoPs per day). */
   int startOverCount = 0;    /* Used to denote if we should increment to the 
                                 next summarization period. */
   int roundedPopData = 0;    /* Returned rounded data. */
   xmlNodePtr precipitation = NULL; /* Xml Node Pointer for <precipitation>
                                     * element. */
   xmlNodePtr value = NULL;   /* Xml Node Pointer for <value> element. */
   char strBuff[30];          /* Temporary string buffer holding rounded
                               * data. */
   int priorElemCount = 0;    /* Used to subtract prior elements when looping 
                               * thru matches. */

   /* Format the <precipitation> element. */
   precipitation = xmlNewChild(parameters, NULL, BAD_CAST
                               "probability-of-precipitation", NULL);
   xmlNewProp(precipitation, BAD_CAST "type", BAD_CAST "12 hour");
   xmlNewProp(precipitation, BAD_CAST "units", BAD_CAST "percent");
   xmlNewProp(precipitation, BAD_CAST "time-layout", BAD_CAST layoutKey);

   /* Format the display <name> element. */
   xmlNewChild(precipitation, NULL, BAD_CAST "name", BAD_CAST
               "12 Hourly Probability of Precipitation");
   
   /* If DWMLgen product, set numFmtdRows = to numRows because we don't have 
    * a set number of rows we are ultimately formatting.
    */
   if (f_XML == 1 || f_XML == 2 || f_XML == 6)
      numFmtdRows = numRows.total-numRows.skipBeg-numRows.skipEnd;
   else if (f_XML == 3 || f_XML == 4) 
      numFmtdRows = (*numDays)*2;

   /* Loop over all the data values and format them. */
   for (i = startNum; i < endNum; i++)
   {
      if (match[i].elem.ndfdEnum == NDFD_POP && 
	  match[i].validTime >= numRows.firstUserTime &&
          match[i].validTime <= numRows.lastUserTime)
      {  
         /* Accounts for DWMLgenByDay. */
         if ((i - priorElemCount) < (numFmtdRows + startNum)) 
         {
	    if (f_XML == 3 || f_XML == 4) /* DWMLgenByDay products. */
            {
               startOverCount++;

               /* If the data is missing, so indicate in the XML (nil=true). */
               if (match[i].value[pnt].valueType == 2)
               {
                  value = xmlNewChild(precipitation, NULL, BAD_CAST "value",
                                      NULL);
                  xmlNewProp(value, BAD_CAST "xsi:nil", BAD_CAST "true");
               }
               else if (match[i].value[pnt].valueType == 0) /* Good data. */
               {
                  roundedPopData = (int)myRound(match[i].value[pnt].data, 0);
                  sprintf(strBuff, "%d", roundedPopData);
                  xmlNewChild(precipitation, NULL, BAD_CAST "value", BAD_CAST
                              strBuff);
               }

               /* Make some adjustments for the next loop interation. */
               if (f_XML == 4 && match[i].value[pnt].valueType == 0)
               {
                  /* For 24hr summarization, get the max PoP out of the two 
                   * 12hr pops to represent the summarization period. 
		   */
                  if (roundedPopData > maxDailyPop[dayCount] && dayCount <= *numDays)
	          {
                     maxDailyPop[dayCount] = roundedPopData;
                  }
                  /* We change to a new period every other PoP value. */
                  if (startOverCount % 2 == 0)
                     dayCount++;
               }
               else if (f_XML == 3 && match[i].value[pnt].valueType == 0)
               {
                  /* For 12hr summarization, we simply use every PoP value. */
                  if (dayCount <= (*numDays)*2)
                  {
                     maxDailyPop[dayCount] = roundedPopData;
                     dayCount++;
	          }
               }
            }   
            else if (f_XML == 1 || f_XML == 2 || f_XML == 6)
            {
               /* If the data is missing, so indicate in the XML (nil=true). */
               if (match[i].value[pnt].valueType == 2)
               {
                  value = xmlNewChild(precipitation, NULL, BAD_CAST "value", NULL);
                  xmlNewProp(value, BAD_CAST "xsi:nil", BAD_CAST "true");
               }
               else if (match[i].value[pnt].valueType == 0)  /* Format good
                                                              * data. */
               {
                  roundedPopData = (int)myRound(match[i].value[pnt].data, 0);
                  sprintf(strBuff, "%d", roundedPopData);
                  xmlNewChild(precipitation, NULL, BAD_CAST "value", BAD_CAST
                              strBuff);
               }
            }
	 }
      }
      else
         priorElemCount++;
   }

   /* In certain cases for the DWMLgenByDay products, we'll need to account for 
    * times when there may be less data in the match structure than the amount 
    * of data that needs to be formatted. These "extra" spaces will need to be 
    * formatted with a "nil" attribute. 
    */
   if (f_XML == 3 || f_XML == 4)  /* DWMLgenByDay products. */
   {
      /* Tally up the number of iterations that occurred thru the match 
       * structure and compare to the number of actual data rows to see if there
       * is a difference.
       */
      numNils = numFmtdRows - (numRows.total-numRows.skipBeg-numRows.skipEnd);
      if (numNils > 0)
      {
         for (i = 0; i < numNils; i++)
	 {
            value = xmlNewChild(precipitation, NULL, BAD_CAST "value", NULL);
            xmlNewProp(value, BAD_CAST "xsi:nil", BAD_CAST "true");
	 }
      }
   }
   
   return;
}
Exemplo n.º 8
0
void prepareDWMLgenByDay(genMatchType *match, uChar f_XML, 
                         double *startTime_cml, double *endTime_cml,
			 double *firstValidTimeMatch, int *numDays, 
                         char *format, uChar *f_formatPeriodName,
                         uChar **wxParameters, int *timeInterval,
                         int *numOutputLines, char *summarization,
			 double currDoubTime, size_t numPnts, 
                         PntSectInfo *pntInfo, char **currentLocalDate, 
                         size_t numElem, genElemDescript *elem, 
                         uChar varFilter[NDFD_MATCHALL + 1])
{
   int i; /* Counter through the match structure. */
   int j; /* Counter through points. */
   int f_startTimeToZero = 0; /* After the point loop and upon exiting routine,
                               * flag denotes whether to turn incoming user
                               * supplied startTime to zero. */
   int f_endTimeToZero = 0; /* After the point loop and upon exiting routine,
                             * flag denotes whether to turn incoming user
                             * supplied endTime to zero. */
   int startNum; /* First index in match structure an individual point's data
                  * matches can be found. */
   int endNum;/* Last index in match structure an individual point's data
               * matches can be found. */
   double lastValidTimeMatch = 0.0; /* Time of last valid data value. Used in 
                                     * determining numDays value. */
   char currUTCHour[3];  /* Current UTC hour in 2-digit form. */
   char currUTCTime[30]; /* Current UTC Time in
                          * "2006-12-29T00:00:00-00:00" format. */
   char currUTCDate[3];  /* Current UTC date in 2-digit form. */

   /* Find the current hour in UTC form. */
   Clock_Print2(currUTCTime, 30, currDoubTime,
                "%Y-%m-%dT%H:%M:%S", 0, 0);

   currUTCHour[0] = currUTCTime[11];
   currUTCHour[1] = currUTCTime[12];
   currUTCHour[2] = '\0';
   currUTCDate[0] = currUTCTime[8];
   currUTCDate[1] = currUTCTime[9];
   currUTCDate[2] = '\0';

   /* Get the validTime of the first match and last match of the match 
    * structure. We'll need these to calculate numDays. 
    */
   for (j = 0; j < numPnts; j++)
   {

/*
      printf ("pntInfo[%d].startNum = %d\n",j,pntInfo[j].startNum);
      printf ("pntInfo[%d].endNum = %d\n",j,pntInfo[j].endNum);
*/
      startNum = pntInfo[j].startNum;
      endNum = pntInfo[j].endNum;

      firstValidTimeMatch[j] = match[startNum].validTime;
      lastValidTimeMatch = match[startNum].validTime;
      for (i = startNum; i < endNum; i++)
      {
         if (match[i].validTime < firstValidTimeMatch[j])
            firstValidTimeMatch[j] = match[i].validTime;
         if (match[i].validTime > lastValidTimeMatch)
            lastValidTimeMatch = match[i].validTime;
      }

      if (*startTime_cml == 0.0 && *endTime_cml == 0.0)
         numDays[j] = ceil(((lastValidTimeMatch - currDoubTime) / 3600) / 24);
      else if (*startTime_cml == 0.0 && *endTime_cml != 0.0)
      {	   
         /* Then endTime was entered on the command line argument. See if the time
          * entered occurs after the last valid data in NDFD. If so, simply treat
          * it as if no endTime was entered (set endTime = 0.0).
          */	   
         if (*endTime_cml < currDoubTime || *endTime_cml > lastValidTimeMatch)
         {
            f_endTimeToZero = 1;
            numDays[j] = ceil(((lastValidTimeMatch - currDoubTime) / 3600) / 24);\
         }
         else
            numDays[j] = (int)myRound(((*endTime_cml - currDoubTime) / 3600) / 24, 0);
      }
      else if (*startTime_cml != 0.0 && *endTime_cml == 0.0)
      {

         /* Then startTime was entered as a command line argument. First, see if 
          * the startTime occurs before current system time. If so, simply treat 
          * it as if no startTime was entered (set startTime = 0.0).
          */
         if (*startTime_cml < currDoubTime || *startTime_cml > lastValidTimeMatch)
         {
            f_startTimeToZero = 1;
            numDays[j] = ceil(((lastValidTimeMatch - currDoubTime) / 3600) / 24);
         }      
         else
         {
            numDays[j] = ceil(((lastValidTimeMatch - *startTime_cml) / 3600) / 24);
         }
      }      
      else if (*startTime_cml != 0.0 && *endTime_cml != 0.0)
      {
         /* Then both startTime and endTime were entered as command line arguments.
          * Simply subtract the times. Rule out erroneous choices for these times. If
          * that is the case, simply use times returned in match structure.
          */
          if (*startTime_cml < currDoubTime || *startTime_cml > lastValidTimeMatch)
          { 
             /* startTime not valid. */
             f_startTimeToZero = 1;
             if (*endTime_cml < currDoubTime || *endTime_cml > lastValidTimeMatch)
             {
                /* endTime is not valid. */
                f_endTimeToZero = 1;
                numDays[j] = ceil(((lastValidTimeMatch - currDoubTime) / 3600) / 24);
             }
             else /* startTime is not valid (before current time), but endTime is valid, 
                     shortening the time period data is retrieved for. */
             {
                if (atoi(currUTCHour) >= 5 && atoi(currUTCHour) < 12)
                /* This if statement is needed because we set the startTime at 5Z on
                 * the date specified by startDate. For example, if startDate is set
                 * on command line to "2007-10-29" then the startTime is converted to
                 * "2007-10-29T01:00:00-04:00". The endTime, based off of command 
                 * line argument "numDays" (ie. numDays = 5) is set to 12Z numDays 
                 * into the future. Here, it would be "2007-11-03T08:00:00-04:00". Thus, 
                 * if the current Time is between these hours, we need to account for 
                 * this with either the floor or ceil command when determining numDays.
                 */
                {
                   if (strcmp(currentLocalDate[j], currUTCDate) != 0)
                      numDays[j] = floor((*endTime_cml - currDoubTime) / (3600 * 24));
                   else
                      numDays[j] = floor((*endTime_cml - currDoubTime) / (3600 * 24));
                }
                else
                {
                   if (strcmp(currentLocalDate[j], currUTCDate) != 0)
                      numDays[j] = floor((*endTime_cml - (currDoubTime-(3600*24))) / (3600 * 24));
                   else
                      numDays[j] = ceil((*endTime_cml - currDoubTime) / (3600 * 24));
                }
             }
          }
          else /* startTime is valid. */
          {
             if (*endTime_cml < currDoubTime || *endTime_cml > lastValidTimeMatch)
             { 
                /* endTime is not valid. */
                f_endTimeToZero = 1;
                numDays[j] = ceil(((lastValidTimeMatch - *startTime_cml) / 3600) / 24);
             }
             else /* Both are valid, shortening the time period data is returned for. */
             {
                numDays[j] = floor((*endTime_cml - *startTime_cml) / (3600 * 24));
             }
          }
      }
 
      /* Assign the number of output lines, if DWMLgenByDay product. */
      if (f_XML == 3)
         /* All elements formatted this way in 12 hourly product except MaxT 
          * and Mint. 
          */
         numOutputLines[j] = numDays[j] * 2;
      else if (f_XML == 4)
         numOutputLines[j] = numDays[j];

      /* Flag the below five elements for formatting in the ouput XML (icons
       * will be the sixth element formatted). Set the value to = 1. 
       */
      for (i = 0; i < numElem; i++)
      {
         if (varFilter[elem[i].ndfdEnum] >= 2)
            wxParameters[j][i] = 1;
      }

      /* We need to collect data for the following four elements too. They are
       * not formatted in the output XML summary products, but are used in icon 
       * determination. Set these values to = 2. 
       */
      for (i = 0; i < numElem; i++)
      {
         if (elem[i].ndfdEnum == NDFD_WD)
            wxParameters[j][i] = 2;
         if (elem[i].ndfdEnum == NDFD_WS)
            wxParameters[j][i] = 2;
         if (elem[i].ndfdEnum == NDFD_SKY)
            wxParameters[j][i] = 2;
         if (elem[i].ndfdEnum == NDFD_WG)
            wxParameters[j][i] = 2;
      }
   } /* End Point Loop. */

   /* DWMLgenByDay, both formats, have pre-defined sets of NDFD parameters. */	   
   if (f_XML == 3)
   {
      *f_formatPeriodName = 1;
      *timeInterval = 3600 * 12;  /* Number of seconds in half a day */
      strcpy(summarization, "12hourly");
      strcpy(format, "12 hourly");
   }
   else if (f_XML == 4)       /* Note, there is no formatting of period
                               * names. */
   {	    
      *timeInterval = 3600 * 24;  /* Number of seconds in a whole day */
      strcpy(summarization, "24hourly");
      strcpy(format, "24 hourly");
   }

   if (f_startTimeToZero)
      *startTime_cml = 0.0;      
   if (f_endTimeToZero)
      *endTime_cml = 0.0; 

   return;
}