Skip to content

Instantly share code, notes, and snippets.

@hmparanjape
Created July 7, 2015 22:00
Show Gist options
  • Save hmparanjape/d7e8df18b19067fb8ccd to your computer and use it in GitHub Desktop.
Save hmparanjape/d7e8df18b19067fb8ccd to your computer and use it in GitHub Desktop.
Obtain load/displacement data from CHESS/APS spec log file
spec_file_dir = 'X:\stebner-252-1\HEA_tension';
spec_log_file_name = 'spec.log';
DIC_image_dir = 'X:\stebner-252-1\301lss_rams2t_1\dic_post\raw_images';
cross_section_area = 1;
log_file = fopen(fullfile(spec_file_dir, spec_log_file_name), 'r');
image_file_numbers = [];
force = [];
displacement = [];
newimages = [];
start_scan_flag = 1;
% Extract load/displacement from log.
while(~feof(log_file))
log_line_next = fgetl(log_file);
%if(start_scan_flag == 0 && ~isempty(findstr(log_line, '#D Thu Oct 30')))
% start_scan_flag = 1;
%end
if(~isempty(findstr(log_line_next, 'force=')) && ...
~isempty(findstr(log_line_next, 'displacement=')))
log_line = fgetl(log_file);
if(start_scan_flag ~= 0 && ~isempty(findstr(log_line, 'DIC image saved')))
for ii = 13:-1:7
if isempty(str2num(log_line(end - ii))) == 1
imindex = ii-1;
end
end
image_file_numbers(end+1) = str2num(log_line(end-imindex:end-6));
newimages(end+1,1) = 1e5 + image_file_numbers(end);
split_log_line = strsplit(log_line_next, '=');
split_log_line_2 = strsplit(mat2str(cell2mat(split_log_line(2))), ',');
force_str_temp = mat2str(cell2mat(split_log_line_2(1)));
force(end+1) = str2num(force_str_temp(4:end-1));
split_log_line_3 = mat2str(cell2mat(split_log_line(3)));
split_log_line_4 = split_log_line_3(2:end-2);
%displacement_str_temp = mat2str(cell2mat(split_log_line_4));
displacement(end+1) = str2num(split_log_line_4);
end
end
end
fclose(log_file);
% Plot for fun
plot(displacement-displacement(1), force)
xlabel('Relative crosshead displacement (mm)');
ylabel('Force (N)');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment