time_window.c 2.9 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*-----------------------------------------------------------------------------------------
 * Copyright (C) 2013  For the list of authors, see file AUTHORS.
 *
 * This file is part of DENISE.
 * 
 * DENISE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.0 of the License only.
 * 
 * DENISE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DENISE. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 *   Apply time damping (after Brossier (2009))                                 
 *   last update 31/08/11, D.Koehn
 *   modified    02/02/12, S.Heider
 *  ----------------------------------------------------------------------*/
#include "fd.h"

void time_window(float **sectiondata, float *picked_times, int iter, int ntr_glob, int **recpos_loc, int ntr, int ns, int ishot){

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
	/* declaration of variables */
	extern float DT;
	extern int REC1, REC2, MYID;
	extern float GAMMA, TWLENGTH_PLUS, TWLENGTH_MINUS;
	extern char PICKS_FILE[STRING_SIZE];
	int READ_PICKED_TIMES;
	char pickfile_char[STRING_SIZE];
	float time, dump, dump1, taper, taper1;
	float *pick_tmp;
	int i, j, h;

	FILE *fptime;

	READ_PICKED_TIMES=1; /*other options?*/

	/* read picked first arrival times */
	if(READ_PICKED_TIMES==1){
		pick_tmp = vector(1,ntr_glob);
		
		sprintf(pickfile_char,"%s_%i.dat",PICKS_FILE,ishot);
		
		fptime=fopen(pickfile_char,"r");
		if (fptime == NULL) {
			err(" picks_?.dat could not be opened !");
		}
		
		for(i=1;i<=ntr_glob;i++){
			fscanf(fptime,"%f",&dump);
			pick_tmp[i] = dump;
		}
		
		fclose(fptime);
		
		/* distribute picks on CPUs */
		h=1;
		for(i=1;i<=ntr;i++){
			picked_times[h] = pick_tmp[recpos_loc[3][i]];
			
			/*printf("MYID IS: %i REC1 is= %i REC2 is %i\n",MYID, REC1, REC2);
			printf("MYID= %i     pick_tmp[%i]= %f\n",MYID, i,pick_tmp[i]);*/
			
			h++;
		}
		
		free_vector(pick_tmp,1,ntr_glob);
		
	} /* end of if(READTIMES==1) */

	for(i=1;i<=ntr;i++){
	for(j=2;j<=ns;j++){
	
		time = (float)(j * DT);
		
		dump = (time-picked_times[i]-TWLENGTH_PLUS);
		taper = exp(-GAMMA*dump*dump);
		
		dump1 = (time-picked_times[i]+TWLENGTH_MINUS); 
		taper1 = exp(-GAMMA*dump1*dump1);
		
		if(time>=picked_times[i]+TWLENGTH_PLUS){
		sectiondata[i][j] = sectiondata[i][j] * taper;}
		
		if(time<=picked_times[i]-TWLENGTH_MINUS){
		sectiondata[i][j] = sectiondata[i][j] * taper1;}
		
		sectiondata[i][j] = sectiondata[i][j];
		
	}     
	}
Tilman Steinweg's avatar
Tilman Steinweg committed
97 98

} /* end of function time_window.c */