⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msrutils.c

📁 C编写的格式转换程序
💻 C
📖 第 1 页 / 共 3 页
字号:
	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_log (0, "            signal amplitude: %g\n", blkt_200->amplitude);	      ms_log (0, "               signal period: %g\n", blkt_200->period);	      ms_log (0, "         background estimate: %g\n", blkt_200->background_estimate);	      	      if ( details > 1 )		{		  b = blkt_200->flags;		  ms_log (0, "       event detection flags: [%u%u%u%u%u%u%u%u] 8 bits\n",			  bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08),			  bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80));		  if ( b & 0x01 ) ms_log (0, "                         [Bit 0] 1: Dilatation wave\n");		  else            ms_log (0, "                         [Bit 0] 0: Compression wave\n");		  if ( b & 0x02 ) ms_log (0, "                         [Bit 1] 1: Units after deconvolution\n");		  else            ms_log (0, "                         [Bit 1] 0: Units are digital counts\n");		  if ( b & 0x04 ) ms_log (0, "                         [Bit 2] Bit 0 is undetermined\n");		  ms_log (0, "               reserved byte: %u\n", blkt_200->reserved);		}	      	      ms_btime2seedtimestr (&blkt_200->time, time);	      ms_log (0, "           signal onset time: %s\n", time);	      ms_log (0, "               detector name: %.24s\n", blkt_200->detector);	    }	  else if ( cur_blkt->blkt_type == 201 )	    {	      struct blkt_201_s *blkt_201 = (struct blkt_201_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_log (0, "            signal amplitude: %g\n", blkt_201->amplitude);	      ms_log (0, "               signal period: %g\n", blkt_201->period);	      ms_log (0, "         background estimate: %g\n", blkt_201->background_estimate);	      	      b = blkt_201->flags;	      ms_log (0, "       event detection flags: [%u%u%u%u%u%u%u%u] 8 bits\n",		      bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08),		      bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80));	      if ( b & 0x01 ) ms_log (0, "                         [Bit 0] 1: Dilation wave\n");	      else            ms_log (0, "                         [Bit 0] 0: Compression wave\n");	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_201->reserved);	      	      ms_btime2seedtimestr (&blkt_201->time, time);	      ms_log (0, "           signal onset time: %s\n", time);	      ms_log (0, "                  SNR values: ");	      for (idx=0; idx < 6; idx++) ms_log (0, "%u  ", blkt_201->snr_values[idx]);	      ms_log (0, "\n");	      ms_log (0, "              loopback value: %u\n", blkt_201->loopback);	      ms_log (0, "              pick algorithm: %u\n", blkt_201->pick_algorithm);	      ms_log (0, "               detector name: %.24s\n", blkt_201->detector);	    }	  else if ( cur_blkt->blkt_type == 300 )	    {	      struct blkt_300_s *blkt_300 = (struct blkt_300_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_btime2seedtimestr (&blkt_300->time, time);	      ms_log (0, "      calibration start time: %s\n", time);	      ms_log (0, "      number of calibrations: %u\n", blkt_300->numcalibrations);	      	      b = blkt_300->flags;	      ms_log (0, "           calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n",		      bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08),		      bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80));	      if ( b & 0x01 ) ms_log (0, "                         [Bit 0] First pulse is positive\n");	      if ( b & 0x02 ) ms_log (0, "                         [Bit 1] Calibration's alternate sign\n");	      if ( b & 0x04 ) ms_log (0, "                         [Bit 2] Calibration was automatic\n");	      if ( b & 0x08 ) ms_log (0, "                         [Bit 3] Calibration continued from previous record(s)\n");	      	      ms_log (0, "               step duration: %u\n", blkt_300->step_duration);	      ms_log (0, "           interval duration: %u\n", blkt_300->interval_duration);	      ms_log (0, "            signal amplitude: %g\n", blkt_300->amplitude);	      ms_log (0, "        input signal channel: %.3s", blkt_300->input_channel);	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_300->reserved);	      ms_log (0, "         reference amplitude: %u\n", blkt_300->reference_amplitude);	      ms_log (0, "                    coupling: %.12s\n", blkt_300->coupling);	      ms_log (0, "                     rolloff: %.12s\n", blkt_300->rolloff);	    }	  	  else if ( cur_blkt->blkt_type == 310 )	    {	      struct blkt_310_s *blkt_310 = (struct blkt_310_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_btime2seedtimestr (&blkt_310->time, time);	      ms_log (0, "      calibration start time: %s\n", time);	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_310->reserved1);	      	      b = blkt_310->flags;	      ms_log (0, "           calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n",		      bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08),		      bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80));	      if ( b & 0x04 ) ms_log (0, "                         [Bit 2] Calibration was automatic\n");	      if ( b & 0x08 ) ms_log (0, "                         [Bit 3] Calibration continued from previous record(s)\n");	      if ( b & 0x10 ) ms_log (0, "                         [Bit 4] Peak-to-peak amplitude\n");	      if ( b & 0x20 ) ms_log (0, "                         [Bit 5] Zero-to-peak amplitude\n");	      if ( b & 0x40 ) ms_log (0, "                         [Bit 6] RMS amplitude\n");	      	      ms_log (0, "        calibration duration: %u\n", blkt_310->duration);	      ms_log (0, "               signal period: %g\n", blkt_310->period);	      ms_log (0, "            signal amplitude: %g\n", blkt_310->amplitude);	      ms_log (0, "        input signal channel: %.3s", blkt_310->input_channel);	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_310->reserved2);	      	      ms_log (0, "         reference amplitude: %u\n", blkt_310->reference_amplitude);	      ms_log (0, "                    coupling: %.12s\n", blkt_310->coupling);	      ms_log (0, "                     rolloff: %.12s\n", blkt_310->rolloff);	    }	  else if ( cur_blkt->blkt_type == 320 )	    {	      struct blkt_320_s *blkt_320 = (struct blkt_320_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_btime2seedtimestr (&blkt_320->time, time);	      ms_log (0, "      calibration start time: %s\n", time);	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_320->reserved1);	      	      b = blkt_320->flags;	      ms_log (0, "           calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n",		      bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08),		      bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80));	      if ( b & 0x04 ) ms_log (0, "                         [Bit 2] Calibration was automatic\n");	      if ( b & 0x08 ) ms_log (0, "                         [Bit 3] Calibration continued from previous record(s)\n");	      if ( b & 0x10 ) ms_log (0, "                         [Bit 4] Random amplitudes\n");	      	      ms_log (0, "        calibration duration: %u\n", blkt_320->duration);	      ms_log (0, "      peak-to-peak amplitude: %g\n", blkt_320->ptp_amplitude);	      ms_log (0, "        input signal channel: %.3s", blkt_320->input_channel);	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_320->reserved2);	      ms_log (0, "         reference amplitude: %u\n", blkt_320->reference_amplitude);	      ms_log (0, "                    coupling: %.12s\n", blkt_320->coupling);	      ms_log (0, "                     rolloff: %.12s\n", blkt_320->rolloff);	      ms_log (0, "                  noise type: %.8s\n", blkt_320->noise_type);	    }	  	  else if ( cur_blkt->blkt_type == 390 )	    {	      struct blkt_390_s *blkt_390 = (struct blkt_390_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_btime2seedtimestr (&blkt_390->time, time);	      ms_log (0, "      calibration start time: %s\n", time);	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_390->reserved1);	      	      b = blkt_390->flags;	      ms_log (0, "           calibration flags: [%u%u%u%u%u%u%u%u] 8 bits\n",		      bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08),		      bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80));	      if ( b & 0x04 ) ms_log (0, "                         [Bit 2] Calibration was automatic\n");	      if ( b & 0x08 ) ms_log (0, "                         [Bit 3] Calibration continued from previous record(s)\n");	      	      ms_log (0, "        calibration duration: %u\n", blkt_390->duration);	      ms_log (0, "            signal amplitude: %g\n", blkt_390->amplitude);	      ms_log (0, "        input signal channel: %.3s", blkt_390->input_channel);	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_390->reserved2);	    }	  else if ( cur_blkt->blkt_type == 395 )	    {	      struct blkt_395_s *blkt_395 = (struct blkt_395_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_btime2seedtimestr (&blkt_395->time, time);	      ms_log (0, "        calibration end time: %s\n", time);	      if ( details > 1 )		ms_log (0, "          reserved bytes (2): %u,%u\n",			blkt_395->reserved[0], blkt_395->reserved[1]);	    }	  else if ( cur_blkt->blkt_type == 400 )	    {	      struct blkt_400_s *blkt_400 = (struct blkt_400_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_log (0, "      beam azimuth (degrees): %g\n", blkt_400->azimuth);	      ms_log (0, "  beam slowness (sec/degree): %g\n", blkt_400->slowness);	      ms_log (0, "               configuration: %u\n", blkt_400->configuration);	      if ( details > 1 )		ms_log (0, "          reserved bytes (2): %u,%u\n",			blkt_400->reserved[0], blkt_400->reserved[1]);	    }	  else if ( cur_blkt->blkt_type == 405 )	    {	      struct blkt_405_s *blkt_405 = (struct blkt_405_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s, incomplete)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_log (0, "           first delay value: %u\n", blkt_405->delay_values[0]);	    }	  else if ( cur_blkt->blkt_type == 500 )	    {	      struct blkt_500_s *blkt_500 = (struct blkt_500_s *) cur_blkt->blktdata;	      	      ms_log (0, "          BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_log (0, "              VCO correction: %g%%\n", blkt_500->vco_correction);	      ms_btime2seedtimestr (&blkt_500->time, time);	      ms_log (0, "           time of exception: %s\n", time);	      ms_log (0, "                        usec: %d\n", blkt_500->usec);	      ms_log (0, "           reception quality: %u%%\n", blkt_500->reception_qual);	      ms_log (0, "             exception count: %u\n", blkt_500->exception_count);	      ms_log (0, "              exception type: %.16s\n", blkt_500->exception_type);	      ms_log (0, "                 clock model: %.32s\n", blkt_500->clock_model);	      ms_log (0, "                clock status: %.128s\n", blkt_500->clock_status);	    }	  	  else if ( cur_blkt->blkt_type == 1000 )	    {	      struct blkt_1000_s *blkt_1000 = (struct blkt_1000_s *) cur_blkt->blktdata;	      int recsize;	      char order[40];	      	      /* Calculate record size in bytes as 2^(blkt_1000->rec_len) */	      recsize = (unsigned int) 1 << blkt_1000->reclen;	      	      /* Big or little endian? */	      if (blkt_1000->byteorder == 0)		strncpy (order, "Little endian", sizeof(order)-1);	      else if (blkt_1000->byteorder == 1)		strncpy (order, "Big endian", sizeof(order)-1);	      else		strncpy (order, "Unknown value", sizeof(order)-1);	      	      ms_log (0, "         BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_log (0, "                    encoding: %s (val:%u)\n",		      (char *) ms_encodingstr (blkt_1000->encoding), blkt_1000->encoding);	      ms_log (0, "                  byte order: %s (val:%u)\n",		      order, blkt_1000->byteorder);	      ms_log (0, "               record length: %d (val:%u)\n",		      recsize, blkt_1000->reclen);	      	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_1000->reserved);	    }	  	  else if ( cur_blkt->blkt_type == 1001 )	    {	      struct blkt_1001_s *blkt_1001 = (struct blkt_1001_s *) cur_blkt->blktdata;	      	      ms_log (0, "         BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_log (0, "              timing quality: %u%%\n", blkt_1001->timing_qual);	      ms_log (0, "                micro second: %d\n", blkt_1001->usec);	      	      if ( details > 1 )		ms_log (0, "               reserved byte: %u\n", blkt_1001->reserved);	      	      ms_log (0, "                 frame count: %u\n", blkt_1001->framecnt);	    }	  else if ( cur_blkt->blkt_type == 2000 )	    {	      struct blkt_2000_s *blkt_2000 = (struct blkt_2000_s *) cur_blkt->blktdata;	      char order[40];	      	      /* Big or little endian? */	      if (blkt_2000->byteorder == 0)		strncpy (order, "Little endian", sizeof(order)-1);	      else if (blkt_2000->byteorder == 1)		strncpy (order, "Big endian", sizeof(order)-1);	      else		strncpy (order, "Unknown value", sizeof(order)-1);	      	      ms_log (0, "         BLOCKETTE %u: (%s)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	      ms_log (0, "            blockette length: %u\n", blkt_2000->length);	      ms_log (0, "                 data offset: %u\n", blkt_2000->data_offset);	      ms_log (0, "               record number: %u\n", blkt_2000->recnum);	      ms_log (0, "                  byte order: %s (val:%u)\n",		      order, blkt_2000->byteorder);	      b = blkt_2000->flags;	      ms_log (0, "                  data flags: [%u%u%u%u%u%u%u%u] 8 bits\n",		      bit(b,0x01), bit(b,0x02), bit(b,0x04), bit(b,0x08),		      bit(b,0x10), bit(b,0x20), bit(b,0x40), bit(b,0x80));	      if ( details > 1 )		{		  if ( b & 0x01 ) ms_log (0, "                         [Bit 0] 1: Stream oriented\n");		  else            ms_log (0, "                         [Bit 0] 0: Record oriented\n");		  if ( b & 0x02 ) ms_log (0, "                         [Bit 1] 1: Blockette 2000s may NOT be packaged\n");		  else            ms_log (0, "                         [Bit 1] 0: Blockette 2000s may be packaged\n");		  if ( ! (b & 0x04) && ! (b & 0x08) )		                  ms_log (0, "                      [Bits 2-3] 00: Complete blockette\n");		  else if ( ! (b & 0x04) && (b & 0x08) )		                  ms_log (0, "                      [Bits 2-3] 01: First blockette in span\n");		  else if ( (b & 0x04) && (b & 0x08) )		                  ms_log (0, "                      [Bits 2-3] 11: Continuation blockette in span\n");		  else if ( (b & 0x04) && ! (b & 0x08) )		                  ms_log (0, "                      [Bits 2-3] 10: Final blockette in span\n");		  if ( ! (b & 0x10) && ! (b & 0x20) )		                  ms_log (0, "                      [Bits 4-5] 00: Not file oriented\n");		  else if ( ! (b & 0x10) && (b & 0x20) )		                  ms_log (0, "                      [Bits 4-5] 01: First blockette of file\n");		  else if ( (b & 0x10) && ! (b & 0x20) )		                  ms_log (0, "                      [Bits 4-5] 10: Continuation of file\n");		  else if ( (b & 0x10) && (b & 0x20) )		                  ms_log (0, "                      [Bits 4-5] 11: Last blockette of file\n");		}	      	      ms_log (0, "           number of headers: %u\n", blkt_2000->numheaders);	      	      /* Crude display of the opaque data headers */	      if ( details > 1 )		ms_log (0, "                     headers: %.*s\n",			(blkt_2000->data_offset - 15), blkt_2000->payload);	    }	  	  else	    {	      ms_log (0, "         BLOCKETTE %u: (%s, not parsed)\n", cur_blkt->blkt_type,		      ms_blktdesc(cur_blkt->blkt_type));	      ms_log (0, "              next blockette: %u\n", cur_blkt->next_blkt);	    }	  	  cur_blkt = cur_blkt->next;	}    }} /* End of msr_print() *//*************************************************************************** * msr_host_latency: * * Calculate the latency based on the host time in UTC accounting for * the time covered using the number of samples and sample rate; in * other words, the difference between the host time and the time of * the last sample in the specified Mini-SEED record. * * Double precision is returned, but the true precision is dependent * on the accuracy of the host system clock among other things. * * Returns seconds of latency or 0.0 on error (indistinguishable from * 0.0 latency). ***************************************************************************/doublemsr_host_latency (MSRecord *msr){  double span = 0.0;            /* Time covered by the samples */  double epoch;                 /* Current epoch time */  double latency = 0.0;  time_t tv;  if ( msr == NULL )    return 0.0;    /* Calculate the time covered by the samples */  if ( msr->samprate > 0.0 && msr->samplecnt > 0 )    span = (1.0 / msr->samprate) * (msr->samplecnt - 1);    /* Grab UTC time according to the system clock */  epoch = (double) time(&tv);    /* Now calculate the latency */  latency = epoch - ((double) msr->starttime / HPTMODULUS) - span;    return latency;} /* End of msr_host_latency() */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -