-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadSpect.m
More file actions
35 lines (28 loc) · 1.01 KB
/
Copy pathReadSpect.m
File metadata and controls
35 lines (28 loc) · 1.01 KB
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
function [file_header, headers, data] = ReadSpect(filename);
%% Reads a .spect file and returns data and metadata
%
% Use: [fileheader, headers, data] = ReadSpect(filename);
% -----------------------------------------------------------------------------
% Author:
% Keegan Lensink
% Seismic Laboratory for Imaging and Modeling
% Department of Earth, Ocean, and Atmospheric Sciences
% The University of British Columbia
%
% Date: March, 2017
% -----------------------------------------------------------------------------
% Open the file for reading
fid = fopen(filename,'r');
% Read the file header
file_header = fread(fid,[4,1],'double');
% Pull out metadata that will be used to read
ns = file_header(3);
ntraces = file_header(4);
% Now read all of the headers, real, and imag data
all = fread(fid, [4+2*ns,ntraces],'double');
% Split of headers, and clear;
headers = all(1:4,:);
%all(1:4,:) = [];
% Reconstruct the complex data
data = complex(all(5:ns+4,:), all(ns+5:end,:));
fclose(fid);