📄 rdseed.c
字号:
p = strtok(network_list," ,"); if (p == NULL) { ignore_net_codes = TRUE; /* maybe not needed, but ... */ network_point[network_count++] = "??"; } else while(p != NULL) { network_point[network_count] = p; if (strcmp(network_point[network_count], "??") == 0) { ignore_net_codes = TRUE; } network_count++; p = strtok(NULL," ,"); } printf("Loc Ids (ALL [\"--\" for spaces])\t: "); fflush(stdout); if (fgets(location_list, sizeof(location_list), stdin) == NULL) exit(0); NO_NL(location_list); location_count = 0; p = strtok(location_list," ,"); if (p == NULL) { /* maybe not needed, but ... */ ignore_loc_codes = TRUE; location_point[location_count++] = "??"; } else while(p != NULL) { if (strcmp(p, "--") == 0) location_point[location_count] = ""; else location_point[location_count] = p; strupr(location_point[location_count]); if (strcmp(location_point[location_count], "??") == 0) { ignore_loc_codes = TRUE; } location_count++; p = strtok(NULL," ,"); } if (Output_PnZs) { if (output_pipe) outputfile = popen("more", "w"); return; } if (stations_flag||event_flag|| ex_stn_flag||outresp_flag||outresp_old_flag) /* bale here */ { if (stations_flag) { char ch = 0, xch; printf("Output poles & zeroes ? [Y/(N)]"); fflush(stdout); while (xch != '\n') { xch = getchar(); if (xch != '\n') ch = xch; } ch = toupper(ch); if (ch == 'Y') Output_PnZs = TRUE; printf("Extract Responses [Y/(N)] : "); fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit(0); NO_NL(buffer); if (toupper(*buffer) == 'Y') outresp_flag = TRUE; else outresp_flag = FALSE; } if (output_pipe) outputfile = popen("more", "w"); return; } } /* if not read_summary_flag */ if (!comments_flag) { printf("Output Format [(1=SAC), 2=AH, 3=CSS, 4=mini seed, 5=seed, 6=sac ascii, 7=SEGY] : "); fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit(0); NO_NL(buffer); i = sscanf(buffer,"%d",&output_format); if (i == 0) output_format = 1; /* default to sac */ /* decrement user input to start at zero */ output_format--; if ((output_format < 0) || (output_format > 6)) output_format = 0; if (output_format == 3) mini_flag = TRUE; /* set for mini seed */ if (output_format == 4) { /* removes files perhaps left behind */ clean_up_output_seed(); Seed_flag = TRUE; /* set for new seed */ } if (from_weed && (WeedVersion < 2.0)) { /* bale here for earlier versions of weed */ if (output_pipe) outputfile = popen("more", "w"); return; } if (output_format == 0) /* SAC - ask for poles and zeroes output */ { char ch = 0, xch; printf("Output poles & zeroes ? [Y/(N)]"); fflush(stdout); while (xch != '\n') { xch = getchar(); if (xch != '\n') ch = xch; } ch = toupper(ch); if (ch == 'Y') Output_PnZs = TRUE; } if (mini_flag || Seed_flag) { char ch = 0, xch; printf("Strip out records with zero sample count? [Y/N]"); printf("? [Y/N]"); fflush(stdout); while (xch != '\n') { xch = getchar(); if (xch != '\n') ch = xch; } ch = toupper(ch); if (ch == 'Y' || ch == '\n') strip_flag = TRUE; } /* No reversal check for mini or seed output */ if (output_format != 3 && output_format != 4) { printf("Check Reversal [(0=No), 1=Dip.Azimuth, 2=Gain, 3=Both]: "); fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit(0); NO_NL(buffer); i = sscanf(buffer,"%d",&check_reverse); if (i = 0) check_reverse = 0; if ((check_reverse < 0) || (check_reverse > 3)) check_reverse = 0; } /* ask for Quality option */ printf("Select Data Type [(E=Everything), D=Data of Undetermined State, R=Raw waveform Data, Q=QC'd data] :"); if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit(0); NO_NL(buffer); *buffer = toupper(*buffer); if (strlen(buffer) == 0) { q_flag = 'E'; } switch (*buffer) { case('D') : q_flag = 'D'; break; case('R') : q_flag = 'R'; break; case('Q') : q_flag = 'Q'; break; default : q_flag = 'E'; break; } /* switch */ } /* if not comments_flag */ if (!read_summary_flag) { printf("Start Time(s) YYYY,DDD,HH:MM:SS.FFFF : "); fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit (0); NO_NL(buffer); buffer[strlen(buffer)+1] = '\0'; p = malloc (strlen(buffer)+1); strcpy(p,buffer); i = 0; p2 = strtok(p," "); while(p2 != NULL) { i++; p2 = strtok(NULL," "); } start_time_count = 0; if (i == 0) { /* make a really small starting time */ start_time_point = (struct time *) malloc(sizeof(struct time)); start_time_point[0].year = 1900; start_time_count = 1; } else { start_time_point = (struct time *) malloc(sizeof(struct time)*i); p2 = strtok(buffer," "); while(p2 != NULL) { strcpy(p,p2); timecvt(&start_time_point[start_time_count], p); start_time_count++; /* this is needed because * timecvt calls strtok() */ p2 += (strlen(p2)+1); p2 = strtok(p2," "); } } free (p); printf("End Time(s) YYYY,DDD,HH:MM:SS.FFFF : "); fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit(0); NO_NL(buffer); buffer[strlen(buffer)+1] = '\0'; p = malloc (strlen(buffer)+1); strcpy(p,buffer); i = 0; p2 = strtok(p," "); while(p2 != NULL) { i++; p2 = strtok(NULL," "); } end_time_count = 0; if (i == 0) { end_time_point = (struct time *)malloc(sizeof(struct time)); /* I should be retired by then */ end_time_point[0].year = 9999; end_time_count = 1; } else { end_time_point = (struct time *) malloc(sizeof(struct time)*i); p2 = strtok(buffer," "); while(p2 != NULL) { strcpy(p,p2); timecvt(&end_time_point[end_time_count], p); end_time_count++; /* this is needed because * timecvt calls strtok() */ p2 += (strlen(p2)+1); p2 = strtok(p2," "); } } free (p); if (((start_time_point != NULL) || (end_time_point != NULL)) && (output_format == 4)) { /* warn user that time series boundaries * are rounded up and * down to the * nearest LRECL */ printf("Warning - output time series' will be will be rounded up and down to the nearest logical record boundary in the output seed volume.\n"); } } } if (data_flag) { printf("Sample Buffer Length [2000000]: "); fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit(0); NO_NL(buffer); i = sscanf(buffer,"%d",&seis_buffer_length); if (i == 0) seis_buffer_length = 2000000; if (!outresp_flag) { printf("Extract Responses [Y/(N)] : "); fflush(stdout); if (fgets(buffer, sizeof(buffer), stdin) == NULL) exit(0); NO_NL(buffer); if (toupper(*buffer) == 'Y') outresp_flag = TRUE; else outresp_flag = FALSE; } } if (output_pipe) outputfile = popen("more", "w");}/*===========================================================================*//* SEED reader | usage | subprocedure *//*===========================================================================*//* show usage of program */void usage (){ printf("Usage: rdseed -f inputfile -{a | d [list] | l | s | t}\n"); printf("\twhere inputfile = name of input file or device;\n"); printf("\t a = retrieve abbreviation dictionaries;\n"); printf("\t b = set the seismogram input buffer size (bytes);\n"); printf("\t c = retrieve volume table of contents;\n"); printf("\t C = retrieve the comments where arg is either STN or CHN;\n"); printf("\t d = read data from tape;\n"); printf("\t e = extract event/station data;\n"); printf("\t f = input filename;\n"); printf("\t g = alternate response file(s);\n"); printf("\t i = ignore location codes;\n"); printf("\t k = strip records from output which have a zero sample count. (miniseed and seed only);\n"); printf("\t l = list contents of each block in volume;\n"); printf("\t o = specify output format (1=SAC, 2=AH, 3=CSS, 4=MINISEED, 5=SEED [default=1]);\n"); printf("\t p = output poles and zeros;\n"); printf("\t q = specify the output directory;\n"); printf("\t Q = specify data type (E=Everything, D=Data of undetermined state, R=Raw waveform data, Q=QC'd data;\n"); printf("\t R = print response data;\n"); printf("\t s = retrieve all station header information;\n"); printf("\t S = retrieve station summary information;\n"); printf("\t t = show start/stop times, start blocks of events;\n"); printf("\t u = usage (this list);\n"); printf("\t v = select volume number;\n"); printf("\t x = use summary file;\n"); printf("\t z = check for reversals;\n");}/*=======================================================================*//* SEED reader | chk_station | main program *//*=======================================================================*//* see if station is in select list */int chk_station(station)char *station;{ int i, j; char buffer[200], *p; if (station_count == 0) return(TRUE); for (i=0;i<station_count;i++) { strupr(station_point[i]); if (wstrcmp(station,station_point[i],5) == 0) return(TRUE);/* look through alias strings */ for (j=0;j<alias_count;j++) { strcpy(buffer,alias_point[i]); p = strtok(buffer," ,"); if (p != NULL) { if (wstrcmp(p,station_point[i],5) == 0) { p = strtok(NULL," ,"); while (p != NULL) { if (wstrcmp(station,p,5) == 0) return(TRUE); p = strtok(NULL," ,"); } } } } } return(FALSE);}/*=======================================================================*//* SEED reader | chk_channel | main program *//*=======================================================================*//* see if channel is in select list */int chk_channel(channel)char *channel;{ int i; if (channel_count == 0) return(TRUE); for (i=0;i<channel_count;i++) { strupr(channel_point[i]); if (wstrcmp(channel, channel_point[i], 3) == 0) return(TRUE); } return(FALSE);}/*=======================================================================*//* SEED reader | chk_location | main program *//*=======================================================================*//* see if network is in select list */int chk_location(location)char *location;{ int i; char loc[3]; if (location_count == 0) return TRUE; if (ignore_loc_codes) return TRUE; strncpy(loc, location, 2); /* sizeof location code */ loc[2] = 0; if (isalnum(loc[0]) && (loc[1] == ' ')) loc[1] = 0; if ((loc[0] == ' ') && (isalnum(loc[1]))) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -