inseis.c 3.11 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1
/*-----------------------------------------------------------------------------------------
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 26 27 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
 *
 * 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>.
-----------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 *   Write seismograms to disk                                  
 *   last update 19/01/02, T. Bohlen
 *  ----------------------------------------------------------------------*/
#include "fd.h"
#include "segy.h"

void  inseis(FILE *fp, int comp, float **section, int ntr, int ns, int sws, int iter){

	/* declaration of extern variables */
	extern int NDT, MYID;
	extern char DATA_DIR[STRING_SIZE], SEIS_FILE_P[STRING_SIZE], SEIS_FILE_VX[STRING_SIZE];
	extern char SEIS_FILE_VY[STRING_SIZE];
	extern float  TIME, DH, DT, REFREC[4];
        char data[STRING_SIZE];
	const float xshift=800.0, yshift=800.0;
        FILE *fpdata;
	
	if(sws==1){  /* open seismic data vx */
		sprintf(data,"%s_x.su.shot%d",DATA_DIR,comp);
	}
	
	if(sws==2){  /* open seismic data vy */
		sprintf(data,"%s_y.su.shot%d",DATA_DIR,comp);
	}
	
	if(sws==3){ /* open forward modelled data vx*/
		sprintf(data,"%s.shot%d.%d",SEIS_FILE_VX,comp,MYID);
	}
	
	if(sws==4){ /* open forward modelled data vy*/
		sprintf(data,"%s.shot%d.%d",SEIS_FILE_VY,comp,MYID);
	}
	
	if(sws==5){ /* open old data residuals vx*/
		sprintf(data,"%s.shot%d_it-1.%d",SEIS_FILE_VX,comp,MYID);
	}
	
	if(sws==6){ /* open old data residuals vy*/
		sprintf(data,"%s.shot%d_it-1.%d",SEIS_FILE_VY,comp,MYID);
	}
	
	if(sws==7){  /* open convolved seismic data vx */
		sprintf(data,"%s_x.su.conv.shot%d",DATA_DIR,comp);
	}
	
	if(sws==8){  /* open convolved seismic data vy */
		sprintf(data,"%s_y.su.conv.shot%d",DATA_DIR,comp);
	}
	
	if(sws==9){  /* open seismic data p */
		sprintf(data,"%s_p.su.shot%d",DATA_DIR,comp);
	}
72 73 74 75
    
    if(sws==10){  /* open seismic data vz */
        sprintf(data,"%s_z.su.shot%d",DATA_DIR,comp);
    }
Tilman Steinweg's avatar
Tilman Steinweg committed
76
	
77
    
Tilman Steinweg's avatar
Tilman Steinweg committed
78 79 80
	/*printf("%s\n",data);*/
	
	fpdata = fopen(data,"r");
81
	if (fpdata==NULL) err(" Seismograms for inversion were not found ");
Tilman Steinweg's avatar
Tilman Steinweg committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

	/* declaration of local variables */
	int i,j;
	segy tr;
	int tracl1 ;
	float xr, yr, x, y, dump;

		for(tracl1=1;tracl1<=ntr;tracl1++){        /* SEGY (without file-header) */
                        
			fread(&tr,240,1,fpdata);
			fread(&tr.data,4,ns,fpdata);
			
			section[tracl1][1]=0.0;
			
			  
			for(j=1;j<=ns;j++){
				dump=tr.data[j];
				section[tracl1][j+1]=dump;
			}
		}
	fclose(fpdata);
}