-
Notifications
You must be signed in to change notification settings - Fork 171
/
Mdatasucjb2rsf2d.c
107 lines (83 loc) · 2.87 KB
/
Mdatasucjb2rsf2d.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
/* Convert 2D cjb-SU data to RSF format.
Copyright (C) 2012 Tongji University, Shanghai, China
Authors: Jiubing Cheng
This program 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; either version 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <rsf.h>
/* prepared head files by myself */
#include "_cjb.h"
#include "_cjbsegy.h"
/* head files aumatically produced from *.c */
#include "zero.h"
#include "puthead.h"
/*****************************************************************************************/
int main(int argc, char* argv[])
{
int i;
float *data;
cjbsegy *tr;
char *fn;
FILE *Fi;
sf_file Fo;
int nz, nx;
float fz;
float fx;
float dz;
float dx;
sf_init(argc,argv);
if (NULL==(fn=sf_getstring("fn"))) fn="hess.rtm.absorb.vti.image.su.pc_LF";
/* setup I/O files */
Fo = sf_output("out"); /* pseudo-pure P-wave x-component */
if((Fi=fopen(fn,"rb"))==NULL)
{
printf("File %s open error!\n",fn);
exit(0);
}
tr = calloc(sizeof(cjbsegy),1);
if (1 != fread(tr,sizeof(cjbsegy),1,Fi))
sf_error("fread error:");
nz=(int)tr->ns;
fz=tr->f1;
fx=-5000.0*6.096*2/10;
dz=6.096*2;
dx=6.096*2;
if(fseek(Fi, 0L, 2) ==-1)
printf("input file size unknown; Please specify n2\n");
nx=(int) (ftell(Fi)/((nz+60)*sizeof(float)));
sf_warning("nx=%d nz=%d dx=%f dz=%f",nx,nz,dx,dz);
sf_putint(Fo,"n1",nz);
sf_putint(Fo,"n2",nx);
sf_putfloat(Fo,"d1",dz);
sf_putfloat(Fo,"o1",fz);
sf_putfloat(Fo,"d2",dx);
sf_putfloat(Fo,"o2",fx);
sf_putstring(Fo,"label1","z");
sf_putstring(Fo,"label2","x");
sf_putstring(Fo,"unit1","m");
sf_putstring(Fo,"unit2","m");
data = sf_floatalloc(nz);
rewind(Fi);
for(i=0;;i++)
{
if (1 != fread(tr,sizeof(cjbsegy),1,Fi))
sf_error("fread error:");
if(feof(Fi))break;
if (nz != fread(data,sizeof(float),nz,Fi))
sf_error("fread error:");
sf_floatwrite(data, nz, Fo);
}
fclose(Fi);
free(tr);
free(data);
exit(0);
}