⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makeing_data.c

📁 人工合成记录的程序
💻 C
字号:
#include "stdafx.h"
#include "stdio.h"
#include "math.h"
#define length 130
#define NShot 1
#define Channel 100
#define Station_Interval 30
#define Sample_Point 2000
#define T_RATE 0.001


float data[NShot][Channel][Sample_Point];

int delay_time[NShot][Channel][2]; /*Delay Time*/
float r[NShot][Channel][2]; 

void geom()
{
	int i,j,a=3,b=3;
	int freq_main=30;   /*Dominate Frequency*/
    float h=1000;       /*Datum Elevation*/
	float v=3000;      /*Interval Velocity*/
    const double pi=3.1415926;
	float tmp1,tmp2;
	float sx[NShot],sz[NShot];
	float rx[NShot][Channel],rz[NShot][Channel];
	float midx[NShot][Channel],midz[NShot][Channel];

	FILE *fp,*out;
	
	if((fp=fopen("surf.txt","w+")) == NULL) {
		printf("can't open the file\n");
	}

	if((out=fopen("delay&r.txt","w+")) == NULL) {
		printf("can't open the file\n");
	}
/*-----------------Define Shot Point  Coordinate------------------------*/
    
	for (i=0;i<NShot;i++) {
		  sx[i] =0;
          sz[i] =0;
		  
	}


/*---------------Define Reciever Station Coordinate------------------------*/
    
	for (i=0;i<NShot;i++) {
	  for (j=0;j<Channel;j++) {
		  rx[i][j] = (float) ( Station_Interval*j );
          rz[i][j] = a*120*sin(2*pi*b*rx[i][j]/120.0);
		  fprintf(fp,"%7.2f,%7.2f;",rx[i][j],rz[i][j]);
	  }
	}

  fclose(fp);

/*---------Define Delay Time(include The First Break and Reflection)-----------*/

    for (i=0;i<NShot;i++) {
        for (j=0;j<Channel;j++) {
            r[i][j][1] = sqrt((sx[i]-rx[i][j])*(sx[i]-rx[i][j])+(sz[i]-rz[i][j])*(sz[i]-rz[i][j]));
            midx[i][j]=0.5*(sx[i]+rx[i][j]);
			midz[i][j]=0.5*(sz[i]+rz[i][j])-h;
            tmp1 = sqrt((sx[i]-midx[i][j])*(sx[i]-midx[i][j])+(sz[i]-midz[i][j])*(sz[i]-midz[i][j]));
            tmp2 = sqrt((rx[i][j]-midx[i][j])*(rx[i][j]-midx[i][j])+(rz[i][j]-midz[i][j])*(rz[i][j]-midz[i][j]));
            r[i][j][2] = tmp1 + tmp2;
			delay_time[i][j][1] = (int)( r[i][j][1]/(T_RATE*v) );
            delay_time[i][j][2] = (int)( r[i][j][2]/(T_RATE*v) );
			fprintf(out,"%7.2f %7d, %7.2f %7d\n",r[i][j][1],delay_time[i][j][1],r[i][j][2],delay_time[i][j][2]);
		}
	}
	fclose(out);
}

void ricker(int Lr,int L,float dalt,float fp,float *w)
{
	double temp;
	double pi;
	int Ll;
	int k,i;
	Ll = L - Lr - 1;
	pi = 4.0 * atan(1.0);
	for(i = -Lr; i <= Ll; i++)
	{
		k = i + Lr;
		temp = pi * fp * (dalt * i);
		temp *= temp;
		w[k] = (float) ( (1.0 - 2.0 * temp) *  exp(-temp) );
		//printf("%5d %10.6f\n",k,w[k]);

	}
	return;
}

int making_data( )
{
	int i,j,k,m,n,p,q;
	static float w[130];

	FILE *fp;

	if((fp = fopen("data.txt","w")) == NULL)
	{
		printf("----cannot open  data file --\n");
		return 0; 
	}

		
	ricker(30,100,0.001,30.0,w);
	geom(r,delay_time);

	for ( i=0;i<NShot;i++ ) {
		for ( j=0;j<Channel;j++) {
			for ( k=0;k<Sample_Point;k++) {
				 
			     data[i][j][k]=0;
                 for ( m=0;m<length;m++ ) {
					 p = delay_time[i][j][1];
				     data[i][j][p+m]=w[m];
				 }
                 for ( n=0;n<length;n++ ) {
					q = delay_time[i][j][2];
				    data[i][j][q+n]=w[n]; 
				    
				 }
              fprintf(fp,"%7.2f\n",data[i][j][k]);
			 //fwrite(&data[i][j][k], sizeof(float), 1, fp);
			}
		
              //fwrite(&data[i][j], sizeof(float), Sample_Point, fp);
		}
	}
			
	
	fclose(fp);
}


main()
{
	

	making_data(  );
	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -