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

📄 times_data.c

📁 解吸SEED格式的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	if ((input_data_hdr->activity_flags & 0x02) == 0)	{		this_time.fracsec += input_data_hdr->number_time_corrections;		while ((this_time.fracsec >= 10000) || (this_time.fracsec < 0)) {		if (this_time.fracsec >= 10000)		{			this_time.second += this_time.fracsec/10000;			this_time.fracsec = this_time.fracsec%10000;			if (this_time.second >= 60)			{				this_time.minute += this_time.second/60;				this_time.second = this_time.second%60;				if (this_time.minute >= 60)				{					this_time.hour += this_time.minute/60;					this_time.minute = this_time.minute%60;					if (this_time.hour >= 24)					{						this_time.day += this_time.hour/24;						this_time.hour = this_time.hour%24;						if (this_time.day > (isaleap(this_time.year) ? 366 : 365))						{							this_time.year += 1;							this_time.day = 1;						}					}				}			}		}		else if (this_time.fracsec < 0)		{			this_time.second -= 1;			this_time.fracsec += 10000;			if (this_time.second < 0)			{				this_time.minute -= 1;				this_time.second += 60;				if (this_time.minute < 0)				{					this_time.hour -= 1;					this_time.minute += 60;					if (this_time.hour < 0)					{						this_time.day -= 1;						this_time.hour += 24;						if (this_time.day == 0)						{							this_time.year -= 1;							this_time.day = (isaleap(this_time.year) ? 366 : 365);						}					}				}			}		}		}/*		printf("%02d:%02d:%02d.%05d\n", this_time.hour, this_time.minute, this_time.second, this_time.fracsec);  */	}	{	struct time effective_start, effective_end;	/* response effective times */	current_station = NULL;	current_channel = NULL;        /* find the current station information in the tables */        for (p_station = type50_head;                p_station != NULL;                p_station = p_station->next)                if (strcmp (this_station, p_station->station) == 0)			{			timecvt(&effective_start, p_station->start);			timecvt(&effective_end, p_station->end);			if (p_station->end == NULL) effective_end.year = 9999;			if ((timecmp(this_time, effective_start) >= 0) &&				(timecmp(this_time, effective_end) <= 0))					current_station = p_station;        /* find the current channel within the current station */	                for (p_channel = p_station->type52_head;         		       	p_channel != NULL;                		p_channel = p_channel->next)                		if ((strcmp(this_channel, 					   p_channel->channel) == 0) &&					(strcmp(this_location, 						p_channel->location) == 0))					{						timecvt(&effective_start, p_channel->start);						timecvt(&effective_end, p_channel->end);						if (p_channel->end == NULL) effective_end.year = 9999;						if ((timecmp(this_time, effective_start) >= 0) &&							(timecmp(this_time, effective_end) <= 0))						{							current_channel = p_channel;							break;						}					}			}                      if (current_station == NULL) /* station was not found */        	{                	fprintf (stderr, "WARNING (process_data):  ");                	fprintf (stderr, "station %s ",                        this_station); 						timeprt(this_time);                	fprintf (stderr, " - response effective time not found.\n",                        this_station);               	fprintf (stderr, "\tData Record Skipped.\n");			return;        	}	if (current_channel == NULL) /* channel was not found */                {                        fprintf (stderr, "WARNING (process_data):  ");                        fprintf (stderr, "%s,%s ", this_station, this_channel);						timeprt(this_time);                        fprintf (stderr, " - response effective time not found.\n",                                this_station);                        fprintf (stderr, "\tData Record Skipped.\n");			return;                }	}/*                 +=======================================+                 *//*=================| accumulate various descriptive info   |=================*//*                 +=======================================+                 *//*                 +=======================================+                 *//*=================|          determine continuity         |=================*//*                 +=======================================+                 */	/* determine whether this is station-, channel-, and time-continuous */	/* with previous data block *//*	if (timeqc (last_time, this_time, last_nsamples, last_sample_rate) == 0) */	if (timetol (newtime, this_time, last_nsamples) == 0)		continuous = TRUE;	else 		continuous = FALSE;	if (!(strcmp(this_station, prev_station) == 0) && (strcmp(prev_station, "XXXXX") != 0))		continuous = FALSE;	if (!(strcmp(this_channel, prev_channel) == 0) && (strcmp(prev_channel, "XXXXX") != 0))         	continuous = FALSE;	if ((strcmp(this_location, prev_location) != 0) && 			(strcmp(prev_location, "XXXXX") != 0))		continuous = FALSE;	strcpy(prev_station, this_station);	strcpy(prev_channel, this_channel);	strcpy(prev_location, this_location);	/* figure out current display ending time of previous seismogram */	if (last_sample_rate != 0)	{		duration = (int)((double)((last_nsamples-1) * 10000) / (double)last_sample_rate);	}	else 	{		duration = 0;		last_time.year = 0;		last_time.day = 0;		last_time.hour = 0;		last_time.minute = 0;		last_time.second = 0;		last_time.fracsec = 0;	}	newtime = timeadd (last_time, duration);	/* save information for next time around (continuity check) */	last_time.year    = (int) this_time.year;	last_time.day     = (int) this_time.day;	last_time.hour    = (int) this_time.hour;	last_time.minute  = (int) this_time.minute;	last_time.second  = (int) this_time.second;	last_time.fracsec = (int) this_time.fracsec;	temp_u2byte        = input_data_hdr->nsamples;	last_nsamples     = (int) temp_u2byte;	/* get sample rate */	temp_2byte = input_data_hdr->sample_rate;	last_sample_rate = (float) temp_2byte;	temp_2byte = input_data_hdr->sample_rate_multiplier;	tempint = (int) temp_2byte;	if (last_sample_rate < 0) 		last_sample_rate = 1/(-last_sample_rate);	if (tempint > 0) 		last_sample_rate = last_sample_rate * tempint;	else if (tempint < 0) 		last_sample_rate = last_sample_rate / (-tempint);	parse_type100(input_data_ptr, &last_sample_rate);/*	printf ("%4d,%03d,%02d:%02d:%02d.%04d  %d\n", 		this_time.year, this_time.day, this_time.hour, this_time.minute,		this_time.second, this_time.fracsec, last_nsamples); */	}	else	{		continuous = FALSE;		if (last_sample_rate != 0)		{			duration = (int)((double)((last_nsamples-1) * 10000) / (double)last_sample_rate);		}		else 		{			duration = 0;			last_time.year = 0;			last_time.day = 0;			last_time.hour = 0;			last_time.minute = 0;			last_time.second = 0;			last_time.fracsec = 0;		}		newtime = timeadd (last_time, duration);	}		if (continuous)	{		total_samples += (long int) last_nsamples;	}	else /* if (!(continuous) && (this_time.year != 0)) */	{		strcpy(prev_station, "XXXXX");  /* set for new time span */		strcpy(prev_channel, "XXXXX");  /* Same here! */		strcpy(prev_location, "XXXXX");		if (start_record != 0)		{			if (sample_rate_count) sample_rate_accum = sample_rate_accum/sample_rate_count;			else sample_rate_accum = sample_rate;			fprintf (outputfile,"%4d,%03d,%02d:%02d:%02d.%04d ", 				newtime.year, newtime.day, newtime.hour, newtime.minute,				newtime.second, newtime.fracsec);			fprintf (outputfile,"%11.7f ", sample_rate);			fprintf (outputfile,"%6d", total_samples);			fprintf (outputfile,"\n");			sample_rate_accum = 0.0;			sample_rate_count = 0;		}/*** Added by Sue to fix (I hope) incorrect display of record numbers ***/		if (!call_type)		{			start_record = input.recordnumber;			fprintf(outputfile,"%6ld ", start_record);			fprintf(outputfile,"%-5s ", this_station);			fprintf(outputfile,"%-3s ", this_channel);			fprintf(outputfile,"%-2s ", this_network);			fprintf(outputfile, " %-2.2s ", this_location);			fprintf (outputfile,"%4d,%03d,%02d:%02d:%02d.%04d ", 				this_time.year, this_time.day, this_time.hour, this_time.minute,				this_time.second, this_time.fracsec);			total_samples = last_nsamples;			start_record = input.recordnumber;			sample_rate = last_sample_rate;			first_time = this_time;		}	}}

⌨️ 快捷键说明

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