| 2 | |
| 3 | [[CollapsibleStart(Load BOV File into Matlab)]] |
| 4 | This script will load the data from a bov/dat file pair into matlab |
| 5 | {{{ |
| 6 | % usage data=load_bov('~/sample_file.bov'); |
| 7 | % imagesc(squeeze(sum(data(:,:,:,1),3)) %makes a column density plot along z axis... |
| 8 | |
| 9 | function data=load_bov(file) |
| 10 | fid=fopen(file); |
| 11 | [path,name,ext]=fileparts(which(file)); |
| 12 | textdata=textscan(fid,'%s',1000); |
| 13 | for i=1:3 |
| 14 | mx(i)=str2num(textdata{1}{strmatch('DATA_SIZE:',textdata{1})+i}) |
| 15 | end |
| 16 | components=str2num(textdata{1}{strmatch('DATA_COMPONENTS:',textdata{1})+1}) |
| 17 | fclose(fid) |
| 18 | file2=[path,'/',textdata{1}{strmatch('DATA_FILE:',textdata{1})+1}] |
| 19 | fid=fopen(file2); |
| 20 | fread(fid,4,'char'); %fortran unformatted write includes a 4 byte header |
| 21 | data=reshape(transpose(reshape(fread(fid,double(mx(1)*mx(2)*mx(3)*components),'float64'), [components,mx(1)*mx(2)*mx(3)])), [mx(1), mx(2), mx(3),components]); |
| 22 | fclose(fid); |
| 23 | }}} |
| 24 | |
| 25 | |