time_window.c 2.9 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1
/*-----------------------------------------------------------------------------------------
Florian Wittkamp's avatar
Florian Wittkamp committed
2
 * Copyright (C) 2016  For the list of authors, see file AUTHORS.
Tilman Steinweg's avatar
Tilman Steinweg committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * 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"

26
void time_window(float **sectiondata, float *picked_times, int iter, int ntr_glob, int **recpos_loc, int ntr, int ns, int ishot){
Tilman Steinweg's avatar
Tilman Steinweg committed
27

28 29
	/* declaration of variables */
	extern float DT;
30
	extern int REC1, REC2, MYID;
31 32
	extern float GAMMA, TWLENGTH_PLUS, TWLENGTH_MINUS;
	extern char PICKS_FILE[STRING_SIZE];
33
	int READ_PICKED_TIMES;
34
	char pickfile_char[STRING_SIZE];
35 36
	float time, dump, dump1, taper, taper1;
	float *pick_tmp;
37 38 39 40
	int i, j, h;

	FILE *fptime;

41 42 43 44
	READ_PICKED_TIMES=1; /*other options?*/

	/* read picked first arrival times */
	if(READ_PICKED_TIMES==1){
45
		pick_tmp = vector(1,ntr_glob);
46 47 48 49 50 51
		
		sprintf(pickfile_char,"%s_%i.dat",PICKS_FILE,ishot);
		
		fptime=fopen(pickfile_char,"r");
		if (fptime == NULL) {
			err(" picks_?.dat could not be opened !");
52
		}
53
		
54 55 56 57
		for(i=1;i<=ntr_glob;i++){
			fscanf(fptime,"%f",&dump);
			pick_tmp[i] = dump;
		}
58 59 60 61 62
		
		fclose(fptime);
		
		/* distribute picks on CPUs */
		h=1;
63 64
		for(i=1;i<=ntr;i++){
			picked_times[h] = pick_tmp[recpos_loc[3][i]];
65
			
66 67 68
			/*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]);*/
			
69 70
			h++;
		}
71
		
72
		free_vector(pick_tmp,1,ntr_glob);
73 74 75 76 77
		
	} /* end of if(READTIMES==1) */

	for(i=1;i<=ntr;i++){
	for(j=2;j<=ns;j++){
78
	
79
		time = (float)(j * DT);
80
		
81 82
		dump = (time-picked_times[i]-TWLENGTH_PLUS);
		taper = exp(-GAMMA*dump*dump);
83
		
84 85 86 87 88 89 90 91 92 93 94 95
		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];
		
	}     
96
	}
97

Tilman Steinweg's avatar
Tilman Steinweg committed
98
} /* end of function time_window.c */