#include #include #include #include #include"sac.h" #define DATA 36000 main(argc, argv) int argc; char *argv[]; { char wname[30], com[20], c[20]; long spoint, epoint,pp,i,j,k,mon,day; float ud[DATA], ns[DATA], ew[DATA]; FILE *f1, *f2; struct sac sach; sach = sac_null; fprintf(stderr, "Please input station name\n"); scanf("%s",com); if((f2=fopen(argv[1],"r"))==NULL){ fprintf(stderr,"file format err !!! <<%s: ascii.sac.file>>\n", argv[1]); exit(-1); } fprintf(stderr, "Please input data start year mon day hour min sec\n"); scanf("%ld %ld %ld %ld %ld %ld", &sach.nzyear, &mon, &day, &sach.nzhour,&sach.nzmin, &sach.nzsec); to_jday( sach.nzyear, mon, day, &sach.nzjday); fprintf(stderr, "Set sampling delta\n"); scanf("%f", &sach.delta); fprintf(stderr, "Set start point of your making data \n"); scanf("%ld", &spoint); fprintf(stderr, "Set total point of your making data \n"); scanf("%ld", &epoint); for(pp=0; pp > \n",f); exit(1); } fwrite( sach, sizeof(struct sac), 1, f1); fwrite( data , sach->npts * sizeof (float), 1, f1); fclose(f1); } convert_data( sach, dhead, ihead, chead, data) float dhead[], data[]; long ihead[]; char chead[]; struct sac sach; { /* sach = sac_null; */ sach.delta = dhead[0]; sach.depmin = dhead[1]; sach.depmax = dhead[2]; sach.scale = dhead[3]; sach.odelta = dhead[4]; sach.b = dhead[5]; sach.e = dhead[6]; sach.o = dhead[7]; sach.a = dhead[8]; sach.internal1 = dhead[9]; sach.t0 = dhead[10]; sach.t1 = dhead[11]; sach.t2 = dhead[12]; sach.t3 = dhead[13]; sach.t4 = dhead[14]; sach.t5 = dhead[15]; sach.t6 = dhead[16]; sach.t7 = dhead[17]; sach.t8 = dhead[18]; sach.t9 = dhead[19]; sach.f = dhead[20]; sach.resp0 = dhead[21]; sach.resp1 = dhead[22]; sach.resp2 = dhead[23]; sach.resp3 = dhead[24]; sach.resp4 = dhead[25]; sach.resp5 = dhead[26]; sach.resp6 = dhead[27]; sach.resp7 = dhead[28]; sach.resp8 = dhead[29]; sach.resp9 = dhead[30]; sach.stla = dhead[31]; sach.stlo = dhead[32]; sach.stel = dhead[33]; sach.stdp = dhead[34]; sach.evla = dhead[35]; sach.evlo = dhead[36]; sach.evel = dhead[37]; sach.evdp = dhead[38]; sach.unused1= dhead[39]; sach.user0 = dhead[40]; sach.user1 = dhead[41]; sach.user2 = dhead[42]; sach.user3 = dhead[43]; sach.user4 = dhead[44]; sach.user5 = dhead[45]; sach.user6 = dhead[46]; sach.user7 = dhead[47]; sach.user8 = dhead[48]; sach.user9 = dhead[49]; sach.dist = dhead[50]; sach.az = dhead[51]; sach.baz = dhead[52]; sach.gcarc = dhead[53]; sach.internal2 = dhead[54]; sach.internal3 = dhead[55]; sach.depmen = dhead[56]; sach.cmpaz = dhead[57]; sach.cmpinc = dhead[58]; sach.unused2= dhead[59]; sach.unused3= dhead[60]; sach.unused4= dhead[61]; sach.unused5= dhead[62]; sach.unused6= dhead[63]; sach.unused7= dhead[64]; sach.unused8= dhead[65]; sach.unused9= dhead[66]; sach.unused10 = dhead[67]; sach.unused11 = dhead[68]; sach.unused12 = dhead[69]; sach.nzyear = ihead[0]; sach.nzjday = ihead[1]; sach.nzhour = ihead[2]; sach.nzmin = ihead[3]; sach.nzsec = ihead[4]; sach.nzmsec = ihead[5]; sach.internal4 = ihead[6]; sach.internal5 = ihead[7]; sach.internal6 = ihead[8]; sach.npts = ihead[9]; sach.internal7 = ihead[10]; sach.internal8 = ihead[11]; sach.unused3 = ihead[12]; sach.unused4 = ihead[13]; sach.unused5 = ihead[14]; sach.iftype = ihead[15]; sach.idep = ihead[16]; sach.iztype = ihead[17]; sach.unused6 = ihead[18]; sach.iinst = ihead[19]; sach.istreg = ihead[20]; sach.ievreg = ihead[21]; sach.ievtyp = ihead[22]; sach.iqual = ihead[23]; sach.isynth = ihead[24]; sach.unused17= ihead[25]; sach.unused18= ihead[26]; sach.unused19= ihead[27]; sach.unused20= ihead[28]; sach.unused21= ihead[29]; sach.unused22= ihead[30]; sach.unused23= ihead[31]; sach.unused24= ihead[32]; sach.unused25= ihead[33]; sach.unused26= ihead[34]; sach.leven = ihead[35]; sach.lpspol = ihead[36]; sach.lovrok = ihead[37]; sach.lcalda = ihead[38]; sach.unused27= ihead[39]; /* strcpy (sach.kstnm, chead); wsac( chead, sach, data); */ }