Commit df243d58 authored by niklas.thiel's avatar niklas.thiel
Browse files

Merge branch 'develop' into pup

Conflicts:
	doc/latex/6_Parameter_Definition.tex
	src/IFOS2D.c
	src/calc_misfit.c
	src/exchange_par.c
	src/globvar.h
parents 914e765c 973a56a6
......@@ -19,6 +19,10 @@ remainder may consist of several control parameters being separated by colons
or may come along with a parameter value. The value is separated from the
parameter by an equal sign (=).
Where several values in an argument to a parameter must be separated (like in
the 'irtap' option of the Fourier domain procedures) white space ( ), commas
(,), and semicolons (;) are allowed as field delimiters, at your convenience.
Examples:
- To select Fourier domain least squares and shift the returned source
correction filter wavelet by 0.4s and switch on verbose mode, pass the
......
......@@ -4,17 +4,31 @@
# Procedures in the Fourier domain
# --------------------------------
Options and parameters in common for procedures in the Fourier domain:
fpow2 use power of two for number of coefficients
fdiv=d use integer multiple of d for number of coefficients
fpad=f padding factor
tshift=d delay source correction filter wavelet by d (in seconds)
in order to expose acausal components
fpow2 use power of two for number of coefficients
fdiv=d use integer multiple of d for number of coefficients
fpad=f padding factor
tshift=d delay source correction filter wavelet by d (in seconds)
in order to expose acausal components
irtap=t1,t2,t3,t4 taper impulse response of correction filter
These options define the number of samples N used for the FFT (Fast Fourier
Transform). This number N should be larger than the number of samples M in the
original input time series to avoid wrap-around. If fpow2 is set, N will be
the next power of 2 larger than M*f. Else if fdiv is set, N will be the next
integer multiple of d larger than M*f.
integer multiple of d larger than M*f. If fdiv is not set explicitely, a
default value for d (commonly 100) is used. If option fpad ist used, N will be
f times larger than without padding. Without explicitely setting fpad, a
default value for f is used (which commonly equals 1.5). When defining the
number of samples N, first padding is considered (fpad), then the either
selection of a power of two (pow2) or the divisor criterion (fdiv) is applied.
The latter is only applied, if pow2 ist not selected.
Input time series with M samples will be padded with (N-M) zeros to create the
time series which actually will be transformed to the Fourier domain. Upon
inverse FFT the additional (N-M) samples of the resulting time series will be
discarded before returning the M remaining samples to the caller. Note, that
this is a form of implicite taper. In particular the caller will not obtain
exactly the filter response, which was used for convolution internally.
The derived correction filter in some cases can contain acausal components.
This means that the impulse response is non-zero for negative time values.
......@@ -22,4 +36,24 @@ Since by definition, the impulse response is output for the time interval of
the input data, these acausal components can remain unnoticed. The option
tshift can be used to shift the impulse response as obtained by inverse FFT in
order to expose acausal components.
A time domain taper can be applied to the impulse response of the correction
filter by using option irtap. Four time values are given in units of seconds:
t1, t2, t3, and t4. They must be in increasing order and (t4-t1) must be
smaller than the total duration of the time series used to represent signals
internally. Times value are allowed to be negative. Time series are understood
to be periodic (due to discrete Fourier transformation). Prior to application
of the correction filter to the time series passed to the algorithm, the
correction filter is transformed to the time domain, tapered, and then
transformed to the Fourier domain again. The values of the taper are:
0 if t < t1
0.5-0.5*cos(pi*(t-t1)/(t2-t1)) if t1 <= t <= t2
1 if t2 < t < t3
0.5+0.5*cos(pi*(t-t3)/(t3-t4)) if t3 <= t <= t4
0 if t > t4
Time values are given in the same unit in which the sampling interval is given
in the input time series. I.e. if sampling interval is specified as a fraction
of seconds (which is standard) then all time values passed as parameters are
also given as fractions or multiples of seconds.
# ----- END OF stfinvfourier_description_usage.txt -----
......@@ -4,8 +4,9 @@
Procedures in the Fourier domain
--------------------------------
Options and parameters in common for procedures in the Fourier domain:
fpow2 use power of two for number of coefficients
fdiv=d use integer multiple of d for number of coefficients
fpad=f padding factor
tshift=d delay source correction filter wavelet by d (in seconds)
fpow2 use power of two for number of coefficients
fdiv=d use integer multiple of d for number of coefficients
fpad=f padding factor
tshift=d delay source correction filter wavelet by d (in seconds)
irtap=t1,t2,t3,t4 taper impulse response of correction filter
# ----- END OF stfinvfourier_summary_usage.txt -----
......@@ -659,7 +659,7 @@ To remove the contribution of the unknown source time function (STF) from the wa
"TRKILL_STF" : "0",
"TRKILL_FILE_STF" : "./trace_kill/trace_kill",
"STF_FULL" : "0",
"TRKILL_STF_OFFSET" : "0",
"TRKILL_STF_OFFSET_LOWER" : "10",
"TRKILL_STF_OFFSET_UPPER" : "20",
......@@ -671,13 +671,14 @@ Default values are:
INV_STF=0
\end{verbatim}}}
INV\_STF should be switched to 1 if you want to invert for the source time function.
INV\_STF should be switched to 1 if you want to invert for the source time function. If STF\_FULL is set to 1 then the total wavefield is used to invert for the source time function and the time window is ignored.
\newline
An example for the parameter string provided in PARA is:
\begin{itemize}
\item To select frequency domain least squares (fdlsq), apply offset dependent weights and a waterlevel use\\
\textit{fdlsq:exp=1.0:waterlevel=0.01}
\item For tapering the inverted STF add the option \textit{irtap=t1;t2;t3;t4} to the parameter string. The four values define the taper window. %It is important to use ";", because "," is used by the JSON-parser to separate variables.
\end{itemize}
In most cases the frequency domain least squares engine is the best approach to find a suitable wavelet. There are also other possibilities, if you want to use those a detailed look at the libraries and the acompanying documentation provided in the folder /contrib is recommended. Here only the two main parameters for the fdlsq approach are described.
......@@ -735,7 +736,7 @@ With F\_HIGH\_PASS an additional high pass filter can be applied, where F\_HIGH\
With the parameter PRO (see~\ref{json:abort_criterion}) one has to adjust the criterion that defines at which points the bandwidth of the signals are increased.
With the parameter WRITE\_FILTERED\_DATA it is possible to write the time filtered measured data to disk which are filtered with the same filter as the synthetic data. Therefore this output can be used to visualize the residuals between synthetic and measured data. The filtered data is located in DATA\_DIR and are labeled with "\_measured".
With the parameter WRITE\_FILTERED\_DATA=1 it is possible to write the time filtered measured data to disk which are filtered with the same filter as the synthetic data. Therefore this output can be used to visualize the residuals between synthetic and measured data. The filtered data is located in SEIS\_FILE and the seismograms are labeled with "obs" (synthetic seismograms are labeled with "syn"). By choosing WRITE\_FILTERED\_DATA=2 one can directly output the seismograms that are used for calculating the adjoint sources. Additionally time windowing and integration (see Option VELOCITY) are considered and the label "adj" is added to the seismogram name.
If you are using frequeny filtering (TIME\_FILT==1) during the inversion, you can set a minimum number of iterations per frequency. Within this minimum number of iteration per frequency the abort criterion PRO will receive no consideration.
......@@ -755,7 +756,7 @@ Default values are:
TIMEWIN=0
\end{verbatim}}}
To apply time windowing in a time series the paramter TIMEWIN must set to 1. A automatic picker routine is not integrated. The point in time (picked time) for each source must be specified in separate files. The folder and file name can be set with the parameter PICKS\_FILE. The files must be named like this PICKS\_FILE\_<sourcenumber>.dat. So the number of sources must be equal to the number of files. Each file must contain the picked times for every receiver.
To apply time windowing in a time series the parameter TIMEWIN must set to 1. A automatic picker routine is not integrated. The point in time (picked time) for each source must be specified in separate files. The folder and file name can be set with the parameter PICKS\_FILE. The files must be named like this PICKS\_FILE\_<sourcenumber>.dat. So the number of sources must be equal to the number of files. Each file must contain the picked times for every receiver.
The parameters TWLENGTH\_PLUS and TWLENGTH\_MINUS specify the length of the time window after (PLUS) and before (MINUS) the picked time. The unit is seconds. The damping factor GAMMA must be set individually.
......@@ -815,7 +816,7 @@ SWS_TAPER_FILE=0
SWS_TAPER_FILE_PER_SHOT=0
\end{verbatim}}}
Different preconditioning matrices can be created and applied to the gradients (using the function \texttt{taper\_grad.c}). To apply a vertical taper one has to set the switch SWS\_TAPER\_GRAD\_VERT to one and for a horizontaltaper SWS\_TAPER\_GRAD\_HOR has to be 1. The parameters for the vertical and the horizontal window are defined by the input file paramters GRADT1, GRADT2, GRADT3 and GRADT4. Please have a look at the function \texttt{taper\_grad.c} directly to obtain more information about the actual definition of the tapers. It is also possible to apply cylindrical tapers around the source positions. This can be done by either setting the switch SWS\_TAPER\_GRAD\_SOURCES or SWS\_TAPER\_CIRCULAR\_PER\_SHOT to 1. If one uses SWS\_TAPER\_GRAD\_SOURCES=1 only the final gradients (that means the gradients obtained by the summation of the gradients of each shots) are multiplied with a taper that decreases the gradients at all shot positions. Therefore, one looses the update information at the source positions. To avoid this one can use SWS\_TAPER\_CIRCULAR\_PER\_SHOT=1. In this case the gradients of the single shots are preconditioned with a window that only decreases at the current shot position. This is done before the summation of all gradients to keep model update information also at the shot positions. The actual tapers are generated by the function \texttt{taper\_grad.c} and \texttt{taper\_grad\_shot.c}, respectively. The circular taper around the source positions decrease from a value of one at the edge of the taper to a value of zero at the source position. The shape of the decrease can be defined by an error function (SRTSHAPE=1) or a log-function (SRTSHAPE=2). The radius of the taper is defined in meter by SRTRADIUS. Note, that this radius must be at least 5 gridpoints. With the parameter FILTSIZE one can extend the region where the taper is zero around the source. The taper is set to zero in a square region of (2*FILTSIZE+1 times 2*FILTSIZE+1) gridpoints. All preconditioning matrices that are applied are saved in the par directory with the file names taper\_coeff\_vert.bin, taper\_coeff\_horz.bin and taper\_coeff\_sources.bin.\\
Different preconditioning matrices can be created and applied to the gradients (using the function \texttt{taper\_grad.c}). To apply a vertical taper one has to set the switch SWS\_TAPER\_GRAD\_VERT to one and for a horizontaltaper SWS\_TAPER\_GRAD\_HOR has to be 1. The parameters for the vertical and the horizontal window are defined by the input file parameters GRADT1, GRADT2, GRADT3 and GRADT4. Please have a look at the function \texttt{taper\_grad.c} directly to obtain more information about the actual definition of the tapers. It is also possible to apply cylindrical tapers around the source positions. This can be done by either setting the switch SWS\_TAPER\_GRAD\_SOURCES or SWS\_TAPER\_CIRCULAR\_PER\_SHOT to 1. If one uses SWS\_TAPER\_GRAD\_SOURCES=1 only the final gradients (that means the gradients obtained by the summation of the gradients of each shots) are multiplied with a taper that decreases the gradients at all shot positions. Therefore, one looses the update information at the source positions. To avoid this one can use SWS\_TAPER\_CIRCULAR\_PER\_SHOT=1. In this case the gradients of the single shots are preconditioned with a window that only decreases at the current shot position. This is done before the summation of all gradients to keep model update information also at the shot positions. The actual tapers are generated by the function \texttt{taper\_grad.c} and \texttt{taper\_grad\_shot.c}, respectively. The circular taper around the source positions decrease from a value of one at the edge of the taper to a value of zero at the source position. The shape of the decrease can be defined by an error function (SRTSHAPE=1) or a log-function (SRTSHAPE=2). The radius of the taper is defined in meter by SRTRADIUS. Note, that this radius must be at least 5 gridpoints. With the parameter FILTSIZE one can extend the region where the taper is zero around the source. The taper is set to zero in a square region of (2*FILTSIZE+1 times 2*FILTSIZE+1) gridpoints. All preconditioning matrices that are applied are saved in the par directory with the file names taper\_coeff\_vert.bin, taper\_coeff\_horz.bin and taper\_coeff\_sources.bin.\\
To apply an externally defined taper on the gradients in IFOS2D, the parameter SWS\_TAPER\_FILE has to be set to 1. Each model parameter requires a taper file which needs to be located in TAPER\_FILE\_NAME.vp for vp, in TAPER\_FILE\_NAME.vs for vs and in TAPER\_FILE\_NAME.rho for the density.\\
......@@ -861,6 +862,9 @@ For GRAD\_FILT\_WAVELENGTH = 1 (and TIME\_FILT=1) a new wavelength dependent fil
\end{equation}
where F\_LOW\_PASS is the corner frequency of TIME\_FILT and A is a weighting factor.
\ \\
WARNING: The option GRAD\_FILTER uses a median filter that makes use of a quicksort routine. Under some (unknown) conditions this can take a huge amount of time and corrupt the inversion.
\section{Model manipulation}
\subsection{Limits for the model parameters}
......@@ -924,3 +928,6 @@ Default values are:
\end{verbatim}}}
If MODEL\_FILTER = 1 vp- and vs-models are smoothed with a 2D median filter after every iterationstep. With FILT\_SIZE you can set the filter length in gridpoints.
\ \\
WARNING: The option MODEL\_FILTER uses a median filter that makes use of a quicksort routine. Under some (unknown) conditions this can take a huge amount of time and corrupt the inversion.
This diff is collapsed.
......@@ -19,7 +19,7 @@ EXEC= ../bin
# LINUX with OpenMPI / IntelMPI and INTEL Compiler
# Use icc whenever possible, this will be much faster than gcc
CC=mpiicc
CC=mpicc
LFLAGS=-lm -lcseife -lstfinv -laff -lfourierxx -lfftw3 -lstdc++
CFLAGS=-O3
SFLAGS=-L./../contrib/libcseife -L./../contrib/bin
......
......@@ -29,7 +29,7 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN
extern int TRKILL, NORMALIZE, F_LOW_PASS, TIMEWIN;
extern char TRKILL_FILE[STRING_SIZE];
extern int VELOCITY;
extern int WRITE_FILTERED_DATA;
int i,j;
float l2;
int h;
......@@ -181,8 +181,8 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN
abs_section+=intseis_section[i][j]*intseis_section[i][j];
}
if (abs_sectiondata==0) abs_sectiondata=1;
else abs_sectiondata=sqrt(abs_sectiondata);
if (abs_section==0) abs_section==1;
else abs_sectiondata=sqrt(abs_sectiondata);
if (abs_section==0) abs_section==1;
else abs_section=sqrt(abs_section);
}
......@@ -202,6 +202,15 @@ double calc_misfit(float **sectiondata, float **section, int ntr, int ns, int LN
}
}
if(WRITE_FILTERED_DATA==2){
for(i=1;i<=ntr;i++){
for(j=1;j<=ns;j++){
sectiondata[i][j]=intseis_sectiondata[i][j];
section[i][j]=intseis_section[i][j];
}
}
}
l2=L2;
/* printf("\n MYID = %i IN CALC_MISFIT: L2 = %10.12f \n",MYID,l2); */
......
......@@ -30,7 +30,7 @@ void exchange_par(void){
extern float XREC1, XREC2, YREC1, YREC2, FPML;
extern float REC_ARRAY_DEPTH, REC_ARRAY_DIST, MUN, EPSILON, EPSILON_u, EPSILON_rho;
extern int SEISMO, NDT, NGEOPH, SEIS_FORMAT, FREE_SURF, READMOD, READREC, SRCREC;
extern int BOUNDARY, REC_ARRAY, DRX, FW;
extern int BOUNDARY, REC_ARRAY, DRX, FW, STF_FULL;
extern int SNAPSHOT_START,SNAPSHOT_END,SNAPSHOT_INCR;
extern float TSNAP1, TSNAP2, TSNAPINC, REFREC[4];
extern char MFILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE],SIGNAL_FILE_SH[STRING_SIZE], LOG_FILE[STRING_SIZE];
......@@ -223,7 +223,7 @@ void exchange_par(void){
fdum[68]=TRKILL_OFFSET_LOWER;
fdum[69]=TRKILL_OFFSET_UPPER;
fdum[70]=LBFGS_SCALE_GRADIENTS;
fdum[74]=LBFGS_SCALE_GRADIENTS;
fdum[70]=VEL;
fdum[71]=DENS;
......@@ -387,7 +387,7 @@ void exchange_par(void){
idum[117]=WAVESEP;
idum[118]=JOINT_EQUAL_WEIGHTING;
idum[119]=STF_FULL;
} /** if (MYID == 0) **/
MPI_Barrier(MPI_COMM_WORLD);
......@@ -520,7 +520,7 @@ void exchange_par(void){
ANGTAPO=fdum[73];
LBFGS_SCALE_GRADIENTS=fdum[70];
LBFGS_SCALE_GRADIENTS=fdum[74];
/***********/
/* Integer */
......@@ -681,7 +681,7 @@ void exchange_par(void){
WAVESEP=idum[117];
JOINT_EQUAL_WEIGHTING=idum[118];
STF_FULL=idum[119];
if ( MYID!=0 && L>0 ) {
FL=vector(1,L);
}
......
......@@ -539,6 +539,8 @@ float average_matrix(float ** matrix);
float global_maximum(float ** gradiant_1);
void write_matrix_disk(float ** gradient,char path_name[STRING_SIZE]);
float matrix_product(float ** matrix1, float **matrix2);
void get_local_from_global_matrix(float ** global_matrix,float ** local_matrix);
float ** get_global_from_local_matrix(float ** local_matrix);
/* L-BFGS */
void lbfgs(float **grad1, float **grad2, float **grad3,float Vs_avg,float rho_avg,float Vp_avg, float *bfgsscale, float **bfgsmod, float **bfgsgrad,int bfgsnum,int bfgspar, int iteration, int * LBFGS_iter_start);
......
......@@ -14,7 +14,7 @@ float XREC1, XREC2, YREC1, YREC2;
float REC_ARRAY_DEPTH, REC_ARRAY_DIST;
float REFREC[4]={0.0, 0.0, 0.0, 0.0}, FPML;
int SEISMO, NDT, NGEOPH, NSRC=1, SEIS_FORMAT, FREE_SURF, READMOD, READREC, SRCREC, FW=0;
int NX, NY, NT, SOURCE_SHAPE,SOURCE_SHAPE_SH, SOURCE_TYPE, SNAP, SNAP_FORMAT, REC_ARRAY, RUN_MULTIPLE_SHOTS, NTRG;
int NX, NY, NT, SOURCE_SHAPE,SOURCE_SHAPE_SH, SOURCE_TYPE, SNAP, SNAP_FORMAT, REC_ARRAY, RUN_MULTIPLE_SHOTS, NTRG,STF_FULL;
int L, BOUNDARY, DC, DRX, NXG, NYG, IDX, IDY, FDORDER, MAXRELERROR;
char SNAP_FILE[STRING_SIZE], SOURCE_FILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE], SIGNAL_FILE_SH[STRING_SIZE];
char MFILE[STRING_SIZE], REC_FILE[STRING_SIZE];
......
......@@ -26,7 +26,7 @@
void info(FILE *fp){
fprintf(fp," ***********************************************************\n");
fprintf(fp," This is program IFOS2D. Version 2.0.2 \n");
fprintf(fp," This is program IFOS2D. Version 2.0.3 \n");
fprintf(fp," Parallel 2-D elastic Full Waveform Inversion code. \n");
fprintf(fp," \n");
fprintf(fp," ***********************************************************\n");
......
......@@ -21,7 +21,7 @@
#include "fd.h"
void write_matrix_disk(float ** gradient,char path_name[STRING_SIZE]){
void write_matrix_disk(float ** local_matrix,char path_name[STRING_SIZE]){
char joint[225];
FILE *FPjoint;
extern int POS[3],MYID;
......@@ -32,7 +32,7 @@ void write_matrix_disk(float ** gradient,char path_name[STRING_SIZE]){
for (i=1;i<=NX;i=i+IDX){
for (j=1;j<=NY;j=j+IDY){
fwrite(&gradient[j][i],sizeof(float),1,FPjoint);
fwrite(&local_matrix[j][i],sizeof(float),1,FPjoint);
}
}
......@@ -122,6 +122,70 @@ float matrix_product(float ** matrix1, float **matrix2) {
return global_sum;
}
float ** get_global_from_local_matrix(float ** local_matrix) {
extern int NXG, NYG;
extern int NX,NY;
extern int POS[3];
float ** global_matrix=NULL,** global_matrix_temp=NULL;
int i=0,j=0;
int ii=0, jj=0;
/* Allocate global matrix temp */
global_matrix_temp=matrix(1,NYG,1,NXG);
if(global_matrix_temp==NULL) {
declare_error("Allocation of global_matrix_temp in get_global_from_local_matrix failed!");
}
/* Allocate global matrix */
/* You have to deallocate this matrix on our own */
global_matrix=matrix(1,NYG,1,NXG);
if(global_matrix==NULL) {
declare_error("Allocation of global_matrix in get_global_from_local_matrix failed!");
}
/* Store local matrix in global matrix */
for (i=1;i<=NXG;i++){
for (j=1;j<=NYG;j++){
if ( (POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY)) ) {
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
global_matrix_temp[j][i]=local_matrix[jj][ii];
}
}
}
MPI_Allreduce(&global_matrix_temp[1][1],&global_matrix[1][1],NXG*NYG,MPI_FLOAT,MPI_SUM,MPI_COMM_WORLD);
free_matrix(global_matrix_temp,1,NYG,1,NXG);
return global_matrix;
}
void get_local_from_global_matrix(float ** global_matrix,float ** local_matrix) {
extern int NXG, NYG;
extern int NX,NY;
extern int POS[3];
int i=0,j=0;
int ii=0, jj=0;
/* Store local matrix in global matrix */
for (i=1;i<=NXG;i++){
for (j=1;j<=NYG;j++){
if ( (POS[1]==((i-1)/NX)) && (POS[2]==((j-1)/NY)) ) {
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
local_matrix[jj][ii]=global_matrix[j][i];
}
}
}
}
......@@ -25,6 +25,7 @@
float *rd_sour(int *nts,FILE* fp_source){
extern int VERBOSE;
/* local variables */
float *psource;
int i, c;
......@@ -35,7 +36,7 @@ float *rd_sour(int *nts,FILE* fp_source){
while ((c=fgetc(fp_source)) != EOF)
if (c=='\n') ++(*nts);
rewind(fp_source);
printf(" Number of samples (nts) in source file: %i\n",*nts);
if (VERBOSE==1) printf(" Number of samples (nts) in source file: %i\n",*nts);
psource=vector(1,*nts);
for (i=1;i<=*nts;i++) fscanf(fp_source,"%e\n",&psource[i]);
......
......@@ -131,6 +131,7 @@ void read_par_json(FILE *fp, char *fileinp){
extern int WAVESEP;
extern float VEL, DENS, ANGTAPI, ANGTAPO;
extern int STF_FULL;
/* definition of local variables */
int number_readobjects=0,fserr=0;
......@@ -769,6 +770,9 @@ void read_par_json(FILE *fp, char *fileinp){
TRKILL_STF=0;
fprintf(fp,"Variable TRKILL_STF is set to default value %d.\n",TRKILL_STF);}
else {
if (get_int_from_objectlist("STF_FULL",number_readobjects,&STF_FULL,varname_list, value_list)){
STF_FULL=0;
fprintf(fp,"Variable STF_FULL is set to default value %d.\n",STF_FULL);}
if (TRKILL_STF==1) {
if (get_int_from_objectlist("TRKILL_STF_OFFSET",number_readobjects,&TRKILL_STF_OFFSET,varname_list, value_list)){
TRKILL_STF_OFFSET=0;
......
......@@ -24,7 +24,7 @@
void saveseis_glob(FILE *fp, float **sectionvx, float **sectionvy,float **sectionvz,float **sectionp,float **sectioncurl, float **sectiondiv, int **recpos, int **recpos_loc,int ntr, float ** srcpos, int ishot, int ns, int iter, int type_switch){
/* type_switch:
/* type_switch:
* 1== synthetic data
* 2== measured - synthetic data (residuals)
* 3== filtered measured data
......@@ -32,20 +32,21 @@ void saveseis_glob(FILE *fp, float **sectionvx, float **sectionvy,float **sectio
extern int SEISMO, SEIS_FORMAT, RUN_MULTIPLE_SHOTS, WAVETYPE, VERBOSE,FORWARD_ONLY;
extern char SEIS_FILE[STRING_SIZE];
extern int VELOCITY, WRITE_FILTERED_DATA;
char vxf[STRING_SIZE], vyf[STRING_SIZE],vzf[STRING_SIZE], curlf[STRING_SIZE], divf[STRING_SIZE], pf[STRING_SIZE];
int nsrc=1;
switch (type_switch) {
case 1:
sprintf(vxf,"%s_vx.su.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vyf,"%s_vy.su.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vxf,"%s_vx.su.syn.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vyf,"%s_vy.su.syn.shot%d.it%d",SEIS_FILE,ishot,iter);
if(WAVETYPE==2 || WAVETYPE==3) {
sprintf(vzf,"%s_vz.su.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vzf,"%s_vz.su.syn.shot%d.it%d",SEIS_FILE,ishot,iter);
}
sprintf(pf,"%s_p.su.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(divf,"%s_div.su.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(curlf,"%s_curl.su.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(pf,"%s_p.su.syn.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(divf,"%s_div.su.syn.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(curlf,"%s_curl.su.syn.shot%d.it%d",SEIS_FILE,ishot,iter);
break;
case 2:
......@@ -60,14 +61,36 @@ void saveseis_glob(FILE *fp, float **sectionvx, float **sectionvy,float **sectio
break;
case 3:
sprintf(vxf,"%s_vx.su.measured.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vyf,"%s_vy.su.measured.shot%d.it%d",SEIS_FILE,ishot,iter);
if(WRITE_FILTERED_DATA==1){
sprintf(vxf,"%s_vx.su.obs.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vyf,"%s_vy.su.obs.shot%d.it%d",SEIS_FILE,ishot,iter);
if(WAVETYPE==2 || WAVETYPE==3) {
sprintf(vzf,"%s_vz.su.obs.shot%d.it%d",SEIS_FILE,ishot,iter);
}
sprintf(pf,"%s_p.su.obs.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(divf,"%s_div.su.obs.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(curlf,"%s_curl.su.obs.shot%d.it%d",SEIS_FILE,ishot,iter);
}else if(WRITE_FILTERED_DATA==2){
sprintf(vxf,"%s_vx.su.obs.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vyf,"%s_vy.su.obs.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
if(WAVETYPE==2 || WAVETYPE==3) {
sprintf(vzf,"%s_vz.su.obs.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
}
sprintf(pf,"%s_p.su.obs.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(divf,"%s_div.su.obs.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(curlf,"%s_curl.su.obs.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
}
break;
case 4:
sprintf(vxf,"%s_vx.su.syn.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vyf,"%s_vy.su.syn.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
if(WAVETYPE==2 || WAVETYPE==3) {
sprintf(vzf,"%s_vz.su.measured.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(vzf,"%s_vz.su.syn.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
}
sprintf(pf,"%s_p.su.measured.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(divf,"%s_div.su.measured.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(curlf,"%s_curl.su.measured.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(pf,"%s_p.su.syn.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(divf,"%s_div.su.syn.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
sprintf(curlf,"%s_curl.su.syn.adj.shot%d.it%d",SEIS_FILE,ishot,iter);
break;
default:
......
......@@ -46,177 +46,105 @@ void smooth(float ** mat, int sws, int filter, float Vs_avg, float F_LOW_PASS)
char modfile[STRING_SIZE];
if(sws==1){
sprintf(jac_tmp,"%s_g",JACOBIAN);
write_matrix_disk(mat, jac_tmp);
}
float ** global_matrix;
if(sws==2){
sprintf(jac_tmp,"%s_g_u",JACOBIAN);
write_matrix_disk(mat, jac_tmp);
}
global_matrix=get_global_from_local_matrix(mat);
if(sws==3){
sprintf(jac_tmp,"%s_g_rho",JACOBIAN);
write_matrix_disk(mat, jac_tmp);
switch (filter){
case 1:
if((GRAD_FILT_WAVELENGTH==1)&&(TIME_FILT==1)){
if(VERBOSE) printf("\n -------------------------------------------------------------------------- \n");
if(VERBOSE) printf("\n Calculating a wavelength dependent filter size for smoothing the gradient: \n");
FILT_SIZE_GRAD = (int)(Vs_avg/F_LOW_PASS*A/DH);
if(VERBOSE) printf("\n FILT_SIZE_GRAD = Vs_avg = %4.2f m/s / F_LOW_PASS = %4.2f Hz * weighting factor A = %4.2f / grid spacing DH = %4.2f m \n",Vs_avg,F_LOW_PASS,A,DH);
if(VERBOSE) printf("\n New FILT_SIZE_GRAD = %d (grid points) is used (-> %4.2f m). \n",FILT_SIZE_GRAD,FILT_SIZE_GRAD*DH);
}
if (FILT_SIZE_GRAD==0) return;
if (!(FILT_SIZE_GRAD % 2)) {
if (FILT_SIZE_GRAD > 0) FILT_SIZE_GRAD += 1;
else FILT_SIZE_GRAD -= 1;
}
hfs = abs(FILT_SIZE_GRAD)/2;
if(VERBOSE) printf("\n ----------------------------------------------------------------\n");
if(VERBOSE) printf("\n Filter size is %d gridpoints, half filter size is %d gridpoints.\n",FILT_SIZE_GRAD,hfs);
filterpart=matrix(1,abs(FILT_SIZE_GRAD),1,abs(FILT_SIZE_GRAD));
model_tmp = matrix(-hfs+1,NYG+hfs,-hfs+1,NXG+hfs);
break;
case 2:
if (FILT_SIZE==0) return;
if (!(FILT_SIZE % 2)) {
if (FILT_SIZE > 0) FILT_SIZE += 1;
else FILT_SIZE -= 1;
}
hfs = abs(FILT_SIZE)/2;
if(VERBOSE) printf("\n ----------------------------------------------------------------\n");
if(VERBOSE) printf("\n Filter size is %d gridpoints, half filter size is %d gridpoints.\n",FILT_SIZE,hfs);
filterpart=matrix(1,abs(FILT_SIZE),1,abs(FILT_SIZE));
model_tmp = matrix(-hfs+1,NYG+hfs,-hfs+1,NXG+hfs);
break;
}
if(MYID==0){
switch (filter){
case 1:
if((GRAD_FILT_WAVELENGTH==1)&&(TIME_FILT==1)){
if(VERBOSE) printf("\n -------------------------------------------------------------------------- \n");
if(VERBOSE) printf("\n Calculating a wavelength dependent filter size for smoothing the gradient: \n");
FILT_SIZE_GRAD = (int)(Vs_avg/F_LOW_PASS*A/DH);
if(VERBOSE) printf("\n FILT_SIZE_GRAD = Vs_avg = %4.2f m/s / F_LOW_PASS = %4.2f Hz * weighting factor A = %4.2f / grid spacing DH = %4.2f m \n",Vs_avg,F_LOW_PASS,A,DH);
if(VERBOSE) printf("\n New FILT_SIZE_GRAD = %d (grid points) is used (-> %4.2f m). \n",FILT_SIZE_GRAD,FILT_SIZE_GRAD*DH);
}
if (FILT_SIZE_GRAD==0) return;
if (!(FILT_SIZE_GRAD % 2)) {
if (FILT_SIZE_GRAD > 0) FILT_SIZE_GRAD += 1;
else FILT_SIZE_GRAD -= 1;
}
hfs = abs(FILT_SIZE_GRAD)/2;
if(VERBOSE) printf("\n ----------------------------------------------------------------\n");
if(VERBOSE) printf("\n Filter size is %d gridpoints, half filter size is %d gridpoints.\n",FILT_SIZE_GRAD,hfs);
filterpart=matrix(1,abs(FILT_SIZE_GRAD),1,abs(FILT_SIZE_GRAD));
model_tmp = matrix(-hfs+1,NYG+hfs,-hfs+1,NXG+hfs);
break;
case 2:
if (FILT_SIZE==0) return;
if (!(FILT_SIZE % 2)) {
if (FILT_SIZE > 0) FILT_SIZE += 1;
else FILT_SIZE -= 1;
}
hfs = abs(FILT_SIZE)/2;
if(VERBOSE) printf("\n ----------------------------------------------------------------\n");
if(VERBOSE) printf("\n Filter size is %d gridpoints, half filter size is %d gridpoints.\n",FILT_SIZE,hfs);
filterpart=matrix(1,abs(FILT_SIZE),1,abs(FILT_SIZE));
model_tmp = matrix(-hfs+1,NYG+hfs,-hfs+1,NXG+hfs);
break;
}
model_med = matrix(1,NYG,1,NXG);
if(sws==1){
sprintf(jac_tmp,"%s_g.bin",JACOBIAN);
}
if(sws==2){
sprintf(jac_tmp,"%s_g_u.bin",JACOBIAN);
}
if(sws==3){
sprintf(jac_tmp,"%s_g_rho.bin",JACOBIAN);
}
if(sws==4){
sprintf(jac_tmp,"%s_vp.bin",INV_MODELFILE);}
if(sws==5){
sprintf(jac_tmp,"%s_vs.bin",INV_MODELFILE);}
if(sws==6){
sprintf(jac_tmp,"%s_rho.bin",INV_MODELFILE);}
model=fopen(jac_tmp,"rb");
if (model==NULL) declare_error(" Could not open file !");
/* load merged model */
for (i=1;i<=NXG;i++){
for (j=1;j<=NYG;j++){