-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetnrecs.m
30 lines (26 loc) · 941 Bytes
/
getnrecs.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
% Script to return the number of records in a binary ACM file.
% pep/18Oct12
%
% Arguments:
% fname : Filename to operate on.
%
% Returns:
% ntimes : Total number of timeslices found.
% tmin : The MJDsec timestamp of the first record.
% tmax : The MJDsec timestamp of the last record.
% dt : The time resolution of the records.
function [ntimes, tmin, tmax, dt] = getnrecs (fname)
D = dir (fname);
fid = fopen (fname, 'rb');
fseek (fid, 0, 'bof'); % Go to beginning of file
Nelem = 288;
nblines = Nelem * (Nelem + 1)/2;
tobs = 1; freqobs = 1;
recsize = 8*(2+nblines); % NOTE: Works only for single channel data!
ntimes = D.bytes / recsize;
[acc, tmin, freq] = readms2float (fid, -1, -1, 288);
[acc, tobs, freq] = readms2float (fid, -1, -1, 288);
fseek (fid, -recsize, 'eof'); % Go to the end of the file.
[acc, tmax, freq] = readms2float (fid, -1, -1, 288);
dt = tobs - tmin;
fclose (fid);