-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvertBINtoSAC.m
49 lines (39 loc) · 1.63 KB
/
convertBINtoSAC.m
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------------------------
%
% A MATLAB code for convert the pressure data in .BIN format from
% Scripps Institution of Oceanography EM instruments to .SAC format.
%
%
% Written by Guilherme de Melo
% Scripps Institution of Oceanography
%
%
% v 1.0 April 2022 first version using getsio ([email protected]) and
% MKSAC (https://github.com/IPGP/sac-lib/) codes
%
% GITHUB: https://github.com/gwsmelo/convertSIO_BIN2SAC
%
%--------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; clc;
%%%%filename with complete data of the instrument
filename ='s3mendo_goldfish_s03.bin';
%%%%open the file%%%%
[stFile, ~] = getsio('header',filename,'off');
%%%%find the start and end time%%%%%
starttime = datevec(stFile.datastart + 1);
%t%%total time of file in seconds%%%%%
timelength=5360786;
%%%%get the data with total time length######
[stFile,errmsg] = getsio('times',stFile,starttime,'time',timelength);
%%%%select the pressure channel in instrument#####
pressurechannel=stFile.data(5,:);
%%%%create variable with the start time updated
pressurechannelStartTime=stFile.dStart(1,:)
%%%%convert the data in MATLAB variable to .SAC format using MKSAC
mksac('s3mendo_goldfish_s03_test.sac',pressurechannel,pressurechannelStartTime,'DELTA',(1/62.5),'KSTNM','s3mendo','KCMPNM','SHZ');
%%s3mendo_goldfish_s03_test.sac -> output file in SAC format
%%%DELTA = time increment
%%%KSTNM = station name
%%%KCMPNM = channel