// New station list from a glob structure stations *newStationList(glob_t *glb) { stations *ss; int j, file; ss = malloc(sizeof(stations)); ss->n = 0; ss->slist = NULL; /* Prepare stations table */ for (j = 0; j < glb->gl_pathc; j++) { glob_t *glbs = filelist(glb->gl_pathv[j], "*Z.SAC"); for (file = 0; file < glbs->gl_pathc; file++) { station *s = loadStation(glbs->gl_pathv[file]); int Id = getStationId(ss, s->name, s->net); if (Id == -1) { addss(ss, s); } else { killStation(s); } } glbs = killGlob(glbs); } qsort(&ss->slist[0], ss->n, sizeof(ss->slist[0]), cmpstation); return ss; }
// New event list from a glob events *newEventList(glob_t *glb, stations * ss) { events *evs; int j, file; evs = malloc(sizeof(events)); evs->n = 0; evs->elist = NULL; /* Make event list */ for (j = 0; j < glb->gl_pathc; j++) { glob_t *glbs = filelist(glb->gl_pathv[j],"*Z.SAC"); if (collectorVerbose) fprintf(stdout, "%s: [ ] [ ] ", glb->gl_pathv[j]); event *ev = NULL; for (file = 0; file < glbs->gl_pathc; file++) { if (file == 0) { ev = loadEvent(glbs->gl_pathv[file]); if (ev == NULL) { fprintf(stderr, "Could not get event.\n"); exit(-1); } } pick *p = loadPick(glbs->gl_pathv[file], ss); if (p != NULL) { addpick(ev, p); if (collectorVerbose) fprintf(stdout, "."); } else { if (collectorVerbose) fprintf(stdout, "x"); } } if (ev->n != 0) { addev(evs, ev); if (collectorVerbose) fprintf(stdout, "\r%s: [A] [%03d] \n", glb->gl_pathv[j], ev->n); } else { killEvent(ev); if (collectorVerbose) fprintf(stdout, "\r%s: [D] [%03d] \n", glb->gl_pathv[j], ev->n); } glbs = killGlob(glbs); } calculateEventMean(evs); calculateResiduals(evs); return evs; }
glob_t * io_loadEv(defs *d) { // If data is loaded free it up if (d->nfiles != 0) { tffree(d->files, d->nfiles); d->files = NULL; d->nfiles = 0; d->has3 = 0; } // Prepare the pathname for the current event char *path = d->glb->gl_pathv[d->currentdir]; // Prepare a new glob glob_t *glb = filelist(path, getConfigAsString(config, NAME_Z, DEFAULT_Z)); glob_t *glbt =filelist(path, getConfigAsString(config, NAME_T, DEFAULT_T)); // Set HAS to 0 d->has = findHas(glb); // Load the Z components int nfiles = 0; tf *files = io_loadZ(glb, &nfiles); if (getConfigAsBoolean(config, NAME_LOAD, DEFAULT_LOAD)) { // Load N components glob_t *glbn = filelist(path, getConfigAsString(config, NAME_N, DEFAULT_N)); io_loadN(glbn, files, nfiles); killGlob(glbn); // Load E glob_t *glbe = filelist(path, getConfigAsString(config, NAME_E, DEFAULT_E)); io_loadE(glbe, files, nfiles); killGlob(glbe); // Load R components glob_t *glbr = filelist(path, getConfigAsString(config, NAME_R, DEFAULT_R)); io_loadR(glbr, files, nfiles); killGlob(glbr); // Load T glob_t *glbt = filelist(path, getConfigAsString(config, NAME_T, DEFAULT_T)); io_loadT(glbt, files, nfiles); d->has3 = 1; } // Find the filters in use for this event if (getConfigAsNumber(config, NAME_PICK, DEFAULT_PICK) == P) d->filter = findFilters(glb, &d->lp, &d->hp); else if (getConfigAsNumber(config, NAME_PICK, DEFAULT_PICK) == S) d->filter = findFilters(glbt, &d->lp, &d->hp); else { sprintf(message, " filters used couldn't be loaded "); alert(WARNING); } //kill globs killGlob(glb); killGlob(glbt); // Check the files if (nfiles != 0) { // Check that we have picks checkTREF(files, nfiles); // Sort the files qsort(files, nfiles, sizeof(tf), sortDist); // Synch Time synch(files, nfiles); } // Set Aligmenmode d->alig = (d->has) ? ALIGF : ALIGA; // Set the filterneed if needed if (d->filter) d->needfilter = 1; // Set offset to 0 d->offset = 0; // Prepare to return d->files = files; d->nfiles = nfiles; // Adjust the curent pointer io_AdjustCurrent(d); // Done return NULL; }