Ejemplo n.º 1
0
bool PDSphere::isValidData(double &f)
{
	if(!PDPrimary3D::isValidData(f))
		return false;
	if(!isValidFloat(f=m_dRadius))
		return false;
	if(!isValidFloat(f=m_ptCenter.x) || !isValidFloat(f=m_ptCenter.y) || !isValidFloat(f=m_ptCenter.z))
		return false;
	return true;
}
Ejemplo n.º 2
0
void scanValue()
{
	Value *v = valueBuff + nValueBuff;
	char buff[1024];
	gets(buff);
	if (isValidInt(buff))
	{
		v->type = INTEGER;
		nValueExtraBuff += sizeof(int);
		*((int*)v->extra) = (int)atoi(buff);
	}
	else if (isValidFloat(buff))
	{
		v->type = FLOAT;
		nValueExtraBuff += sizeof(float);
		*((float*)v->extra) = (float)atoi(buff);
	}
	else
	{
		v->type = STRING;
		v->extra = valueExtraBuff + nValueExtraBuff;
		nValueExtraBuff += sprintf((char*)v->extra, "%s", buff) + 1;
	}
}
Ejemplo n.º 3
0
//CHAR 类型的长度限制在interpreter部分实现
bool APIManager:: checkInsertType(string tableName, vector<string> insert)
{
    int tableIndex = catalogmanager.findTable(tableName);
    int attrType;
    int arrNum = catalogmanager.Vtable[tableIndex].attriNum;
    for(int i = 0; i< arrNum; ++i )
    {
        attrType = catalogmanager.Vtable[tableIndex].attributes[i].type;
        switch (attrType) {
            case INT: // int
                if (!isValidInt(insert[i])) {
                    return false;
                }
                break;
            case FLOAT: // float
                if (!isValidFloat(insert[i])) {
                    return false;
                }
            default:
                break;
        }
    }
    return true;
}
Ejemplo n.º 4
0
bool PDEcone::isValidData(double &f)
{
  if(!PDPrimary3D::isValidData(f))
    return false;
  if(!isValidFloat(f=m_dDiameter1))
    return false;
  if(!isValidFloat(f=m_dDiameter2))
    return false;
  if(!isValidFloat(f=m_ptEnd.x) || !isValidFloat(f=m_ptEnd.y) || !isValidFloat(f=m_ptEnd.z))
    return false;
  if(!isValidFloat(f=m_ptStart.x) || !isValidFloat(f=m_ptStart.y) || !isValidFloat(f=m_ptStart.z))
    return false;
  if(!isValidFloat(f=m_vect.x) || !isValidFloat(f=m_vect.y) || !isValidFloat(f=m_vect.z))
    return false;
  return true;
}
Ejemplo n.º 5
0
void sacHeaderFromCSS(DBlist tree, struct SACheader *header, struct wfdiscList *w, int RefTimeType,
                                   double *RefTime, MagType Mtype)
{
   struct sitechanList *sc;
   struct siteList *si;
   struct originList *orig;
   struct eventList *ev;
   struct assocList *aso;
   struct assocList *as;
   struct affiliationList *af;
   struct arrivalList *ar, *arm;
   struct sacdataList *sd;
   struct wftagList *wt = 0 ;

   int year, month, day, hour, min;
   float second;
   int i;
   char SACfield[3];
   float TmpMilliSeconds;


   *header = NullSacHeader;


   header->npts = w->element->nsamp;
   if( CSSchrDefined(w->element->instype) )
      strcpy(header->kinst,w->element->instype);

   header->nwfid = w->element->wfid; 

/* Find an origin struct matched to w and copy its info to header. */
   if( (orig = sacFindOrigin(tree, w) ) ){
      if( CSSfltDefined(orig->element->lat) )   header->evla   = orig->element->lat;
      if( CSSfltDefined(orig->element->lon) )   header->evlo   = orig->element->lon;
      if( CSSfltDefined(orig->element->depth) ) header->evdp   = orig->element->depth * 1000.0;
      if( CSSlngDefined(orig->element->grn) )   header->ievreg = orig->element->grn + REGCONV ;
      if( CSSlngDefined(orig->element->orid)    )header->norid = orig->element->orid;
      if( CSSlngDefined(orig->element->evid) ){
         header->nevid = orig->element->evid;
      }
      header->ievtyp = sacSetEvType(orig->element->etype);
      if( (as = sacFindAssoc(tree, orig->element->orid, w->element->sta) ) ){
	 if(isValidFloat(dbl_LIST_ASSOC, dbl_ASSOC_DELTA, as->element->delta) )
	     header->gcarc = as->element->delta;
	 if( CSSfltDefined(as->element->seaz) )   header->baz = as->element->seaz;
	 if( CSSfltDefined(as->element->esaz)     )header->az = as->element->esaz;
      }
      SetMagnitudeInHeader(header, orig, Mtype);
      SetMagnitudeSource(header, orig);
   }

   if(orig && RefTimeType == IO && CSSdblDefined(orig->element->time)){
      header->iztype = IO;
      *RefTime = orig->element->time;
   }
   else{
      header->iztype = IB;
      *RefTime = w->element->time;
   }
      
      
   header->b = (float) (w->element->time - *RefTime);
   if(orig && CSSdblDefined(orig->element->time) ){
      header->o = orig->element->time - *RefTime;
      strcpy(header->ko, "O");
   }

   if(w->element->samprate)
	header->delta = 1.0 / w->element->samprate;
   else
        header->delta = 1.0;

   header->e = header->b + (float) ( (header->npts -1) * header->delta);

   tmDecodeEpochTime(*RefTime, &year, &month, &day, &hour, &min, &second);
   header->nzyear  = year;
   header->nzjday  = yrday( month, day, isleap( year) );
   header->nzhour  = hour;
   header->nzmin   = min;
   header->nzsec   = (int) second;
   TmpMilliSeconds = (second - (int) second) * 1000;
   header->nzmsec  = Round(TmpMilliSeconds);

   if(w->seis->Cmplx){
      header->iftype = IXY;
      header->leven = FALSE;
   }
   else{
      header->iftype = ITIME;
      header->leven  = TRUE;
      header->depmin = FLT_MAX;
      header->depmax = -header->depmin;
      header->depmen = 0.0;
      for(i=0;i<header->npts;i++){
	 header->depmen += *(w->seis->i + i);
	 if(header->depmin > *(w->seis->i + i) ) header->depmin = *(w->seis->i + i);
	 if(header->depmax < *(w->seis->i + i) ) header->depmax = *(w->seis->i + i);
      }
      if(header->npts) header->depmen /= header->npts;
   }



   /* Get A variable if any are marked as such. */

   strcpy(SACfield, "A");
   arm = MatchingArrival(tree, w->element->sta, w->element->chan, w->element->time,
                         w->element->endtime, SACfield, w->element->wfid);
   if(arm){
      header->a = arm->element->time - *RefTime;
      aso = sacFindAssocFromArid( tree , arm->element->arid ) ;
      if ( aso && isValidString ( dbl_LIST_ASSOC , dbl_ASSOC_PHASE , aso->element->phase ) )
         strncpy(header->ka, aso->element->phase,8);
      else
         strncpy(header->ka, arm->element->iphase,8);
   }

   /* Get T0 - T9 */
   ar = 0;
   for(i=0;i<10;i++){
      sprintf(SACfield,"T%d",i);
      SACfield[2] = '\0';
      arm = MatchingArrival(tree, w->element->sta, w->element->chan, w->element->time,
                           w->element->endtime, SACfield, w->element->wfid);
      if(!arm){  /* If you can't find an arrival marked for Ti, take the next unmarked arrival. */
         ar = sacFindNextMatchingArrival(ar, tree, w->element->sta, w->element->chan,
                                         w->element->time, w->element->endtime, w->element->wfid);
         if ( !ar ) continue ;
         arm = ar;
      }
      aso = sacFindAssocFromArid( tree , arm->element->arid ) ;
      if ( aso && isValidString ( dbl_LIST_ASSOC , dbl_ASSOC_PHASE , aso->element->phase ) ) {
         if ( toupper(aso->element->phase[0]) == 'F' ) continue;
         char *kt = sac_header_kt_number(header, i);
         if(kt) {
             strncpy(kt, aso->element->phase,8);
         }
      }
      else {
         if( toupper(arm->element->iphase[0]) == 'F' ) continue;
         char *kt = sac_header_kt_number(header, i);
         if(kt) {
             strncpy(kt, arm->element->iphase,8);
         }
      }
      *(&(header->t0) + i) = arm->element->time - *RefTime;
      strcpy(arm->element->SACfield, SACfield);
   }



/* Now get the Fini arrival if present. */
   strcpy(SACfield, "F");
   arm = MatchingArrival(tree, w->element->sta, w->element->chan, w->element->time,
                         w->element->endtime, SACfield, w->element->wfid);
   if(arm){
	 header->f = arm->element->time - *RefTime;
         aso = sacFindAssocFromArid( tree , arm->element->arid ) ;
         if ( aso && isValidString ( dbl_LIST_ASSOC , dbl_ASSOC_PHASE , aso->element->phase ) )
            strncpy(header->kf, aso->element->phase,8);
         else
	    strcpy( header->kf, arm->element->iphase);
   }
   else{
      ar = 0;
      do {
         ar = sacFindNextMatchingArrival(ar, tree, w->element->sta, w->element->chan,
                                         w->element->time, w->element->endtime, w->element->wfid);
         if(!ar)break;
         aso = sacFindAssocFromArid( tree , ar->element->arid ) ;
         if ( aso && isValidString ( dbl_LIST_ASSOC , dbl_ASSOC_PHASE , aso->element->phase ) ) {
            if( toupper(aso->element->phase[0]) == 'F' ){
               header->f = ar->element->time - *RefTime;
               strcpy( header->kf, aso->element->phase);
            }
         }
         else {
            if( toupper(ar->element->iphase[0]) == 'F' ){
	       header->f = ar->element->time - *RefTime;
	       strcpy( header->kf, ar->element->iphase);
            }
         }
      }while(ar);
   }

   if( CSSchrDefined(w->element->sta) )
      strncpy(header->kstnm, w->element->sta, 8);

   if( CSSchrDefined(w->element->chan) )
      strncpy(header->kcmpnm, w->element->chan, 8);


   sc = sacFindSiteChan(tree, w->element->sta, w->element->chan, w->element->jdate,
                        w->element->wfid );
   if(sc ){
       if ( isValidFloat ( dbl_LIST_SITECHAN , dbl_SITEC_VANG , sc->element->vang ) )
          header->cmpinc   = sc->element->vang;
       else
          header->cmpinc = -12345.0 ;
       if ( isValidFloat ( dbl_LIST_SITECHAN , dbl_SITEC_HANG , sc->element->hang ) )
          header->cmpaz    = sc->element->hang;
       else
          header->cmpaz = -12345.0 ;
       if(!header->cmpinc) 
          header->cmpaz = 0.0;
       header->stdp     = sc->element->edepth * 1000.0 ;
   }

   if( (si = sacFindSite(tree, w->element->sta, w->element->jdate, w->element->wfid) ) ){
       if( CSSfltDefined(si->element->lat) )  header->stla = si->element->lat;
       if( CSSfltDefined(si->element->lon) )  header->stlo = si->element->lon;
       if( CSSfltDefined(si->element->elev) ) header->stel = si->element->elev * 1000;
       strncpy(header->kuser1 , si->element->refsta , 6 ) ; 
	header->kuser1[6] = '\0' ;
   } else {
     DEBUG("warning: Could not find Site: %s [%d]\n", w->element->sta, w->element->wfid);
   }
   SetDistAzValues(header);


  /* lpspol - true if station components have positive polarity */
   header->lpspol = FALSE;
  
   /* lcalca - true if event info is to be calculated from position */
   header->lcalda = TRUE;

   /* lovrok - true if the file can be overwritten */
   header->lovrok = TRUE;

   /* SAC header version number */
   header->nvhdr = 6;


   sd = findSacData(tree, w->element->wfid);
   if( sd ) {
      strcpy(header->kuser0, sd->element->userdata.label[0]);
      strcpy(header->kuser1, sd->element->userdata.label[1]);
      strcpy(header->kuser2, sd->element->userdata.label[2]);

      header->user0    = sd->element->userdata.value[0];
      header->user1    = sd->element->userdata.value[1];
      header->user2    = sd->element->userdata.value[2];
      header->user3    = sd->element->userdata.value[3];
      header->user4    = sd->element->userdata.value[4];
      header->user5    = sd->element->userdata.value[5];
      header->user6    = sd->element->userdata.value[6];
      header->user7    = sd->element->userdata.value[7];
      header->user8    = sd->element->userdata.value[8];
      header->user9    = sd->element->userdata.value[9];

      header->isynth   = sd->element->synthflag;
      header->lpspol   = sd->element->lpspol;
      header->idep     = sd->element->idep;
      header->iftype   = sd->element->iftype;
      header->nsnpts   = sd->element->nsnpts;
      header->nxsize   = sd->element->nxsize;
      header->nysize   = sd->element->nysize;
      header->leven    = sd->element->leven;
      header->fmt      = sd->element->fmt;
      header->sb       = sd->element->sb;
      header->sdelta   = sd->element->sdelta;
      header->xminimum = sd->element->xminimum;
      header->xmaximum = sd->element->xmaximum;
      header->yminimum = sd->element->yminimum;
      header->ymaximum = sd->element->ymaximum;
      header->odelta   = sd->element->odelta;
      header->resp0    = sd->element->resp[0];
      header->resp1    = sd->element->resp[1];
      header->resp2    = sd->element->resp[2];
      header->resp3    = sd->element->resp[3];
      header->resp4    = sd->element->resp[4];
      header->resp5    = sd->element->resp[5];
      header->resp6    = sd->element->resp[6];
      header->resp7    = sd->element->resp[7];
      header->resp8    = sd->element->resp[8];
      header->resp9    = sd->element->resp[9];
      header->evel     = sd->element->evel;
      header->az       = sd->element->az;
      header->baz      = sd->element->baz;
      header->gcarc    = sd->element->gcarc;
      header->dist     = sd->element->dist;
      header->iinst    = sd->element->iinst;
      if ( lngDefined  ( sd->element->istreg ) )
        header->istreg = sd->element->istreg + REGCONV ;
      header->iqual    = sd->element->iqual;
      header->lovrok   = sd->element->lovrok;
      header->lcalda   = sd->element->lcalda;
      strcpy(header->khole, sd->element->khole);
      strcpy(header->ko, sd->element->ko);
      strcpy(header->kdatrd, sd->element->kdatrd );
   }







   strncpy(header->kdatrd, tmListEpochTime( tmGetEpochTime(), 18 ) , 8 );
   header->kdatrd[ 8 ] = '\0' ;

   if( (af = sacFindAffiliation(tree, header->kstnm) ) ){
      strcpy(header->knetwk, af->element->net);
   }

   if( ( wt = sacFindWftag( tree, w->element->wfid, "evid" ) ) ) {
      if( (ev = sacFindEvent(tree, wt->element->tagid) ) ){
         if( CSSchrDefined(ev->element->evname) )
            strcpy(header->kevnm, ev->element->evname);
      }
   }


}
Ejemplo n.º 6
0
int PutOriginData ( FILE *ptr , DBlist tree )
{
    char HeaderLine1[] = "   Date       Time       Latitude Longitude    Depth    Ndef Nsta "
                         "Gap    Mag1  N    Mag2  N    Mag3  N  Author          ID\n";
    char HeaderLine2[] = "       rms   OT_Error      Smajor Sminor Az        Err   mdist"
                         "  Mdist     Err        Err        Err     Quality\n";

    char time[ 25 ] ,
	fixf = ' ' ,
	lat[ 9 ] ,
	lon[ 10 ] ,
	depth[ 6 ] ,
	ndef[ 5 ] ,
	nsta[ ] = "    " ,
	gap[ ] = "   " ,
	magtype1[ 3 ] ,
	mag1[ 5 ] ,
	magtype2[ 3 ] ,
	mag2[ 5 ] ,
	magtype3[ 3 ] ,
	mag3[ 5 ] ,
	N[] = "  " ,
	author[ 9 ] ,
	id[ 9 ] ,
	line2[] = "\n             +-                                +-                       +-         +-         +-              \n\n" ;


    struct CSStree *Tree = (struct CSStree *) tree ;
    struct originList *orig = Tree->orHead ;

    if(!orig)
	return -1;

    printf("Writing origin data ");

    fprintf(ptr,"DATA_TYPE ORIGIN GSE2.0\n");
    fprintf(ptr, "%s", HeaderLine1);
    fprintf(ptr, "%s\n", HeaderLine2);

    while(orig){
	putchar('.');
	fflush(stdout);

	/* time */
        if ( isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_TIME, orig->element->time ) ) {
            sprintf ( time , "%-21.21s" , tmListEpochTime ( orig->element->time , 14 ) ) ;
	    time[ 10 ] = ' ' ;
	}
        else
            strcpy ( time , "                     " ) ;       /* 21 spaces */

	/* lat */
        if ( isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_LAT, orig->element->lat ) )
            sprintf ( lat , "%8.4f" , orig->element->lat ) ;
        else
            strcpy ( lat , "        " ) ;       /* 8 spaces */

	/* lon */
        if ( isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_LON, orig->element->lon ) )
            sprintf ( lon , "%9.4f" , orig->element->lon ) ;
        else
            strcpy ( lon , "         " ) ;       /* 9 spaces */

	/* depth */
        if ( isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_DEPTH, orig->element->depth ) )
            sprintf ( depth , "%5.1f" , orig->element->depth ) ;
        else
            strcpy ( depth , "     " ) ;       /* 5 spaces */

	/* ndef */
        if ( isValidInt ( dbl_LIST_ORIGIN, dbl_ORIGI_NDEF, orig->element->ndef ) )
            sprintf ( ndef , "%4d" , orig->element->ndef ) ;
        else
            strcpy ( ndef , "    " ) ;       /* 4 spaces */

	/* magnitudes */
	if ( isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_MB, orig->element->mb ) ) {
            sprintf ( mag1 , "%4.1f" , orig->element->mb ) ;
	    strcpy ( magtype1 , "mb" ) ;
	}
        else {
            strcpy ( mag1 , "    " ) ;		/* 4 spaces */
	    strcpy ( magtype1 , "  " ) ;	/* 2 spaces */
	}

        if ( isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_MB, orig->element->ms ) ) {
            sprintf ( mag2 , "%4.1f" , orig->element->ms ) ;
            strcpy ( magtype2 , "ms" ) ;
        }
        else {
            strcpy ( mag2 , "    " ) ;          /* 4 spaces */
            strcpy ( magtype2 , "  " ) ;        /* 2 spaces */
        }

        if ( isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_MB, orig->element->ml ) ) {
            sprintf ( mag3 , "%4.1f" , orig->element->ml ) ;
            strcpy ( magtype3 , "ml" ) ;
        }
        else {
            strcpy ( mag3 , "    " ) ;          /* 4 spaces */
            strcpy ( magtype3 , "  " ) ;        /* 2 spaces */
        }

	/* author */
        if ( isValidString ( dbl_LIST_ORIGIN, dbl_ORIGI_AUTH, orig->element->auth ) &&
             strcmp( orig->element->auth , "-       " )  ) {
	    if ( strlen ( orig->element->auth ) <= 8 )
        	sprintf ( author , "%-8.8s" , orig->element->auth ) ;
	    else {
		strncpy ( author , orig->element->auth , 8 ) ;
		author[ 8 ] = '\0' ;
	    }
	}
        else
            strcpy ( author , "        " ) ;       /* 8 spaces */

	/* id */
	if ( isValidInt ( dbl_LIST_ORIGIN, dbl_ORIGI_ORID, orig->element->orid ) )
            sprintf ( id , "%8d" , orig->element->orid ) ;
        else
            strcpy ( id , "        " ) ;       /* 8 spaces */

	/* out put the strings */
	fprintf ( ptr , "%s %c  %s %s %c  %s %c  %s %s %s  %s%s %s  %s%s %s  %s%s %s  %s  %s%s",
		  time, fixf, lat, lon, fixf, depth, fixf, ndef, nsta, gap, 
		  magtype1, mag1, N, magtype2, mag2, N, magtype3, mag3, N, author, id , line2 ) ;

	orig = orig->next;
    }
    fprintf(ptr,"\n");
    printf("\n");

    return 0 ;

} /* end PutOriginData */
Ejemplo n.º 7
0
int PutArrivalData ( FILE *ptr , DBlist tree )
{
    char sta[ 6 ] ,
	 dist[ 7 ] ,
	 evaz[ 6 ] ,
	 picktype = ' ' ,
	 direction ,
	 detchar ,
	 phase[ 8 ] ,
	 time[ 25 ] ,
	 tres[] = "     " ,
	 azim[ 6 ] ,
	 azres[ 7 ] ,
	 slow[ 6 ] ,
	 sres[ 6 ] ,
	 tdef ,
	 adef ,
	 sdef ,
	 snr[ 6 ] ,
	 amp[ 10 ] ,
	 per[ 6 ] ,
	 mdef1[ 3 ] ,
	 mag1[ 5 ] ,
	 mdef2[ 3 ] ,
	 mag2[ 5 ] ,
	 id [ 9 ] ;

    struct CSStree *Tree = (struct CSStree *) tree ;
    struct arrivalList *ar = Tree->arHead ;

    int dots = 0;
    char HeaderLine[] = "Sta     Dist  EvAz     Phase      Date       Time     TRes  Azim"
                       "  AzRes  Slow  SRes Def   SNR       Amp   Per   Mag1   Mag2       ID";

    if(!ar)
	return -1 ;


    printf("Writing arrival data ");
    fprintf(ptr,"DATA_TYPE ARRIVAL GSE2.0\n");
    fprintf(ptr, "%s\n", HeaderLine);

    while(ar){
	struct assocList *as = Tree->asHead ;
	struct originList *orig = Tree->orHead ;
	struct siteList *si = Tree->slHead ;

	putchar('.');
	dots++;
	if(dots == 80){
	    putchar('\n');
	    dots = 0;
	}
	fflush(stdout);

	/* sta */
        if ( isValidString ( dbl_LIST_ARRIVAL, dbl_ARRIV_STA , ar->element->sta ) &&
             strcmp( ar->element->sta , "-    " )  )
            sprintf ( sta , "%-5.5s" , ar->element->sta ) ;
        else
            strcpy ( sta , "     " ) ;         /* 5 spaces */

	/* dist & evaz */
	/* find assoc in order to find origin, then find sitechan */
	while ( as ) {
	    if ( as->element->arid == ar->element->arid )
		break ;
	    as = as->next ;
	}

	if ( as )
	    while ( orig ) {
		if ( as->element->orid == orig->element->orid )
		    break ;
		orig = orig->next ;
	    } /* end while ( orig ) */

	while ( si ) {
	    if ( !strcmp ( ar->element->sta , si->element->sta ) &&
		 si->element->ondate <= ar->element->jdate &&
		 (si->element->offdate >= ar->element->jdate ||
		 si->element->offdate == -1 ) )
		break ;

	    si = si->next ;
	} /* end while ( si ) */

	if ( orig && si && 
	     isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_LAT, orig->element->lat ) &&
	     isValidFloat ( dbl_LIST_ORIGIN, dbl_ORIGI_LON, orig->element->lon ) &&
	     isValidFloat ( dbl_LIST_SITE, dbl_SITE_LAT, si->element->lat ) &&
	     isValidFloat ( dbl_LIST_SITE, dbl_SITE_LON, si->element->lon ) ) {

		float slat = si->element->lat ,
		      slon = si->element->lon ,
		      elat = orig->element->lat ,
		      elon = orig->element->lon ,
		      delt, fDist, fAzim, bazim ;

		dbDelaz(&slat, &slon, &elat, &elon, &delt, &fDist, &fAzim, &bazim);

		if ( fDist < 1000 )
		    sprintf ( dist , "%6.2f" , fDist ) ;
		else
		    sprintf ( dist , "%6.1f" , fDist ) ;
		sprintf ( evaz , "%5.1f" , fAzim ) ;
	}
	else {
	    strcpy ( dist , "      " ) ;        /* 6 spaces */
	    strcpy ( evaz , "     " ) ;         /* 5 spaces */
	}

	/* direction */
        if ( isValidString ( dbl_LIST_ARRIVAL, dbl_ARRIV_FM , ar->element->fm ) ) {
	    char *fm = ar->element->fm ;
	    if ( fm[ 0 ] == 'c' || fm[ 1 ] == 'c' )
		direction = 'c' ;
	    else if ( fm[ 0 ] == 'd' || fm[ 1 ] == 'd' )
		direction = 'd' ;
	    else if ( fm[ 0 ] == 'u' || fm[ 1 ] == 'u' )
		direction = 'c' ;
	    else if ( fm[ 0 ] == 'r' || fm[ 1 ] == 'r' )
		direction = 'd' ;
	    else
		direction = ' ' ;
	}
	else
	    direction = ' ' ;

	/* detchar */
        if ( isValidString ( dbl_LIST_ARRIVAL, dbl_ARRIV_QUAL , ar->element->qual ) ) {
	    if ( ar->element->qual[ 0 ] == 'i' || ar->element->qual[ 0 ] == 'e' )
		detchar = ar->element->qual[ 0 ] ;
	    else if ( ar->element->qual[ 0 ] == 'q' || ar->element->qual[ 0 ] == 'w' )
		detchar = 'q' ;
	    else
		detchar = ' ' ;
	}
        else
	    detchar = ' ' ;

	/* phase */
        if ( isValidString ( dbl_LIST_ARRIVAL, dbl_ARRIV_IPHASE , ar->element->iphase ) &&
             strcmp( ar->element->iphase , "-      " )  )
            sprintf ( phase , "%-7.7s" , ar->element->iphase ) ;
        else
            strcpy ( phase , "       " ) ;         /* 7 spaces */

	/* time */
        if ( isValidFloat ( dbl_LIST_ARRIVAL, dbl_ARRIV_TIME, ar->element->time ) ) {
            sprintf ( time , "%-21.21s" , tmListEpochTime ( ar->element->time , 14 ) ) ;
	    time[ 10 ] = ' ' ;
	}
        else
            strcpy ( time , "                     " ) ;       /* 21 spaces */

	/* azim */
        if ( isValidFloat ( dbl_LIST_ARRIVAL, dbl_ARRIV_AZIMUTH , ar->element->azimuth ) )
            sprintf ( azim , "%5.1f" , ar->element->azimuth ) ;
        else
            strcpy ( azim , "     " ) ;         /* 5 spaces */

	/* azres */
        if ( isValidFloat ( dbl_LIST_ARRIVAL, dbl_ARRIV_DELAZ , ar->element->delaz ) )
            sprintf ( azres , "%6.1f" , ar->element->delaz ) ;
        else
            strcpy ( azres , "      " ) ;         /* 6 spaces */

	/* slow */
        if ( isValidFloat ( dbl_LIST_ARRIVAL, dbl_ARRIV_SLOW , ar->element->slow ) )
            sprintf ( slow , "%5.1f" , ar->element->slow ) ;
        else
            strcpy ( slow , "     " ) ;         /* 5 spaces */

	/* sres */
        if ( isValidFloat ( dbl_LIST_ARRIVAL, dbl_ARRIV_DELSLO , ar->element->delslo ) )
            sprintf ( sres , "%5.1f" , ar->element->delslo ) ;
        else
            strcpy ( sres , "     " ) ;         /* 5 spaces */

	/* tdef, adef, & sdef */
	if ( as && as->element->timedef[0] == 'd' )
	    tdef = 'T' ;
	else
	    tdef = ' ' ;
	if ( as && as->element->azdef[0] == 'd' )
	    adef = 'A' ;
	else
	    adef = ' ' ;
	if ( as && as->element->slodef[0] == 'd' )
	    sdef = 'S' ;
	else
	    sdef = ' ' ;

	/* snr */
        if ( isValidFloat ( dbl_LIST_ARRIVAL, dbl_ARRIV_SNR , ar->element->snr ) )
            sprintf ( snr , "%5.1f" , ar->element->snr ) ;
        else
            strcpy ( snr , "     " ) ;         /* 5 spaces */

	/* amp */
        if ( isValidFloat ( dbl_LIST_ARRIVAL, dbl_ARRIV_AMP , ar->element->amp ) )
            sprintf ( amp , "%9.1f" , ar->element->amp ) ;
        else
            strcpy ( amp , "         " ) ;         /* 9 spaces */

	/* per */
        if ( isValidFloat ( dbl_LIST_ARRIVAL, dbl_ARRIV_PER , ar->element->per ) )
            sprintf ( per , "%5.2f" , ar->element->per ) ;
        else
            strcpy ( per , "     " ) ;         /* 5 spaces */

	/* mdef1, mag1, mdef2, & mag2 */
	if ( orig ) {
	    if ( isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_MB , orig->element->mb ) &&
		 isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_MS , orig->element->ms ) ) {
		strcpy ( mdef1 , "mb" ) ;
		sprintf( mag1  , "%4.1f" , orig->element->mb ) ;
		strcpy ( mdef2 , "ms" ) ;
		sprintf( mag2  , "%4.1f" , orig->element->ms ) ;
	    }
	    else if ( isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_MB , orig->element->mb ) &&
		      isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_ML , orig->element->ml ) ) {
		strcpy ( mdef1 , "mb" ) ;
		sprintf( mag1  , "%4.1f" , orig->element->mb ) ;
		strcpy ( mdef2 , "ml" ) ;
		sprintf( mag2  , "%4.1f" , orig->element->ml ) ;
	    }
	    else if ( isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_MS , orig->element->ms ) &&
		      isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_ML , orig->element->ml ) ) {
		strcpy ( mdef1 , "ms" ) ;
		sprintf( mag1  , "%4.1f" , orig->element->ms ) ;
		strcpy ( mdef2 , "ml" ) ;
		sprintf( mag2  , "%4.1f" , orig->element->ml ) ;
	    }
	    else {
		strcpy ( mdef2 , "  " ) ;
		strcpy ( mag2  , "    " ) ;

		if ( isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_MB , orig->element->mb ) ) {
		    strcpy ( mdef1 , "mb" ) ;
		    sprintf( mag1  , "%4.1f" , orig->element->mb ) ;
		}
		else if ( isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_MS , orig->element->ms ) ) {
		    strcpy ( mdef1 , "ms" ) ;
		    sprintf( mag1  , "%4.1f" , orig->element->ms ) ;
		}
		else if ( isValidFloat ( dbl_LIST_ORIGIN , dbl_ORIGI_ML , orig->element->ml ) ) {
		    strcpy ( mdef1 , "ml" ) ;
		    sprintf( mag1  , "%4.1f" , orig->element->ml ) ;
		}
		else {
		    strcpy ( mdef1 , "  " ) ;
		    strcpy ( mag1  , "    " ) ;
		}
	    }
	}
	else {
	    strcpy ( mdef1 , "  " ) ;
	    strcpy ( mag1  , "    " ) ;
	    strcpy ( mdef2 , "  " ) ;
	    strcpy ( mag2  , "    " ) ;
	}

	/* id */
        if ( isValidInt ( dbl_LIST_ARRIVAL, dbl_ARRIV_ARID , ar->element->arid ) )
            sprintf ( id , "%8d" , ar->element->arid ) ;
        else
            strcpy ( id , "        " ) ;         /* 8 spaces */


	fprintf ( ptr , "%s %s %s %c%c%c %s %s %s %s %s %s %s %c%c%c %s %s %s %s%s %s%s %s",
		  sta, dist, evaz, picktype, direction, detchar, phase, time, tres,
		  azim, azres, slow, sres, tdef, adef, sdef, snr, amp, per, 
		  mdef1, mag1, mdef2, mag2, id ) ;

	fprintf(ptr, "\n");
	ar = ar->next;
    }
    fprintf(ptr,"\n");
    printf("\n");

    return 0 ;
} /* end PutArrivalData */
Ejemplo n.º 8
0
int PutChannelData ( FILE *ptr , DBlist tree )
{
   char sta[6],
	chan[4],
	auxid[ 5 ] ,
	lat[ 10 ] ,
	lon[ 11 ] ,
	elev[ 8 ] ,
	depth[ 7 ] ,
	hang[ 7 ],
	vang[ 6 ],
	samprat[ 12 ],
	inst[8],
	ondate[25],
	offdate[25];

    int dots = 0;

    float fLat , fLon , fElev ;

    struct CSStree *Tree = (struct CSStree *) tree ;
    struct sitechanList *sc = Tree->scHead ;


    if(!sc)
	return -1 ;

    printf("Writing channel data ");
    fprintf(ptr,"DATA_TYPE CHANNEL\n");
    fprintf(ptr,
     "Sta  Chan Aux   Latitude  Longitude    Elev  Depth   Hang  Vang Sample_Rate Inst       On Date   Off Date\n");

    while(sc){
	struct siteList *si = Tree->slHead ;
	struct wfdiscList *wf = Tree->wfHead ;

	putchar('.');
	dots++;
	if(dots == 80){
	    putchar('\n');
	    dots = 0;
	}
	fflush(stdout);

	/* sta */
        if ( isValidString ( dbl_LIST_SITECHAN, dbl_SITEC_STA , sc->element->sta ) &&
             strcmp( sc->element->sta , "-    " )  )
            sprintf ( sta , "%-5.5s" , sc->element->sta ) ;
        else
            strcpy ( sta , "     " ) ;         /* 5 spaces */

	/* chan */
        if ( isValidString ( dbl_LIST_SITECHAN, dbl_SITEC_CHAN , sc->element->chan ) &&
             strcmp( sc->element->chan , "-  " )  )
            sprintf ( chan , "%-3.3s" , sc->element->chan ) ;
        else
            strcpy ( chan , "   " ) ;         /* 3 spaces */

	/* auxid */
        strcpy ( auxid , "    " ) ;         /* 4 spaces */

	/* lat, lon, & elev */
        GetSiteInfo ( si , sc->element->sta , sc->element->ondate , sc->element->offdate ,
          &fLat , &fLon , &fElev ) ;

        if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_LAT , fLat ) )
            sprintf ( lat , "%9.5f" , fLat ) ;
        else
            strcpy ( lat , "         " ) ;         /* 9 spaces */

        if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_LON , fLon ) )
            sprintf ( lon , "%10.5f" , fLon ) ;
        else
            strcpy ( lon , "          " ) ;         /* 10 spaces */ 

        if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_ELEV , fElev ) )
            sprintf ( elev , "%7.3f" , fElev ) ;
        else
            strcpy ( elev , "       " ) ;         /* 7 spaces */

	/* depth */
        if ( isValidFloat ( dbl_LIST_SITECHAN, dbl_SITEC_EDEPTH , sc->element->edepth ) )
            sprintf ( depth , "%6.3f" , sc->element->edepth ) ;
        else
            strcpy ( depth , "      " ) ;         /* 6 spaces */

	/* hang & vang */
        if ( isValidFloat ( dbl_LIST_SITECHAN, dbl_SITEC_HANG , sc->element->hang ) )
            sprintf ( hang , "%6.1f" , sc->element->hang ) ;
        else
            strcpy ( hang , "      " ) ;         /* 6 spaces */

        if ( isValidFloat ( dbl_LIST_SITECHAN, dbl_SITEC_VANG , sc->element->vang ) )
            sprintf ( vang , "%5.1f" , sc->element->vang ) ;
        else
            strcpy ( vang , "     " ) ;         /* 5 spaces */

	/* samprat */
	strcpy ( samprat , "           " ) ;	/* 11 spaces */

	/* inst */
	GetWfdiscInfo ( wf, sta , chan , sc->element->ondate , sc->element->offdate , inst ) ;
	if ( isValidString ( dbl_LIST_WFDISC, dbl_WFDIS_INSTYPE , inst ) &&
             strcmp( inst , "-      " )  ) {
	    if ( strlen ( inst ) < 7 ) {
		int kdx ;
		for ( kdx = strlen ( inst ) ; kdx < 7 ; kdx++ ) {
		    inst[ kdx ] = ' ' ;
		}
		inst[ 7 ] = '\0' ;
	    }
	}
	else
	    sprintf ( inst , "       " ) ;	/* 7 spaces */

	/* ondate */
        if ( isValidInt ( dbl_LIST_SITECHAN, dbl_SITEC_ONDATE , sc->element->ondate ) ) {
            int doy, mm, id, iyyy , jdate = sc->element->ondate ;

            iyyy = jdate / 1000 ;
            doy  = jdate - ( iyyy * 1000 ) ;

            mnday ( doy , isleap ( iyyy ) , &mm , &id ) ;

            sprintf(ondate, "%04d/%02d/%02d" , iyyy, mm, id );
        }
        else
            strcpy ( ondate , "          " ) ;  /* 10 spaces */

	/* offdate */
        if ( isValidInt ( dbl_LIST_SITECHAN, dbl_SITEC_OFFDATE , sc->element->offdate ) ) {
            int doy, mm, id, iyyy , jdate = sc->element->offdate ;

            iyyy = jdate / 1000 ;
            doy  = jdate - ( iyyy * 1000 ) ;

            mnday ( doy , isleap ( iyyy ) , &mm , &id ) ;

            sprintf(offdate, "%04d/%02d/%02d" , iyyy, mm, id );
        }
        else
            strcpy ( offdate , "          " ) ;  /* 10 spaces */


	fprintf(ptr,"%s %s %s %s %s %s %s %s %s %s %s %s %s\n", sta, chan, auxid,
              lat, lon, elev, depth, hang, vang, samprat, inst, ondate, offdate );

	sc = sc->next;
    }
    fprintf(ptr,"\n");
    printf("\n");

    return 0 ;
} /* end PutChannelData */
Ejemplo n.º 9
0
int PutStationData ( FILE *ptr , DBlist tree )
{
    char sta	[ 6 ] ,
	 statype[ 5 ] ,
	 lat	[ 10 ] ,
	 lon	[ 11 ] ,
	 elev	[ 8 ] ,
	 ondate	[ 25 ] ,
	 offdate[ 25 ] ;

    int dots = 0;

    struct CSStree *Tree = (struct CSStree *) tree ;
    struct siteList *si = Tree->slHead ;

    if(!si)
	return -1 ;

    printf("Writing station data ");
    fprintf(ptr,"DATA_TYPE STATION\n");
    fprintf(ptr, "Sta   Type  Latitude  Longitude    Elev    On Date   Off Date\n");

    while(si){
	putchar('.');
	dots++;
	if(dots == 80){
	    putchar('\n');
	    dots = 0;
	}
	fflush(stdout);

	/* sta */
        if ( isValidString ( dbl_LIST_SITE, dbl_SITE_STA , si->element->sta ) &&
             strcmp( si->element->sta , "-    " )  )
            sprintf ( sta , "%-5.5s" , si->element->sta ) ;
        else
            strcpy ( sta , "     " ) ;   /* 5 spaces */

	/* statype */
	if ( isValidString ( dbl_LIST_SITE, dbl_SITE_STATYPE , si->element->statype ) &&
             strcmp( si->element->statype , "-   " )  )
	    sprintf ( statype , "%-4.4s" , si->element->statype ) ;
	else
            strcpy ( statype , "    " ) ;   /* 4 spaces */

	/* lat */
        if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_LAT , si->element->lat ) )
            sprintf ( lat , "%9.5f" , si->element->lat ) ;
        else
            strcpy ( lat , "         " ) ;   /* 9 spaces */

	/* lon */
        if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_LON , si->element->lon ) )
            sprintf ( lon , "%10.5f" , si->element->lon ) ;
        else
            strcpy ( lon , "          " ) ;   /* 10 spaces */

	/* elev */
        if ( isValidFloat ( dbl_LIST_SITE, dbl_SITE_ELEV , si->element->elev ) )
            sprintf ( elev , "%7.3f" , si->element->elev ) ;
        else
            strcpy ( elev , "       " ) ;	/* 7 spaces */

	/* ondate */
	if ( isValidInt ( dbl_LIST_SITE, dbl_SITE_ONDATE , si->element->ondate ) ) {
	    int doy, mm, id, iyyy , jdate = si->element->ondate ;

	    iyyy = jdate / 1000 ;
	    doy  = jdate - ( iyyy * 1000 ) ;

	    mnday ( doy , isleap ( iyyy ) , &mm , &id ) ;

	    sprintf(ondate, "%04d/%02d/%02d" , iyyy, mm, id );
	}
	else
	    strcpy ( ondate , "          " ) ;	/* 10 spaces */

	/* offdate */
	if ( isValidInt ( dbl_LIST_SITE, dbl_SITE_OFFDATE , si->element->offdate ) ) {
            int doy, mm, id, iyyy , jdate = si->element->offdate ;

            iyyy = jdate / 1000 ;
            doy  = jdate - ( iyyy * 1000 ) ;

            mnday ( doy , isleap ( iyyy ) , &mm , &id ) ;

            sprintf(offdate, "%04d/%02d/%02d" , iyyy, mm, id );
	}
	else
	    strcpy ( offdate , "          " ) ;    /* 10 spaces */	

	fprintf(ptr,"%s %s %s %s %s %s %s\n" ,
	  sta, statype, lat, lon, elev , ondate, offdate );
	si = si->next;
    }
    fprintf(ptr,"\n");
    printf("\n");

    return 0 ;
} /* end PutStationData */
Ejemplo n.º 10
0
int PutWaveformData ( FILE *ptr , DBlist tree , int cm6 )
{
    char id	[ 5 ] ,
	time	[ 24 ] ,
	station	[ 6 ] ,
	channel	[ 4 ] ,
	auxid	[ 5 ] ,
	datatype[ 4 ] ,
	samps	[ 9 ] ,
	samprat	[ 12 ] ,
	calib	[ 11 ] ,
	calper	[ 9 ] ;
    char instype[ ] = "      ",
	hang	[ 6 ] ,
	vang	[ 5 ] ;

    double dHang , dVang ;

    int Ntraces = 0 ;

    int dots = 0 ;
    int jdx ;
    int column ;
    int MaxColumns = 15 ;

    struct CSStree *Tree = (struct CSStree *) tree ;
    struct wfdiscList *wfL ;

    printf ( "Converting waveforms " ) ;
    for ( wfL = Tree->wfHead ; wfL ; wfL = wfL->next , Ntraces++ ) {
	int *iData ;
	struct sitechanList *sc = Tree->scHead ;

	/* display dots for the users sake */
	putchar('.');
	dots++;
	if(dots == 80){
	    putchar('\n');
	    dots = 0;
	}
	fflush(stdout);

	/* data_type record */
	fprintf(ptr,"DATA_TYPE WAVEFORM\n");

	/* BEGIN WID2 RECORD */

	/* id */
	strcpy ( id , "WID2" ) ;

	/* date and time */
	if(isValidFloat( dbl_LIST_WFDISC, dbl_WFDIS_TIME, wfL->element->time )){
	    sprintf ( time , "%-23.23s" , tmListEpochTime ( wfL->element->time , 14 ) ) ;
	    time[ 10 ] = ' ' ;
	}
	else
	    strcpy ( time , "                       " ) ;	/* 23 spaces */
	    
	/* station */
	if ( isValidString ( dbl_LIST_WFDISC, dbl_WFDIS_STA , wfL->element->sta ) &&
             strcmp( wfL->element->sta , "-    " ) ) 
	    sprintf ( station , "%-5.5s" , wfL->element->sta ) ;
	else
	    strcpy ( station , "     " ) ;	/* 5 spaces */

	/* channel */
	if ( isValidString ( dbl_LIST_WFDISC, dbl_WFDIS_CHAN , wfL->element->chan ) &&
             strcmp( wfL->element->chan , "-  " )  )
	    sprintf ( channel , "%-3.3s" , wfL->element->chan ) ;
	else
	    strcpy ( channel , "   " ) ;	/* 3 spaces */

	/* auxid */
	strcpy ( auxid , "    " ) ;		/* 4 spaces */

	/* datatype */
        if( cm6 )
	    strcpy ( datatype , "CM6" ) ;       /* 3 spaces */
        else
	    strcpy ( datatype , "INT" ) ;       /* 3 spaces */

	/* samps */
	if ( isValidInt ( dbl_LIST_WFDISC, dbl_WFDIS_NSAMP , wfL->element->nsamp ) )
	    sprintf ( samps , "%8d" , wfL->element->nsamp ) ;
	else {
	    printf ( "Warning:  file %d had no value for samps\n" , Ntraces + 1 ) ;
	    continue ;
	}

	/* samprat */
	if ( isValidFloat ( dbl_LIST_WFDISC, dbl_WFDIS_SAMPRATE , wfL->element->samprate ) )
	    sprintf ( samprat , "%11.6f" , wfL->element->samprate ) ;
	else
	    strcpy ( samprat , "           " ) ;/* 11 spaces */

	/* calib */
	if ( isValidFloat ( dbl_LIST_WFDISC, dbl_WFDIS_CALIB , wfL->element->calib ) )
	    sprintf ( calib , "%10.2e" , wfL->element->calib ) ;
	else
	    strcpy ( calib , "          " ) ;	/* 10 spaces */

	/* calper */
        if ( isValidFloat ( dbl_LIST_WFDISC, dbl_WFDIS_CALPER , wfL->element->calper ) )
            sprintf ( calper , "%7.3f" , wfL->element->calper ) ;
        else
            sprintf ( calper , "%s", "        " ) ;   /* 8 spaces */

	/* instype */
	if ( isValidString ( dbl_LIST_WFDISC, dbl_WFDIS_INSTYPE , wfL->element->instype ) &&
             strcmp( wfL->element->instype , "-     " )  )
	    sprintf ( instype , "%-6.6s" , wfL->element->instype ) ;
	else
	    strcpy ( instype , "      " ) ;	/* 6 spaces */

	/* hang and vang */
	GetChannelInfo(sc, station, channel, &dHang, &dVang);
	if ( isValidFloat ( dbl_LIST_SITECHAN, dbl_SITEC_HANG , dHang ) )
	    sprintf ( hang , "%5.1f" , dHang ) ;
	else
	    strcpy ( hang , "     " ) ;		/* 5 spaces */

	if ( isValidFloat ( dbl_LIST_SITECHAN, dbl_SITEC_VANG , dVang ) )
            sprintf ( vang , "%4.1f" , dVang ) ;
        else
            strcpy ( vang , "    " ) ;         /* 4 spaces */

	fprintf(ptr, "%s %s %s %s %s %s %s %s %s %s %s %s %s\n", id, time, station,
	  channel, auxid, datatype, samps, samprat, calib, calper, instype, hang, vang);
	/* END WID2 RECORD */


	/* dat2 record */
	fprintf(ptr,"DAT2\n");

	column = 0 ;

	if( !wfL->seis ) {
	    printf ( "ERROR: Data not found!\n " ) ;
	    return ( -1 ) ;
	}

	/* waveform */
	iData = (int *) malloc ( wfL->element->nsamp * sizeof( int ) ) ;
	if ( !iData ) {
	    printf ( "Error:  insufficient memory, PutWavefomrData\n" ) ;
	    return 0 ;
	}
	for ( jdx = 0 ; jdx < wfL->element->nsamp ; jdx++ ) {
	    double point = wfL->seis->i[ jdx ] ;

	    point = point >= 0 ? point + 0.5 : point - 0.5 ;
	    iData[ jdx ] = (int) point ;

            if( !cm6 ){    /* INT format, one point at a time. */
	        fprintf ( ptr , "%d " , (int) point ) ;
	        if ( ++column == MaxColumns ) {
		    fprintf ( ptr , "\n" ) ;
		    column = 0 ;
	        }
            }
	}
        if( cm6 ){
	    char *cOut ;  /* data compressed into CM6 format. */

            takeDiff( iData , wfL->element->nsamp ) ;

	    /* call cmprs6 to get string of chars */
	    if( cmprs6( wfL->element->nsamp , iData , &cOut ) ) {
                printf ( "Error:  insufficient memory, PutWavefomrData\n" ) ;
                free( cOut );
                return 0 ;
            }

	    /* write it out (it already has newlines every 80 chars.) */
	    fprintf ( ptr , "%s", cOut ) ;
            fprintf ( ptr , "\n" ) ;

            free( cOut ) ;

            remdif1( iData , wfL->element->nsamp ) ;
            remdif1( iData , wfL->element->nsamp ) ;
        }
	else
	    if ( column ) fprintf ( ptr , "\n" ) ;

	fprintf(ptr,"CHK2  %d\n\n", CheckSumFromIntArray(iData, wfL->element->nsamp) );
	free ( iData ) ;

    } /* end for */

    printf ( "\n" ) ;

    return Ntraces ;
} /* end PutWaveformData */