-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mwinft.c
130 lines (107 loc) · 3.09 KB
/
Mwinft.c
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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* Windowed FFT to get Frequency dependent Trace gather */
/**********************************************************************************
* Copyright(C), By SINOPEC Geophysical Research Institute, Nanjing, CN
*
* File Name: Mwinft.c
*
* Authors: Heng Luo & Long Teng
*
* Date: 2014/11/03
*
* ********************************************************************************/
#include <rsf.h>
#include "st_avf.h"
int main( int argc , char* argv[] )
{
sf_init( argc , argv );
float ***data, ****data_out;
int ix, nx, iy, ny, it, nt, nfft, nw, iw;
/*
* @ Setup the parameters of the dimensions of the DATASETS
* @ the Output Parameters also be setup
*/
sf_file Fi=NULL, Fo=NULL;
/*
* @ Setup the FILE POINT of Input Data and Output Frequency Dependent Trace
*/
sf_axis at, ax, ay, aw;
/*
* @ Setup the AXISes of DataSETS
*/
float var;
/*
* @ Variance of the Window Function in FT
*/
int dim, num_dim[SF_MAX_DIM];
float dt, dw, nw_s, fre;
if(!sf_getint ( "nw" , &nw )) sf_error( "Missing nw!\n" );
/* Input Parameter: the Number of Slicing in FD */
if(!sf_getfloat( "nw_s" , &nw_s)) sf_error( "Missing nw_s!\n" );
/* Input Parameter: the starting number of frequency */
if(!sf_getfloat( "dw" , &dw )) sf_error( "Missing dw!\n" );
/* Input Parameter: the interval of OUTPUT frequency */
if(!sf_getint( "nfft" , &nfft )) sf_error( "Missing nfft!\n" );
/* Input Parameter: the length of FFT */
if(!sf_getfloat( "variance" , &var )) sf_error( "Missing variance!\n" );
/* the variance of the window */
Fi = sf_input ( "data_in" );
Fo = sf_output( "data_out" );
dim = sf_filedims( Fi , num_dim );
if( dim==1 )
{
at = sf_iaxa( Fi , 1 );
nt = sf_n( at );
dt = sf_d( at );
nx = 1;
ny = 1;
}
else if( dim==2 )
{
at = sf_iaxa( Fi , 1 );
nt = sf_n( at );
dt = sf_d( at );
ax = sf_iaxa( Fi , 2 );
nx = sf_n( ax );
ny = 1;
}
else if( dim==3 )
{
at = sf_iaxa( Fi , 1 );
nt = sf_n( at );
dt = sf_d( at );
ax = sf_iaxa( Fi , 2 );
nx = sf_n( ax );
ay = sf_iaxa( Fi , 3 );
ny = sf_n( ay );
}
else
{
sf_error( "DIMENSION WRONG!\n" );
}
data = sf_floatalloc3( nt , nx , ny );
data_out = sf_floatalloc4( nt , nw , nx , ny );
sf_floatread( &data[0][0][0] , nt*nx*ny , Fi );
for( iy=0 ; iy<ny ; iy++ )
for( ix=0 ; ix<nx ; ix++ )
for( iw=0 ; iw<nw ; iw++ )
{
fre = nw_s+dw*iw;
winft( &data[iy][ix][0] , &data_out[iy][ix][iw][0] , nt , nfft , dt , fre , var );
}
aw = sf_maxa( nw , nw_s , dw );
sf_oaxa( Fo , at , 1 );
sf_oaxa( Fo , aw , 2 );
if( dim==2 )
{
sf_oaxa( Fo , ax , 3 );
}
if( dim==3 )
{
sf_oaxa( Fo , ax , 3 );
sf_oaxa( Fo , ay , 4 );
}
sf_floatwrite( &data_out[0][0][0][0] , ny*nx*nw*nt , Fo );
free( data );
free( data_out );
exit( 0 );
}