Added initial MATLAB script to convert gprMax output to some common GPR formats (RD3, DZT, DT1).

这个提交包含在:
Craig Warren
2018-04-04 16:31:01 +01:00
父节点 1acd8e461a
当前提交 57520e0865

查看文件

@@ -1,14 +1,15 @@
%gprMax_output_converter, Angelis Dimitrios 2017, 2018 % outputfile_converter.m - converts gprMax merged output HDF5 file to RD3, DZT, DT1 files.
%Converts the gprMax merged output HDF5 file to RD3, DZT, DT1 files. %
% Author: Dimitrios Angelis
% Copyright: 2017-2018
% Last modified: 25/03/2018
%Last Modified 25/03/2018 clear, clc, close all;
clear; close all; clc; % Select file. Keep file name, path name and file extension ==============
[infile, path] = uigetfile('*.out', 'Select gprMax output file', 'Multiselect', 'Off');
%Select file. Keep file name, path name and file extension ================
[infile, path] = uigetfile('*.out', 'Select gprMax File', 'Multiselect', 'Off');
if isequal(infile, 0) if isequal(infile, 0)
erd = errordlg('No Input File'); erd = errordlg('No output file');
but = findobj(erd, 'Style', 'Pushbutton'); but = findobj(erd, 'Style', 'Pushbutton');
delete(but); delete(but);
pause(1); close(erd); pause(1); close(erd);
@@ -20,13 +21,13 @@ HDR.pname = path;
HDR.fext = 'out'; HDR.fext = 'out';
%Read data from HDF5 file ================================================= % Read data from HDF5 file ===============================================
dataex = h5read(infile, '/rxs/rx1/Ex'); dataex = h5read(infile, '/rxs/rx1/Ex');
dataey = h5read(infile, '/rxs/rx1/Ey'); dataey = h5read(infile, '/rxs/rx1/Ey');
dataez = h5read(infile, '/rxs/rx1/Ez'); dataez = h5read(infile, '/rxs/rx1/Ez');
%Field check ============================================================== % Field check ============================================================
if dataey == 0 & dataez == 0 if dataey == 0 & dataez == 0
data = dataex'; data = dataex';
elseif dataex == 0 & dataez == 0 elseif dataex == 0 & dataez == 0
@@ -47,15 +48,15 @@ else
end end
%Single to double precision =============================================== % Convert to double precision ============================================
data = double(data); data = double(data);
%The HDF5 file doesn't contain information about the Tx Rx distance and the % The HDF5 file does not contain information about the Tx-Rx separation ==
%trace step. We need to provide this information ========================== % distance and the trace step. The user needs to provide this information
while 1 while 1
prompt = {'Antenna Seperation (m)', 'Trace Step (m)'}; prompt = {'Antenna Separation (m)', 'Trace Step (m)'};
dlg_title = 'gprMax Information'; dlg_title = 'gprMax information';
answer = inputdlg(prompt, dlg_title, [1 45]); answer = inputdlg(prompt, dlg_title, [1 45]);
answer = str2double(answer); answer = str2double(answer);
if isempty(answer) if isempty(answer)
@@ -69,22 +70,23 @@ while 1
end end
%Create header ===================================================== Basic information % Create header with basic informatio =====================================
info = h5info(infile); info = h5info(infile);
attributes = info.Attributes; attributes = info.Attributes;
% Antenna name
if length(attributes) > 4 if length(attributes) > 4
gMaxV = cell2mat(h5readatt(infile, '/', 'gprMax')); gMaxV = cell2mat(h5readatt(infile, '/', 'gprMax'));
HDR.antenna = (['gprMax ', gMaxV]); %Antenna name HDR.antenna = (['gprMax ', gMaxV]);
else else
HDR.antenna = ('gprMax'); %Antenna name HDR.antenna = ('gprMax');
end end
HDR.ant_sep = answer(1); %Tx Rx distance HDR.ant_sep = answer(1); % Tx-Rx separation distance
[HDR.num_samp, HDR.num_trac] = size(data); %Samples & traces [HDR.num_samp, HDR.num_trac] = size(data); % Samples & traces
HDR.trac_int = answer(2); %Trace interval HDR.trac_int = answer(2); % Trace interval
HDR.samp_int = h5readatt(infile, '/', 'dt') * 10^9; %Sampling interval HDR.samp_int = h5readatt(infile, '/', 'dt') * 10^9; % Sampling interval
HDR.samp_freq = (1 / HDR.samp_int) * 10^3; %Sampling Frequency HDR.samp_freq = (1 / HDR.samp_int) * 10^3; % Sampling Frequency
HDR.time_window = HDR.num_samp * HDR.samp_int; %Time window HDR.time_window = HDR.num_samp * HDR.samp_int; % Time window
x = 0 : HDR.trac_int : (HDR.num_trac - 1) * HDR.trac_int; x = 0 : HDR.trac_int : (HDR.num_trac - 1) * HDR.trac_int;
t = HDR.samp_int : HDR.samp_int : HDR.num_samp * HDR.samp_int; t = HDR.samp_int : HDR.samp_int : HDR.num_samp * HDR.samp_int;
@@ -93,16 +95,16 @@ t = HDR.samp_int : HDR.samp_int : HDR.num_samp * HDR.samp_int;
%************************************************************************** %**************************************************************************
%******************************** Optional ******************************** %******************************** Optional ********************************
%Resample to 1024 samples ================================================= % Resample to 1024 samples ================================================
%I usually perform this step for either 512 or 1024 samples (line 98) % I usually perform this step for either 512 or 1024 samples (line 98)
%because many programs cant load files with many samples. % because many programs cannot load files with more samples.
tx1 = 1 : HDR.num_samp; tx1 = 1 : HDR.num_samp;
fs1 = 1024 / HDR.num_samp; fs1 = 1024 / HDR.num_samp;
data = resample(data, tx1, fs1); data = resample(data, tx1, fs1);
[HDR.num_samp, ~] = size(data); %New number of samples [HDR.num_samp, ~] = size(data); % New number of samples
HDR.samp_int = HDR.time_window / HDR.num_samp; %New sampling interval HDR.samp_int = HDR.time_window / HDR.num_samp; % New sampling interval
HDR.samp_freq = (1 / HDR.samp_int) * 10^3; %New sampling frequency HDR.samp_freq = (1 / HDR.samp_int) * 10^3; % New sampling frequency
%************************************************************************** %**************************************************************************
%************************************************************************** %**************************************************************************
@@ -111,8 +113,9 @@ HDR.samp_freq = (1 / HDR.samp_int) * 10^3; %New sampli
%************************************************************************** %**************************************************************************
%******************************** Optional ******************************** %******************************** Optional ********************************
%Data scale =============================================================== % Data scale ==============================================================
data = data * 32767.5 ./ max(max(abs(data))); %signal * ((1 - 1 / 2^bitrate) * 32768) / max(signal) data = data * 32767.5 ./ max(max(abs(data)));
%signal * ((1 - 1 / 2^bitrate) * 32768) / max(signal)
data(data >= 32767.5) = 32767; data(data >= 32767.5) = 32767;
data = round(data); data = round(data);
@@ -120,11 +123,11 @@ data = round(data);
%************************************************************************** %**************************************************************************
%Plots ==================================================================== % Plots ===================================================================
pmin = min(data(:)); pmin = min(data(:));
pmax = max(data(:)); pmax = max(data(:));
%Bscan % Bscan
f1 = figure('Name', 'Bscan', ... f1 = figure('Name', 'Bscan', ...
'NumberTitle', 'off', ... 'NumberTitle', 'off', ...
'Menubar', 'None', ... 'Menubar', 'None', ...
@@ -134,12 +137,17 @@ clims = [pmin pmax];
colormap (flipud(bone(256))); colormap (flipud(bone(256)));
im1 = imagesc(x, t, data, clims); im1 = imagesc(x, t, data, clims);
set(im1, 'cdatamapping', 'scaled'); set(im1, 'cdatamapping', 'scaled');
title(HDR.fname); xlabel('Distance (m)'); ylabel('Time (ns)'); title(HDR.fname);
ax1 = gca; ax1.XAxisLocation = 'Top'; ax1.FontSize = 12; xlabel('Distance (m)');
box off; movegui(f1, 'northeast'); ylabel('Time (ns)');
ax1 = gca;
ax1.XAxisLocation = 'Top';
ax1.FontSize = 12;
box off;
movegui(f1, 'northeast');
%Frequency Spectrum % Frequency Spectrum
m = 2.^nextpow2(HDR.num_samp); m = 2.^nextpow2(HDR.num_samp);
amp = fft(data, m); amp = fft(data, m);
@@ -153,12 +161,16 @@ f2 = figure('Name', 'Frequency Spectrum', ...
'Toolbar', 'Figure'); 'Toolbar', 'Figure');
area(freq, amp, 'FaceColor', 'black'); area(freq, amp, 'FaceColor', 'black');
title(HDR.fname); xlabel('Frequency (MHz)'); ylabel('Amplitude'); title(HDR.fname);
ax2 = gca; ax2.FontSize = 12; xlabel('Frequency (MHz)');
box off; movegui(f2, 'southeast'); ylabel('Amplitude');
ax2 = gca;
ax2.FontSize = 12;
box off;
movegui(f2, 'southeast');
%Export option rd3 or dzt or dt1 ========================================== % Export option rd3 or dzt or dt1 =========================================
while 1 while 1
choice = questdlg('File Type', 'Export', ... choice = questdlg('File Type', 'Export', ...
'RD3', 'DZT', 'DT1', 'Default'); 'RD3', 'DZT', 'DT1', 'Default');
@@ -178,40 +190,40 @@ end
wb = waitbar(0, 'Exporting...', 'Name', 'Exporting File'); wb = waitbar(0, 'Exporting...', 'Name', 'Exporting File');
%RAD / RD3, Mala GeoScience =============================================== % RAD / RD3, Mala GeoScience ==============================================
%Rad is the header file. In this file are contained all the important % Rad is the header file. In this file is all the important
%information such as the number of traces, samples, measurement intervals... % information such as the number of traces, samples, measurement intervals...
%Rd3 is the data file. This file contain only the data (amplitudes) in a % Rd3 is the data file. This file contains only the data (amplitudes) in a
%binary form. % binary form.
if flg == 1 if flg == 1
%Header structure % Header structure
HDR.fname = HDR.fname; %File name HDR.fname = HDR.fname; % File name
HDR.num_samp = HDR.num_samp; %Number of samples HDR.num_samp = HDR.num_samp; % Number of samples
HDR.samp_freq = HDR.samp_freq; %Sampling frequency HDR.samp_freq = HDR.samp_freq; % Sampling frequency
HDR.frequency_steps = 1; %Frequency steps HDR.frequency_steps = 1; % Frequency steps
HDR.signal_pos = 0; HDR.signal_pos = 0;
HDR.raw_signal_pos = 0; HDR.raw_signal_pos = 0;
HDR.distance_flag = 1; %Distance flag: 0 time interval, 1 distance interval HDR.distance_flag = 1; % Distance flag: 0 time interval, 1 distance interval
HDR.time_flag = 0; %Time flag : 0 distance interval, 1 time interval HDR.time_flag = 0; % Time flag : 0 distance interval, 1 time interval
HDR.program_flag = 0; HDR.program_flag = 0;
HDR.external_flag = 0; HDR.external_flag = 0;
HDR.trac_int_sec = 0; %Trace interval in seconds(only if Time flag = 1) HDR.trac_int_sec = 0; % Trace interval in seconds(only if Time flag = 1)
HDR.trac_int = HDR.trac_int; %Trace interval in meters (only if Distance flag = 1) HDR.trac_int = HDR.trac_int; % Trace interval in meters (only if Distance flag = 1)
HDR.operator = 'Unknown'; HDR.operator = 'Unknown';
HDR.customer = 'Unknown'; HDR.customer = 'Unknown';
HDR.site = 'gprMax'; HDR.site = 'gprMax';
HDR.antenna = HDR.antenna; %Antenna name HDR.antenna = HDR.antenna; % Antenna name
HDR.antenna_orientation = 'NOT VALID FIELD'; HDR.antenna_orientation = 'NOT VALID FIELD';
HDR.ant_sep = HDR.ant_sep; %Antenna seperation (Tx-Rx distance) HDR.ant_sep = HDR.ant_sep; % Antenna seperation (Tx-Rx distance)
HDR.comment = '-'; HDR.comment = '-';
HDR.time_window = HDR.time_window; %Time window HDR.time_window = HDR.time_window; % Time window
HDR.stacks = 0; %Stacks HDR.stacks = 0; % Stacks
HDR.stack_exponent = 0; %Stack exponent HDR.stack_exponent = 0; % Stack exponent
HDR.stacking_time = 0; %Stacking Time HDR.stacking_time = 0; % Stacking Time
HDR.num_trac = HDR.num_trac; %Number of traces HDR.num_trac = HDR.num_trac; % Number of traces
HDR.stop_pos = HDR.num_trac * HDR.trac_int; %Stop position (meters) HDR.stop_pos = HDR.num_trac * HDR.trac_int; % Stop position (meters)
HDR.system_calibration = 0; HDR.system_calibration = 0;
HDR.start_pos = 0; %Start position (meters) HDR.start_pos = 0; % Start position (meters)
HDR.short_flag = 1; HDR.short_flag = 1;
HDR.intermediate_flag = 0; HDR.intermediate_flag = 0;
HDR.long_flag = 0; HDR.long_flag = 0;
@@ -225,7 +237,7 @@ if flg == 1
HDR.wheel_calibration = 0; HDR.wheel_calibration = 0;
HDR.positive_direction = 1; HDR.positive_direction = 1;
%RAD file % RAD file
fid = fopen([HDR.fname '.rad'], 'w'); fid = fopen([HDR.fname '.rad'], 'w');
fprintf(fid, 'SAMPLES:%i\r\n', HDR.num_samp); fprintf(fid, 'SAMPLES:%i\r\n', HDR.num_samp);
fprintf(fid, 'FREQUENCY:%0.6f\r\n', HDR.samp_freq); fprintf(fid, 'FREQUENCY:%0.6f\r\n', HDR.samp_freq);
@@ -267,38 +279,38 @@ if flg == 1
fprintf(fid, 'POSITIVE DIRECTION:%i\r\n', HDR.positive_direction); fprintf(fid, 'POSITIVE DIRECTION:%i\r\n', HDR.positive_direction);
fclose(fid); fclose(fid);
%RD3 file % RD3 file
fid = fopen([HDR.fname '.rd3'], 'w'); fid = fopen([HDR.fname '.rd3'], 'w');
fwrite(fid, data, 'short'); fwrite(fid, data, 'short');
fclose(fid); fclose(fid);
%DZT, Geophysical Survey Systems Inc. (GSSI) ============================== % DZT, Geophysical Survey Systems Inc. (GSSI) =============================
%Dzt is a binary file that consists of the file header with all the % Dzt is a binary file that consists of the file header with all the
%important information (number of traces, samples, channels, etc.) followed % important information (number of traces, samples, channels, etc.) followed
%by the data section. % by the data section.
%Every information that is needed is contained in this file except the % All information that is needed is contained in this file except the
%TxRx distance (antenna seperation). There is a possibility that the % TxRx distance (antenna separation). There is a possibility that the
%official GSSI software has stored this information and by using the % official GSSI software has stored this information and by using the
%antenna name presents the correct one. All the other software doesn't % antenna name presents the correct one. All the other software does not
%detect the TxRx distance. % detect the TxRx distance.
elseif flg == 2 elseif flg == 2
%Header structure % Header structure
HDR.fname = HDR.fname; %File name HDR.fname = HDR.fname; % File name
HDR.tag = 255; %Header = 255 HDR.tag = 255; % Header = 255
HDR.data_offset = 1024; %Offset to data from the beginning of file HDR.data_offset = 1024; % Offset to data from the beginning of file
HDR.num_samp = HDR.num_samp; %Number of samples HDR.num_samp = HDR.num_samp; % Number of samples
HDR.bits_per_word = 16; %Bits per data word (8, 16, 32) HDR.bits_per_word = 16; % Bits per data word (8, 16, 32)
HDR.binary_offset = 32768; %Binary offset, 8 bit = 128, 16 bit = 32768 HDR.binary_offset = 32768; % Binary offset, 8 bit = 128, 16 bit = 32768
HDR.scans_per_second = 0; %Scans per second HDR.scans_per_second = 0; % Scans per second
HDR.scans_per_meter = 1 / HDR.trac_int; %Scans per meter HDR.scans_per_meter = 1 / HDR.trac_int; % Scans per meter
HDR.meters_per_mark = 0; %Meters per mark HDR.meters_per_mark = 0; % Meters per mark
HDR.zero_time_adjustment = 0; %Zero time adjustment (nanoseconds) HDR.zero_time_adjustment = 0; % Time zero adjustment (nanoseconds)
HDR.time_window = HDR.time_window; %Time window (with no corrections i.e zero time) HDR.time_window = HDR.time_window; % Time window (with no corrections i.e zero time)
HDR.scans_per_pass = 0; %Scan per pass for 2D files HDR.scans_per_pass = 0; % Scan per pass for 2D files
HDR.createdate.sec = 0 / 2; %Structure, date created HDR.createdate.sec = 0 / 2; % Structure, date created
HDR.createdate.min = 0; HDR.createdate.min = 0;
HDR.createdate.hour = 0; HDR.createdate.hour = 0;
HDR.createdate.day = 0; HDR.createdate.day = 0;
@@ -306,31 +318,31 @@ elseif flg == 2
HDR.createdate.year = 0 - 1980; HDR.createdate.year = 0 - 1980;
date_time = clock; date_time = clock;
HDR.modifydate.sec = date_time(6) / 2; %Structure, date modified HDR.modifydate.sec = date_time(6) / 2; % Structure, date modified
HDR.modifydate.min = date_time(5); HDR.modifydate.min = date_time(5);
HDR.modifydate.hour = date_time(4); HDR.modifydate.hour = date_time(4);
HDR.modifydate.day = date_time(3); HDR.modifydate.day = date_time(3);
HDR.modifydate.month = date_time(2); HDR.modifydate.month = date_time(2);
HDR.modifydate.year = date_time(1) - 1980; HDR.modifydate.year = date_time(1) - 1980;
HDR.offset_to_range_gain = 0; %Offset to range gain HDR.offset_to_range_gain = 0; % Offset to range gain
HDR.size_of_range_gain = 0; %Size of range gain HDR.size_of_range_gain = 0; % Size of range gain
HDR.offset_to_text = 0; %Offset to text HDR.offset_to_text = 0; % Offset to text
HDR.size_of_text = 0; %Size of text HDR.size_of_text = 0; % Size of text
HDR.offset_to_proc_his = 0; %Offset to processing history HDR.offset_to_proc_his = 0; % Offset to processing history
HDR.size_of_proc_his = 0; %Size of processing hisstory HDR.size_of_proc_his = 0; % Size of processing hisstory
HDR.num_channels = 1; %Number of channels HDR.num_channels = 1; % Number of channels
HDR.dielectric_constant = 8; %Dielectric constant (8 is a random number) HDR.dielectric_constant = 8; % Dielectric constant (8 is a random number)
HDR.top_position = 0; %Top position HDR.top_position = 0; % Top position
c = 299792458; c = 299792458;
v = (c / sqrt(HDR.dielectric_constant)) * 10^-9; v = (c / sqrt(HDR.dielectric_constant)) * 10^-9;
HDR.range_depth = v * (HDR.time_window / 2); %Range depth HDR.range_depth = v * (HDR.time_window / 2); % Range depth
HDR.reserved = zeros(31, 1); %Reserved HDR.reserved = zeros(31, 1); % Reserved
HDR.data_type = 0; HDR.data_type = 0;
if length(HDR.antenna) == 14 %Antenna name if length(HDR.antenna) == 14 % Antenna name
HDR.antenna = HDR.antenna; HDR.antenna = HDR.antenna;
elseif length(HDR.antenna) < 14 elseif length(HDR.antenna) < 14
HDR.antenna = pad(HDR.antenna, 14, 'right'); HDR.antenna = pad(HDR.antenna, 14, 'right');
@@ -338,22 +350,22 @@ elseif flg == 2
HDR.antenna = HDR.antenna(1 : 14); HDR.antenna = HDR.antenna(1 : 14);
end end
HDR.channel_mask = 0; %Channel mask HDR.channel_mask = 0; % Channel mask
if length(HDR.fname) == 12 if length(HDR.fname) == 12
HDR.raw_file_name = HDR.fname; %Raw file name (File name during survey) HDR.raw_file_name = HDR.fname; % Raw file name (File name during survey)
elseif length(HDR.fname) < 12 elseif length(HDR.fname) < 12
HDR.raw_file_name = pad(HDR.fname, 12, 'right'); HDR.raw_file_name = pad(HDR.fname, 12, 'right');
elseif length(HDR.fname) > 12 elseif length(HDR.fname) > 12
HDR.raw_file_name = HDR.fname(1:12); HDR.raw_file_name = HDR.fname(1:12);
end end
HDR.checksum = 0; %Checksum HDR.checksum = 0; % Checksum
HDR.num_gain_points = 0; %Number of gain points HDR.num_gain_points = 0; % Number of gain points
HDR.range_gain_db = []; %Range gain in db HDR.range_gain_db = []; % Range gain in db
HDR.variable = zeros(896, 1); HDR.variable = zeros(896, 1);
%DZT file % DZT file
fid = fopen([HDR.fname '.dzt'], 'w'); fid = fopen([HDR.fname '.dzt'], 'w');
fwrite(fid, HDR.tag, 'ushort'); fwrite(fid, HDR.tag, 'ushort');
fwrite(fid, HDR.data_offset, 'ushort'); fwrite(fid, HDR.data_offset, 'ushort');
@@ -404,72 +416,72 @@ elseif flg == 2
fclose(fid); fclose(fid);
%HD / DT1, Sensors & Software Inc. ======================================== % HD / DT1, Sensors & Software Inc. =======================================
%Hd is the header file. In this file can be found all the important % Hd is the header file. In this file is all the important
%information such as the number of traces, samples, stacks, etc. % information such as the number of traces, samples, stacks, etc.
%Dt1 is the data file written in binary form. This file contains as many % Dt1 is the data file written in binary form. This file contains as many
%records as there are traces. Each record consists of a header section and % records as there are traces. Each record consists of a header section and
%a data section. That means that in this file there are also stored % a data section. That means that in this file there are also stored
%information such as the number of samples, traces, etc. % information such as the number of samples, traces, etc.
elseif flg == 3 elseif flg == 3
%Header structure of HD %Header structure of HD
HDR.fname = HDR.fname; %File name HDR.fname = HDR.fname; % File name
HDR.file_tag = 1234; %File tag = 1234 HDR.file_tag = 1234; % File tag = 1234
HDR.system = ['Data Collected with ' HDR.antenna]; HDR.system = ['Data Collected with ' HDR.antenna];
date_time = clock; date_time = clock;
HDR.date = ([num2str(date_time(3)), '/' ... HDR.date = ([num2str(date_time(3)), '/' ...
num2str(date_time(2)), '/' ... num2str(date_time(2)), '/' ...
num2str(date_time(1))]); %Date num2str(date_time(1))]); % Date
HDR.num_trac = HDR.num_trac; %Number of traces HDR.num_trac = HDR.num_trac; % Number of traces
HDR.num_samp = HDR.num_samp; %Number of samples HDR.num_samp = HDR.num_samp; % Number of samples
HDR.time_zero_point = 0; HDR.time_zero_point = 0;
HDR.time_window = HDR.time_window; %Total time window HDR.time_window = HDR.time_window; % Total time window
HDR.start_position = 0; HDR.start_position = 0;
HDR.final_position = (HDR.num_trac - 1 ) * HDR.trac_int; HDR.final_position = (HDR.num_trac - 1 ) * HDR.trac_int;
HDR.trac_int = HDR.trac_int; %Trace interval HDR.trac_int = HDR.trac_int; % Trace interval
HDR.pos_units = 'm'; %Position units HDR.pos_units = 'm'; % Position units
HDR.nominal_freq = 'Unknown'; %Nominal frequency HDR.nominal_freq = 'Unknown'; % Nominal frequency
HDR.ant_sep = HDR.ant_sep; %Antenna seperation HDR.ant_sep = HDR.ant_sep; % Antenna separation
HDR.pulser_voltage = 'Unknown'; %Pulser voltage (V) HDR.pulser_voltage = 'Unknown'; % Pulser voltage (V)
HDR.stacks = 0; %Number of stacks HDR.stacks = 0; % Number of stacks
HDR.survey_mode = 'Reflection'; %Survey mode HDR.survey_mode = 'Reflection'; % Survey mode
HDR.odometer = 0; %Odometer Cal (t/m) HDR.odometer = 0; % Odometer Cal (t/m)
HDR.stacking_type = 'F1'; %Stacking type (Not using 'Unknown' in case it causes any problems) HDR.stacking_type = 'F1'; % Stacking type (Not using 'Unknown' in case it causes any problems)
HDR.dvl_serial = '0000-0000-0000'; %DVL serial HDR.dvl_serial = '0000-0000-0000'; % DVL serial
HDR.console_serial = '000000000000'; %Console serial HDR.console_serial = '000000000000'; % Console serial
HDR.tx_serial = '0000-0000-0000'; %Transmitter serial HDR.tx_serial = '0000-0000-0000'; % Transmitter serial
HDR.rx_serial = '0000-0000-0000'; %Receiver Serial HDR.rx_serial = '0000-0000-0000'; % Receiver Serial
%Header structure of DT1 % Header structure of DT1
HDR.num_each_trac = 1 : 1 : HDR.num_trac; %Number of each trace 1, 2, 3, ... num_trac HDR.num_each_trac = 1 : 1 : HDR.num_trac; % Number of each trace 1, 2, 3, ... num_trac
HDR.position = 0 : HDR.trac_int : ... HDR.position = 0 : HDR.trac_int : ...
(HDR.num_trac - 1) * HDR.trac_int; %Position of each trace (Xaxis) (HDR.num_trac - 1) * HDR.trac_int; % Position of each trace (Xaxis)
HDR.num_samp_each_trac = zeros(1, HDR.num_trac) + HDR.num_samp; %Number of samples of each trace HDR.num_samp_each_trac = zeros(1, HDR.num_trac) + HDR.num_samp; % Number of samples of each trace
HDR.elevation = zeros(1, HDR.num_trac); %Elevation / topography of each trace; HDR.elevation = zeros(1, HDR.num_trac); % Elevation / topography of each trace;
HDR.not_used1 = zeros(1, HDR.num_trac); %Not used HDR.not_used1 = zeros(1, HDR.num_trac); % Not used
HDR.bytes = zeros(1, HDR.num_trac) + 2; %Always 2 for Rev 3 firmware HDR.bytes = zeros(1, HDR.num_trac) + 2; % Always 2 for Rev 3 firmware
HDR.time_window_each_trac = zeros(1, HDR.num_trac) + HDR.time_window; % Time window of each trace HDR.time_window_each_trac = zeros(1, HDR.num_trac) + HDR.time_window; % Time window of each trace
HDR.stacks_each_trac = zeros(1, HDR.num_trac); %Number of stacks each trace HDR.stacks_each_trac = zeros(1, HDR.num_trac); % Number of stacks each trace
HDR.not_used2 = zeros(1, HDR.num_trac); %Not used HDR.not_used2 = zeros(1, HDR.num_trac); % Not used
HDR.rsv_gps_x = zeros(1, HDR.num_trac); %Reserved for GPS X position (double*8 number) HDR.rsv_gps_x = zeros(1, HDR.num_trac); % Reserved for GPS X position (double*8 number)
HDR.rsv_gps_y = zeros(1, HDR.num_trac); %Reserved for GPS Y position (double*8 number) HDR.rsv_gps_y = zeros(1, HDR.num_trac); % Reserved for GPS Y position (double*8 number)
HDR.rsv_gps_z = zeros(1, HDR.num_trac); %Reserved for GPS Z position (double*8 number) HDR.rsv_gps_z = zeros(1, HDR.num_trac); % Reserved for GPS Z position (double*8 number)
HDR.rsv_rx_x = zeros(1, HDR.num_trac); %Reserved for receiver x position HDR.rsv_rx_x = zeros(1, HDR.num_trac); % Reserved for receiver x position
HDR.rsv_rx_y = zeros(1, HDR.num_trac); %Reserved for receiver y position HDR.rsv_rx_y = zeros(1, HDR.num_trac); % Reserved for receiver y position
HDR.rsv_rx_z = zeros(1, HDR.num_trac); %Reserved for receiver z position HDR.rsv_rx_z = zeros(1, HDR.num_trac); % Reserved for receiver z position
HDR.rsv_tx_x = zeros(1, HDR.num_trac); %Reserved for transmitter x position HDR.rsv_tx_x = zeros(1, HDR.num_trac); % Reserved for transmitter x position
HDR.rsv_tx_y = zeros(1, HDR.num_trac); %Reserved for transmitter y position HDR.rsv_tx_y = zeros(1, HDR.num_trac); % Reserved for transmitter y position
HDR.rsv_tx_z = zeros(1, HDR.num_trac); %Reserved for transmitter z position HDR.rsv_tx_z = zeros(1, HDR.num_trac); % Reserved for transmitter z position
HDR.time_zero = zeros(1, HDR.num_trac); %Time zero adjustment where: point(x) = point(x + adjustment) HDR.time_zero = zeros(1, HDR.num_trac); % Time zero adjustment where: point(x) = point(x + adjustment)
HDR.zero_flag = zeros(1, HDR.num_trac); %0 = data ok, 1 = zero data HDR.zero_flag = zeros(1, HDR.num_trac); % 0 = data ok, 1 = zero data
HDR.num_channels = zeros(1, HDR.num_trac); %Number of channels HDR.num_channels = zeros(1, HDR.num_trac); % Number of channels
HDR.time = zeros(1, HDR.num_trac); %Time of day data collected in seconds past midnight HDR.time = zeros(1, HDR.num_trac); % Time of day data collected in seconds past midnight
HDR.comment_flag = zeros(1, HDR.num_trac); %Comment flag HDR.comment_flag = zeros(1, HDR.num_trac); % Comment flag
HDR.comment = zeros(1, 24); %Comment HDR.comment = zeros(1, 24); % Comment
%HD file % HD file
fid = fopen([HDR.fname '.hd'], 'w'); fid = fopen([HDR.fname '.hd'], 'w');
fprintf(fid, '%i\r\n\n', HDR.file_tag); fprintf(fid, '%i\r\n\n', HDR.file_tag);
fprintf(fid, 'Data Collected with %s\r\n\n', HDR.system); fprintf(fid, 'Data Collected with %s\r\n\n', HDR.system);
@@ -495,7 +507,7 @@ elseif flg == 3
fprintf(fid, 'Receiver Serial# = %s\r\n', HDR.rx_serial); fprintf(fid, 'Receiver Serial# = %s\r\n', HDR.rx_serial);
fclose(fid); fclose(fid);
%DT1 file % DT1 file
fid = fopen([HDR.fname '.dt1'], 'w'); fid = fopen([HDR.fname '.dt1'], 'w');
for i = 1 : HDR.num_trac for i = 1 : HDR.num_trac
fwrite(fid, HDR.num_each_trac(i), 'float'); fwrite(fid, HDR.num_each_trac(i), 'float');
@@ -530,4 +542,7 @@ elseif flg == 3
end end
fclose(fid); fclose(fid);
end end
waitbar(1, wb, 'Done!!!'); pause(1); close(wb);
waitbar(1, wb, 'Done!!!');
pause(1);
close(wb);