📄 output_ah.c
字号:
memset(wrkstr, 0, sizeof(wrkstr)); /* recover current event from summary file */ strncpy(wrkstr, summary_file_get_event(), 511); /* skip the source */ p = strtok(wrkstr, ","); /* date and time */ p = strtok(NULL, "/"); if (p == NULL) p = ""; hed.event.ot.yr = atoi(p); p = strtok(NULL, "/"); if (p == NULL) p = ""; hed.event.ot.mo = atoi(p); p = strtok(NULL, " "); if (p == NULL) p = ""; hed.event.ot.day = atoi(p); /* hour:minute:second.frac */ p = strtok(NULL, ":"); if (p == NULL) p = ""; hed.event.ot.hr = atoi(p); /* minute */ p = strtok(NULL, ":"); if (p == NULL) p = ""; hed.event.ot.mn = atoi(p); /* seconds */ p = strtok(NULL, ","); if (p == NULL) p = ""; hed.event.ot.sec = atof(p); /* lat and long */ p = strtok(NULL, ","); /* latitiude */ if (p == NULL) p = ""; hed.event.lat = atof(p); p = strtok(NULL, ","); /* longitude */ if (p == NULL) p = ""; hed.event.lon = atof(p); p = strtok(NULL, ","); /* depth */ if (p == NULL) p = ""; hed.event.dep = atof(p); } else if (type71_head != NULL) { hed.event.lat= type71_head->latitude; hed.event.lon= type71_head->longitude; hed.event.dep= type71_head->depth; /* convert date/time from YYYYDDD... to MM/DD/YYYY */ strcpy(wrkstr, type71_head->origin_time); /* peal off the year */ p = strtok(wrkstr, ","); if (p == NULL) p = ""; else y = atoi(p); /* peal off the day of year */ p = strtok(NULL, ","); if (p == NULL) p = ""; ddd = atoi(p); /* go ahead and extract the time from wrkstr */ /* hour */ p = strtok(NULL, ":"); if (p == NULL) p = ""; hed.event.ot.hr = atoi(p); /* minute */ p = strtok(NULL, ":"); if (p == NULL) p = ""; hed.event.ot.mn = atoi(p); /* seconds */ p = strtok(NULL, ","); if (p == NULL) p = ""; hed.event.ot.sec = atof(p); /* start over with new string */ strcpy(wrkstr, ddd2mmdd(ddd, y)); /* MM/DD/YYYY */ p = strtok(wrkstr, "/"); if (p == NULL) p = ""; hed.event.ot.mo = atoi(p); /* day */ p = strtok(NULL, "/"); if (p == NULL) p = ""; hed.event.ot.day = atoi(p); /* year */ p = strtok(NULL, "/"); if (p == NULL) p = ""; hed.event.ot.yr = atoi(p); } else { hed.event.lat=hed.event.lon=hed.event.dep=0.0; hed.event.ot.yr=hed.event.ot.mo=hed.event.ot.day=0; hed.event.ot.hr=hed.event.ot.mn=0; hed.event.ot.sec=0.0; } sprintf (outfile_name, "%04d.%03d.%02d.%02d.%02d.%04d.%s.%s.%s.%s.%c.AH", data_hdr->time.year, data_hdr->time.day, data_hdr->time.hour, data_hdr->time.minute, data_hdr->time.second, data_hdr->time.fracsec, data_hdr->network, data_hdr->station, data_hdr->location, channel, input.type); if ((outfile = fopen (outfile_name, "w")) == NULL) { fprintf (stderr,"\tWARNING (output_ah): "); fprintf (stderr,"Output file %s is not available for writing.\n",outfile_name); fprintf (stderr, "\tExecution continuing.\n"); perror("output_ah()"); chdir(orig_dir); return; } xdrstdio_create(&xdr_out, outfile, XDR_ENCODE); if (binary) { /* describe the file being written */ printf ("Writing %s: %s: %s: %s, %5d samples (binary),", data_hdr->network, data_hdr->station, data_hdr->location, channel, data_hdr->nsamples); printf (" starting %04d,%03d %02d:%02d:%02d.%04d UT\n", data_hdr->time.year,data_hdr->time.day, data_hdr->time.hour,data_hdr->time.minute, data_hdr->time.second,data_hdr->time.fracsec); j = k*(seis_buffer_length/data_hdr->num_mux_chan); if (reverse_flag) { char wrkstr[200]; for (i=0; i<data_hdr->nsamples; i++) seismic_data[offset+i+j] = -seismic_data[offset+i+j]; sprintf(wrkstr, "Data Reversal initiated for AH file %s", outfile_name); rdseed_alert_msg_out(wrkstr); } /* find max. amplitude */ ier = maxamp (&hed, &seismic_data[offset+j]); /* write ah header and data */ if(xdr_puthead(&hed, &xdr_out) != 1) { fprintf(stderr,"Error writing header in rdseed; output_ah\n"); perror("xdr_puthead"); exit(-3); } if(xdr_putdata(&hed, (char *)&seismic_data[offset+j], &xdr_out) < 0) { fprintf(stderr,"Error writing data in rdseed; output_ah\n"); perror("xdr_putdata"); exit(-3); } } xdr_destroy(&xdr_out); fclose (outfile); fflush(stdout); current_channel = current_channel->next; } chdir(orig_dir);#if 0 strcpy(channel,current_channel->channel); for (current_channel=current_channel->next; current_channel != NULL; current_channel=current_channel->next) if (strcmp(channel, current_channel->channel) == 0) break;#endif return;}void month_day(t, jul_day)register struct ah_time *t;int jul_day;{ int i, dim; t->day= jul_day; for (i= 0; i < 12; i ++) { dim= days_in_month[i]; if (isaleap(t->yr) && (i == 1)) dim++; if (t->day <= dim ) break; t->day-= dim; } t->mo= i+1; return;}char *get_type33 (code)int code;{ struct type33 *type33; for (type33 = type33_head; type33 != NULL; type33 = type33->next) { if (type33->code == code) { return(type33->abbreviation); break; } } if (type33 == NULL) return (NULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -