Commit 2a316380 authored by niklas.thiel's avatar niklas.thiel

wavefield seperation added

parent 94121d66
...@@ -65,6 +65,13 @@ ...@@ -65,6 +65,13 @@
"XREC2, YREC2" : "93.0 , 0.2", "XREC2, YREC2" : "93.0 , 0.2",
"NGEOPH" : "80", "NGEOPH" : "80",
"Wavefield Separation" : "comment",
"WAVESEP" : "0",
"VEL" : "1500.0",
"DENS" : "1000.0",
"ANGTAPI" : "0.0",
"ANGTAPO" : "70.0",
"Seismograms" : "comment", "Seismograms" : "comment",
"NDT" : "1", "NDT" : "1",
"SEIS_FORMAT" : "1", "SEIS_FORMAT" : "1",
......
...@@ -65,6 +65,14 @@ ...@@ -65,6 +65,14 @@
"XREC2, YREC2" : "93.0 , 0.2", "XREC2, YREC2" : "93.0 , 0.2",
"NGEOPH" : "80", "NGEOPH" : "80",
"Wavefield Separation" : "comment",
"WAVESEP" : "0",
"VEL" : "1500",
"DENS" : "1000",
"ANGTAPI" : "0",
"ANGTAPO" : "70",
"Seismograms" : "comment", "Seismograms" : "comment",
"NDT" : "1", "NDT" : "1",
"SEIS_FORMAT" : "1", "SEIS_FORMAT" : "1",
......
...@@ -699,21 +699,17 @@ int main(int argc, char **argv){ ...@@ -699,21 +699,17 @@ int main(int argc, char **argv){
fulldata_curl = matrix(1,ntr_glob,1,NT); fulldata_curl = matrix(1,ntr_glob,1,NT);
break; break;
case 5 : /* everything except curl and div*/ case 5 : /* everything except curl and div*/
switch (WAVETYPE) { if (WAVETYPE==1) {
case 1:
fulldata_vx = matrix(1,ntr_glob,1,NT); fulldata_vx = matrix(1,ntr_glob,1,NT);
fulldata_vy = matrix(1,ntr_glob,1,NT); fulldata_vy = matrix(1,ntr_glob,1,NT);
break; }
if (WAVETYPE==2) {
case 2:
fulldata_vz = matrix(1,ntr_glob,1,NT); fulldata_vz = matrix(1,ntr_glob,1,NT);
break; }
if (WAVETYPE==3) {
case 3:
fulldata_vx = matrix(1,ntr_glob,1,NT); fulldata_vx = matrix(1,ntr_glob,1,NT);
fulldata_vy = matrix(1,ntr_glob,1,NT); fulldata_vy = matrix(1,ntr_glob,1,NT);
fulldata_vz = matrix(1,ntr_glob,1,NT); fulldata_vz = matrix(1,ntr_glob,1,NT);
break;
} }
fulldata_p = matrix(1,ntr_glob,1,NT); fulldata_p = matrix(1,ntr_glob,1,NT);
break; break;
...@@ -1442,7 +1438,18 @@ int main(int argc, char **argv){ ...@@ -1442,7 +1438,18 @@ int main(int argc, char **argv){
} }
catseis(sectionp, fulldata_p, recswitch, ntr_glob, MPI_COMM_WORLD); catseis(sectionp, fulldata_p, recswitch, ntr_glob, MPI_COMM_WORLD);
if (MYID==0) saveseis_glob(FP,fulldata_vx,fulldata_vy,fulldata_vz,fulldata_p,fulldata_curl,fulldata_div,recpos,recpos_loc,ntr_glob,srcpos,ishot,ns,iter,1); if (MYID==0) saveseis_glob(FP,fulldata_vx,fulldata_vy,fulldata_vz,fulldata_p,fulldata_curl,fulldata_div,recpos,recpos_loc,ntr_glob,srcpos,ishot,ns,iter,1);
/* wavefield separation*/
if (WAVESEP==1) {
if (MYID == 0) {
fprintf(FP,"\n Testposition 0 \n");
pup(fulldata_p, fulldata_vz, FP, ntr_glob,recpos,recpos_loc,ntr_glob,srcpos,ishot,ns,iter,1);
}
/* overwrite sectionp with pup data */
inseis(fprec,ishot,sectionp,ntr_glob,ns,3,iter);
}
break; break;
} /* end of switch (SEISMO) */ } /* end of switch (SEISMO) */
...@@ -1985,7 +1992,15 @@ int main(int argc, char **argv){ ...@@ -1985,7 +1992,15 @@ int main(int argc, char **argv){
catseis(sectionvz, fulldata_vz, recswitch, ntr_glob, MPI_COMM_WORLD); catseis(sectionvz, fulldata_vz, recswitch, ntr_glob, MPI_COMM_WORLD);
} }
catseis(sectionp, fulldata_p, recswitch, ntr_glob, MPI_COMM_WORLD); catseis(sectionp, fulldata_p, recswitch, ntr_glob, MPI_COMM_WORLD);
if (MYID==0) saveseis_glob(FP,fulldata_vx,fulldata_vy,fulldata_vz,fulldata_p,fulldata_curl,fulldata_div,recpos,recpos_loc,ntr_glob,srcpos,ishot,ns,iter,1); if (MYID==0) saveseis_glob(FP,fulldata_vx,fulldata_vy,fulldata_vz,fulldata_p,fulldata_curl,fulldata_div,recpos,recpos_loc,ntr_glob,srcpos,ishot,ns,iter,1);
/* wavefield separation */
if (WAVESEP==1) {
if (MYID == 0) fprintf(FP,"\n Testposition out pup");
if (MYID == 0) pup(fulldata_p, fulldata_vy, FP, ntr_glob,recpos,recpos_loc,ntr_glob,srcpos,ishot,ns,iter,1);
/* overwrite sectionp with pup data */
inseis(fprec,ishot,sectionp,ntr_glob,ns,3,iter);
}
break; break;
} /* end of switch (SEISMO) */ } /* end of switch (SEISMO) */
...@@ -3485,6 +3500,15 @@ int main(int argc, char **argv){ ...@@ -3485,6 +3500,15 @@ int main(int argc, char **argv){
} }
/* wavefield separation */
if (WAVESEP==1) {
catseis(sectionvz, fulldata_vz, recswitch, ntr_glob, MPI_COMM_WORLD);
catseis(sectionp, fulldata_p, recswitch, ntr_glob, MPI_COMM_WORLD);
if (MYID == 0) pup(fulldata_p, fulldata_vz, FP, ntr_glob,recpos,recpos_loc,ntr_glob,srcpos,ishot,ns,iter,2);
/* overwrite sectionp with pup data */
inseis(fprec,ishot,sectionp,ntr_glob,ns,3,iter);
}
/*-------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------*/
/*------------------ end loop over timesteps (forward model) step length -------*/ /*------------------ end loop over timesteps (forward model) step length -------*/
/*-------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------*/
......
...@@ -163,7 +163,10 @@ IFOS2D= \ ...@@ -163,7 +163,10 @@ IFOS2D= \
readmod_viscac.c \ readmod_viscac.c \
time_window_glob.c \ time_window_glob.c \
create_trkill_table.c \ create_trkill_table.c \
filter_frequencies.c filter_frequencies.c \
pup.c \
fft2_filt.c \
fft2d.c
SNAPMERGE_OBJ = $(SNAPMERGE_SCR:%.c=%.o) SNAPMERGE_OBJ = $(SNAPMERGE_SCR:%.c=%.o)
......
...@@ -117,6 +117,9 @@ void exchange_par(void){ ...@@ -117,6 +117,9 @@ void exchange_par(void){
extern int WOLFE_TRY_OLD_STEPLENGTH; extern int WOLFE_TRY_OLD_STEPLENGTH;
extern float WOLFE_C1_SL; extern float WOLFE_C1_SL;
extern float WOLFE_C2_SL; extern float WOLFE_C2_SL;
extern int WAVESEP;
extern float VEL, DENS, ANGTAPI, ANGTAPO;
/* definition of local variables */ /* definition of local variables */
...@@ -218,6 +221,12 @@ void exchange_par(void){ ...@@ -218,6 +221,12 @@ void exchange_par(void){
fdum[68]=TRKILL_OFFSET_LOWER; fdum[68]=TRKILL_OFFSET_LOWER;
fdum[69]=TRKILL_OFFSET_UPPER; fdum[69]=TRKILL_OFFSET_UPPER;
fdum[70]=VEL;
fdum[71]=DENS;
fdum[72]=ANGTAPI;
fdum[73]=ANGTAPO;
/***********/ /***********/
/* Integer */ /* Integer */
/***********/ /***********/
...@@ -371,6 +380,10 @@ void exchange_par(void){ ...@@ -371,6 +380,10 @@ void exchange_par(void){
idum[114]=TRKILL_OFFSET; idum[114]=TRKILL_OFFSET;
idum[115]=TRKILL_STF_OFFSET; idum[115]=TRKILL_STF_OFFSET;
idum[116]=WAVESEP;
} /** if (MYID == 0) **/ } /** if (MYID == 0) **/
...@@ -498,6 +511,12 @@ void exchange_par(void){ ...@@ -498,6 +511,12 @@ void exchange_par(void){
TRKILL_STF_OFFSET_UPPER=fdum[67]; TRKILL_STF_OFFSET_UPPER=fdum[67];
TRKILL_OFFSET_LOWER=fdum[68]; TRKILL_OFFSET_LOWER=fdum[68];
TRKILL_OFFSET_UPPER=fdum[69]; TRKILL_OFFSET_UPPER=fdum[69];
VEL=fdum[70];
DENS=fdum[71];
ANGTAPI=fdum[72];
ANGTAPO=fdum[73];
/***********/ /***********/
/* Integer */ /* Integer */
...@@ -655,6 +674,8 @@ void exchange_par(void){ ...@@ -655,6 +674,8 @@ void exchange_par(void){
TRKILL_OFFSET=idum[114]; TRKILL_OFFSET=idum[114];
TRKILL_STF_OFFSET=idum[115]; TRKILL_STF_OFFSET=idum[115];
WAVESEP=idum[116];
MPI_Bcast(&FL[1],L,MPI_FLOAT,0,MPI_COMM_WORLD); MPI_Bcast(&FL[1],L,MPI_FLOAT,0,MPI_COMM_WORLD);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h>
#include <mpi.h> #include <mpi.h>
#define iround(x) ((int)(floor)(x+0.5)) #define iround(x) ((int)(floor)(x+0.5))
...@@ -24,8 +25,32 @@ ...@@ -24,8 +25,32 @@
#define REQUEST_COUNT 4 #define REQUEST_COUNT 4
#define WORKFLOW_MAX_VAR 12 #define WORKFLOW_MAX_VAR 12
/* declaration of functions */ /***************/
/* FFT2D stuff */
/***************/
typedef struct {float re; float im;} COMPLEX;
typedef struct {double re; double im;} DCOMPLEX;
#ifndef ERROR
#define ERROR -1
#define NO_ERROR 0
#endif
#define FFT_FORWARD 0
#define FFT_INVERSE 1
#define TWOPI 6.2831853071795865 /* 2.0 * PI */
#define HALFPI 1.5707963267948966 /* PI / 2.0 */
#define PI8 0.392699081698724 /* PI / 8.0 */
#define RT2 1.4142135623731 /* sqrt(2.0) */
#define IRT2 0.707106781186548 /* 1.0/sqrt(2.0) */
extern int forward_fft2f(COMPLEX *array, int rows, int cols); /* Perform forward 2D transform on a COMPLEX array. */
extern int inverse_fft2f(COMPLEX *array, int rows, int cols); /* Perform inverse 2D transform on a COMPLEX array. */
/****************************/
/* declaration of functions */
/****************************/
void window_cos(float **win, int npad, int nsrc, float it1, float it2, float it3, float it4); void window_cos(float **win, int npad, int nsrc, float it1, float it2, float it3, float it4);
...@@ -125,6 +150,8 @@ void FFT_filt(float ** data, float freqshift, int ntr, int ns,int method); ...@@ -125,6 +150,8 @@ void FFT_filt(float ** data, float freqshift, int ntr, int ns,int method);
void FFT(int isign, unsigned long nlog, float *re, float *im); /* NR version*/ void FFT(int isign, unsigned long nlog, float *re, float *im); /* NR version*/
void fft2(float **array, float **arrayim, int NYG, int NXG, int dir); /* 2d fft filtering*/
float *filter_frequencies(int *nfrq); float *filter_frequencies(int *nfrq);
float *holbergcoeff(void); float *holbergcoeff(void);
...@@ -201,6 +228,7 @@ void psource(int nt, float ** sxx, float ** syy, float ** sp, ...@@ -201,6 +228,7 @@ void psource(int nt, float ** sxx, float ** syy, float ** sp,
void psource_rsg(int nt, float ** sxx, float ** syy, void psource_rsg(int nt, float ** sxx, float ** syy,
float ** srcpos_loc, float ** signals, int nsrc); float ** srcpos_loc, float ** signals, int nsrc);
void pup(float **data_p, float **data_vz, FILE *fp, int ntr_glob, int **recpos, int **recpos_loc,int ntr, float ** srcpos, int ishot, int ns, int iter, int sw );
float *rd_sour(int *nts,FILE* fp_source); float *rd_sour(int *nts,FILE* fp_source);
...@@ -464,6 +492,7 @@ void err(char err_text[]); ...@@ -464,6 +492,7 @@ void err(char err_text[]);
void warning(char warn_text[]); void warning(char warn_text[]);
double maximum(float **a, int nx, int ny); double maximum(float **a, int nx, int ny);
float *vector(int nl, int nh); float *vector(int nl, int nh);
COMPLEX *cplxvector(int nstart, int nend);
int *ivector(int nl, int nh); int *ivector(int nl, int nh);
double *dvector(int nl, int nh); double *dvector(int nl, int nh);
float **fmatrix(int nrl, int nrh, int ncl, int nch); float **fmatrix(int nrl, int nrh, int ncl, int nch);
...@@ -473,6 +502,7 @@ float **matrix(int nrl, int nrh, int ncl, int nch); ...@@ -473,6 +502,7 @@ float **matrix(int nrl, int nrh, int ncl, int nch);
int **imatrix(int nrl, int nrh, int ncl, int nch); int **imatrix(int nrl, int nrh, int ncl, int nch);
float ***f3tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh); float ***f3tensor(int nrl, int nrh, int ncl, int nch,int ndl, int ndh);
void free_vector(float *v, int nl, int nh); void free_vector(float *v, int nl, int nh);
void free_cplxvector(COMPLEX *v, int nstart, int nend);
void free_dvector(double *v, int nl, int nh); void free_dvector(double *v, int nl, int nh);
void free_ivector(int *v, int nl, int nh); void free_ivector(int *v, int nl, int nh);
void free_matrix(float **m, int nrl, int nrh, int ncl, int nch); void free_matrix(float **m, int nrl, int nrh, int ncl, int nch);
......
/*-----------------------------------------------------------------------------------------
* Copyright (C) 2016 For the list of authors, see file AUTHORS.
*
* This file is part of IFOS.
*
* IFOS 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.
*
* IFOS 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 IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
* 2D-FFT preparation
* ----------------------------------------------------------------------*/
#include "fd.h"
void fft2(float **array, float **arrayim, int NYG, int NXG, int dir) {
extern FILE *FP;
COMPLEX *C;
int j, i, k, nx, ny, nxy;
float **RE, **IM;
fprintf(FP,"\n Testposition fft2_filt 1\n ");
usleep(900000);
/****************************************************/
/* recompute the dimensions to become values of 2^m */
nx = (int)(pow(2,(ceil(log(NXG)/log(2)))));
ny = (int)(pow(2,(ceil(log(NYG)/log(2)))));
nxy = max(nx,ny);
nxy *= 2;
fprintf(FP,"\n Testposition fft2_filt 1, nxy: %i\n ",nxy);
usleep(900000);
RE = matrix(1, nxy, 1, nxy);
IM = matrix(1, nxy, 1, nxy);
C = cplxvector(1, nxy*nxy);
/* copy array data to the temp-array */
for (i=1;i<=NXG;i++)
for (j=1;j<=NYG;j++){
RE[j][i] = array[j][i];
IM[j][i] = arrayim[j][i];
}
fprintf(FP,"\n Testposition fft2_filt 3\n ");
usleep(900000);
if (dir==1) {
k = 1;
for (i=1;i<=nxy;i++)
for (j=1;j<=nxy;j++) {
C[k].re = RE[j][i];
C[k].im = 0.0;
k++;
}
forward_fft2f(C, nxy, nxy);
k = 1;
for (i=1;i<=nxy;i++)
for (j=1;j<=nxy;j++) {
RE[j][i] = C[k].re;
IM[j][i] = C[k].im;
k++;
}
} else {
k = 1;
for (i=1;i<=nxy;i++)
for (j=1;j<=nxy;j++) {
C[k].re = RE[j][i];
C[k].im = IM[j][i];
k++;
}
inverse_fft2f(C, nxy, nxy);
k = 1;
for (i=1;i<=nxy;i++)
for (j=1;j<=nxy;j++) {
RE[j][i] = C[k].re;
IM[j][i] = 0.0;
k++;
}
}
/* write result back into array*/
for (i=1;i<=NXG;i++)
for (j=1;j<=NYG;j++){
array[j][i]=RE[j][i];
arrayim[j][i]=IM[j][i];
}
free_cplxvector(C, 1, nxy*nxy);
free_matrix(RE, 1,nxy,1,nxy);
free_matrix(IM, 1,nxy,1,nxy);
}
/********************************************************/
/* 2D-FFTSHIFT */
/********************************************************/
// void fft2shift(float **RE, float **IM, int ny, int nx) {
//
// int j, i;
// float **A;
//
//
// A = matrix(1, ny, 1, nx);
//
// /* shift the real part */
// for (i=1;i<=nx;i++)
// for (j=1;j<=ny;j++) A[j][i] = RE[j][i];
// for (i=1;i<=nx/2;i++)
// for (j=1;j<=ny/2;j++) {
// RE[j][i] = A[j+ny/2][i+nx/2];
// RE[j+ny/2][i+nx/2] = A[j][i];
// RE[j+ny/2][i] = A[j][i+nx/2];
// RE[j][i+nx/2] = A[j+ny/2][i];
// }
//
// /* shift the imaginary part */
// for (i=1;i<=nx;i++)
// for (j=1;j<=ny;j++) A[j][i] = IM[j][i];
// for (i=1;i<=nx/2;i++)
// for (j=1;j<=ny/2;j++) {
// IM[j][i] = A[j+ny/2][i+nx/2];
// IM[j+ny/2][i+nx/2] = A[j][i];
// IM[j+ny/2][i] = A[j][i+nx/2];
// IM[j][i+nx/2] = A[j+ny/2][i];
// }
//
// free_matrix(A, 1, ny, 1, nx);
// }
\ No newline at end of file
This diff is collapsed.
...@@ -144,4 +144,7 @@ int JOINT_INVERSION_PSV_SH_TYPE; ...@@ -144,4 +144,7 @@ int JOINT_INVERSION_PSV_SH_TYPE;
float JOINT_INVERSION_PSV_SH_ALPHA_VS; float JOINT_INVERSION_PSV_SH_ALPHA_VS;
float JOINT_INVERSION_PSV_SH_ALPHA_RHO; float JOINT_INVERSION_PSV_SH_ALPHA_RHO;
int SNAPSHOT_START,SNAPSHOT_END,SNAPSHOT_INCR; int SNAPSHOT_START,SNAPSHOT_END,SNAPSHOT_INCR;
\ No newline at end of file
int WAVESEP;
float VEL, DENS, ANGTAPI, ANGTAPO;
\ No newline at end of file
...@@ -40,6 +40,14 @@ void inseis(FILE *fp, int comp, float **section, int ntr, int ns, int sws, int ...@@ -40,6 +40,14 @@ void inseis(FILE *fp, int comp, float **section, int ntr, int ns, int sws, int
sprintf(data,"%s_vy.su.shot%d",DATA_DIR,comp); sprintf(data,"%s_vy.su.shot%d",DATA_DIR,comp);
} }
if(sws==3){ /* open seismic data pup */
sprintf(data,"%s_pup.su.shot%d",DATA_DIR,comp);
}
if(sws==4){ /* open seismic data pup used for step length calculation */
sprintf(data,"%s_pup.su.step.shot%d",DATA_DIR,comp);
}
/* sws 3 -- 6 not used */ /* sws 3 -- 6 not used */
if(sws==7){ /* open convolved seismic data vx */ if(sws==7){ /* open convolved seismic data vx */
......
/*-----------------------------------------------------------------------------------------
* Copyright (C) 2016 For the list of authors, see file AUTHORS.
*
* This file is part of IFOS.
*
* IFOS 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.
*
* IFOS 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 IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/
/*
*-------------------------------------------------------------
*
* perform wavefield separation in FK domain and save it to file
*
*
*-------------------------------------------------------------
*/
#include "fd.h"
void pup(float **data_p, float **data_vy, FILE *fp, int ntr_glob, int **recpos, int **recpos_loc,int ntr, float ** srcpos, int ishot, int ns, int iter, int sw ) {
extern float DT, DH;
extern float VEL, DENS, ANGTAPI, ANGTAPO;
extern char SEIS_FILE[STRING_SIZE];
extern int SEIS_FORMAT;
extern FILE *FP;
int i, j, k;
float nyq_k, nyq_f, dk, df, angi, ango, ka;
float *w, *kx;
float **filtwk, **filtwk_full;
float **data_pim,**data_vyim,**data_pup,**data_pupim;
char pf[STRING_SIZE], pf1[STRING_SIZE], pf2[STRING_SIZE];
FILE *file;
/* temporary array */
filtwk=matrix(1,ns/2,1,ntr_glob/2);
filtwk_full=matrix(1,ns,1,ntr_glob);
data_pup=matrix(1,ns,1,ntr_glob);
data_pim=matrix(1,ns,1,ntr_glob);
data_vyim=matrix(1,ns,1,ntr_glob);
data_pupim=matrix(1,ns,1,ntr_glob);
w=vector(1,ns/2);
kx=vector(1,ntr_glob/2);
nyq_k = 1/(2*DH); /* Nyquist of data in first dimension */
nyq_f = 1/(2*DT); /* Nyquist of data in time dimension */
dk = 1/(ntr_glob*DH); /* Wavenumber increment */
df = 1/(ns*DT); /* Frequency increment */
for (j=1;j<=ns/2;j++) w[j]=df*(j-1); /* vector of angular frequencies*/
for (j=1;j<=ntr_glob/2;j++) kx[j]=dk*(j-1); /*vector of angular wavenumbers*/
fprintf(FP,"\n kx(8): %7.4f\n",kx[8]);
angi = ANGTAPI * PI/180.0;
ango = ANGTAPO * PI/180.0;
// fprintf(FP,"\n Testposition 2: angi: %f; ango: %f.\n ",angi, ango);
// fprintf(FP,"\n Testposition 2: ns: %i; DT: %f.\n ",ns, DT);
// fprintf(FP,"\n Testposition 2: ntr_glob: %i; DH: %f.\n ",ntr_glob, DH);
/* calculate Filter vor wavefield separation (after Kluever, 2008) */
for (k=1;k<=ns/2;k++) {
if (k==1) fprintf(FP,"\n Testposition 2.5: w(%i): %f \n",k,w[k]);
ka = fabs(w[k])/VEL;
if (k==3000) fprintf(FP,"\n Testposition 2.5: w(%i): %f \n",k,w[k]);
for (i=1;i<=ntr_glob/2;i++) {
if(kx[i] < ka*sin(angi)) {
filtwk[k][i] = (DENS*fabs(w[k]))/sqrt((ka*ka)-(kx[i]*kx[i]));
}else{
if(kx[i] < ka*sin(ango) && kx[i] > ka*sin(angi)){
filtwk[k][i] = 0.5*(1.0+cos(PI/((ka*sin(ango))-(ka*sin(angi))) * (kx[i]-(ka*sin(angi))))) * (DENS*fabs(w[k]))/sqrt((ka*ka)-(kx[i]*kx[i]));
}else {
filtwk[k][i] = 0.0;
}
}
}
}
fprintf(FP,"\n Testposition 3: angi: %f; ango: %f.\n ",angi, ango);
/* expand filter */
for (k=1;k<=ns;k++) {
fprintf(FP,"k: %i \t",k);
for (i=1;i<=ntr_glob;i++) {
if (k==3000) fprintf(FP,"i: %i \n",i);
if(k<=ns/2 && i<=ntr_glob/2) {
filtwk_full[k][i]=filtwk[(ns/2)-(k-1)][(ntr_glob/2)-(i-1)];
}else if(k<=ns/2 && i>ntr_glob/2) {
filtwk_full[k][i]=filtwk[(ns/2)-(k-1)][i-(ntr_glob/2)];
}else if(k>ns/2 && i<=ntr_glob/2) {
filtwk_full[k][i]=filtwk[k-(ns/2)][(ntr_glob/2)-(i-1)];
}else if(k>ns/2 && i>ntr_glob/2) {
filtwk_full[k][i]=filtwk[k-(ns/2)][i-(ntr_glob/2)];
}
}
}
/* transformation into fk domain */
fft2(data_p, data_pim, ns, ntr_glob,1);
fft2(data_vy, data_vyim, ns, ntr_glob,1);
/* write filter to file*/
if (iter==1){
sprintf(pf1,"$s_spectrum.filt.shot%i.it%i.bin",SEIS_FILE,ishot, iter);
file = fopen(pf1,"wb");
for (i=1;i<=ns;i++)
for (j=1;j<=ntr_glob;j++) fwrite(&filtwk_full[j][i],sizeof(float),1,FP);
fclose(file);
/* write spectrum to file */
sprintf(pf2,"$s_spectrum.p.real.shot%i.it%i.bin",SEIS_FILE,ishot, iter);
file = fopen(pf2,"wb");
for (i=1;i<=ns;i++)
for (j=1;j<=ntr_glob;j++) fwrite(&data_p[j][i],sizeof(float),1,FP);
fclose(file);
}
/* perform wavefield separation */
for (k=1;k<=ns;k++) {
for (i=1;i<=ntr_glob;i++) {
data_pup[k][i]=0.5*(data_p[k][i]-(filtwk_full[k][i]*data_vy[k][i]));
data_pupim[k][i]=0.5*(data_pim[k][i]-(filtwk_full[k][i]*data_vyim[k][i]));
}
}
fprintf(FP,"\n Testposition 4\n ");
/* reverse 2d fft */
fft2(data_pup, data_pupim, ns, ntr_glob,-1);
/* save pup*/
if (sw == 1){
sprintf(pf,"%s_pup.su.shot%i.it%i",SEIS_FILE,ishot,iter);
}
if (sw == 2){ /* for step length calculation*/
sprintf(pf,"%s_pup.su.step.shot%i.it%i",SEIS_FILE,ishot,iter);
}
outseis_glob(fp,fopen(pf,"w"), 0, data_pup,recpos,recpos_loc,ntr,srcpos,1,ns,SEIS_FORMAT,ishot,1);
/* overwrite p data */
for (k=1;k<=ns;k++) {
for (i=1;i<=ntr_glob;i++) {
data_p[k][i]=data_pup[k][i];
}
}
fprintf(FP,"\n Testposition 5\n ");
free_matrix(filtwk, 1,ns/2,1,ntr_glob/2);
free_matrix(filtwk_full, 1,ns,1,ntr_glob);
free_matrix(data_pim, 1,ns,1,ntr_glob);
free_matrix(data_vyim, 1,ns,1,ntr_glob);
free_matrix(data_pup, 1,ns,1,ntr_glob);
free_matrix(data_pupim, 1,ns,1,ntr_glob);
free_vector(w,1,ns/2);
free_vector(kx,1,ntr_glob/2);
}
\ No newline at end of file
...@@ -127,6 +127,9 @@ void read_par_json(FILE *fp, char *fileinp){ ...@@ -127,6 +127,9 @@ void read_par_json(FILE *fp, char *fileinp){
extern int WOLFE_TRY_OLD_STEPLENGTH; extern int WOLFE_TRY_OLD_STEPLENGTH;
extern float WOLFE_C1_SL; extern float WOLFE_C1_SL;
extern float WOLFE_C2_SL; extern float WOLFE_C2_SL;
extern int WAVESEP;
extern float VEL, DENS, ANGTAPI, ANGTAPO;
/* definition of local variables */ /* definition of local variables */
...@@ -328,6 +331,31 @@ void read_par_json(FILE *fp, char *fileinp){ ...@@ -328,6 +331,31 @@ void read_par_json(FILE *fp, char *fileinp){
if (get_int_from_objectlist("IDY",number_readobjects,&IDY,varname_list, value_list)){ if (get_int_from_objectlist("IDY",number_readobjects,&IDY,varname_list, value_list)){
IDY=1; IDY=1;
fprintf(fp,"Variable IDY is set to default value %d.\n",IDY);} fprintf(fp,"Variable IDY is set to default value %d.\n",IDY);}
/*=================================
section wavefield separation
=================================*/