| classdef linear_scan < handle |
|
|
| |
| |
| |
| |
|
|
| |
|
|
| properties (SetAccess = public) |
| x_axis |
| z_axis |
| end |
| |
| properties (SetAccess = private) |
| x_matrix |
| z_matrix |
| x |
| z |
| dx |
| dz |
| Nx |
| Nz |
| pixels |
| end |
| |
| |
| methods (Access = public) |
| |
| |
| function h = linear_scan(input_x,input_z) |
| |
| |
| |
| |
| |
| |
| |
| if nargin>0 |
| h.x_axis=input_x; |
| end |
| if nargin>1 |
| h.z_axis=input_z; |
| end |
| |
| end |
| |
| |
| function xd = lateral_distance(h,x0,z0,steer_angle) |
| |
| |
| |
| |
| |
| |
| |
| |
| xd = abs(x0-h.x+h.z*tan(steer_angle)); |
| end |
| |
| |
| function dz = depth_step(h) |
| |
| |
| |
| |
| |
| dz = mean(diff(h.z_axis)); |
| end |
| |
| end |
| |
| |
| methods |
| |
| function h = set.x_axis(h,input_vector) |
| assert(size(input_vector,1)>size(input_vector,2), 'The x vector must be a column vector!') |
| h.x_axis = input_vector; |
| h.dx = h.x_axis(2)-h.x_axis(1); |
| h.Nx = numel(h.x_axis); |
| [h.x_matrix,h.z_matrix] = meshgrid(h.x_axis,h.z_axis); |
| h.x = h.x_matrix(:); |
| h.z = h.z_matrix(:); |
| h.pixels = length(h.x); |
| end |
| |
| function h = set.z_axis(h,input_vector) |
| assert(size(input_vector,1)>size(input_vector,2), 'The z vector must be a column vector!') |
| h.z_axis = input_vector; |
| h.dz = h.z_axis(2)-h.z_axis(1); |
| h.Nz = numel(h.z_axis); |
| [h.x_matrix,h.z_matrix] = meshgrid(h.x_axis,h.z_axis); |
| h.x = h.x_matrix(:); |
| h.z = h.z_matrix(:); |
| h.pixels = length(h.x); |
| end |
| |
| end |
| |
| |
| methods (Access = public) |
| |
| function write_file_hdf5(h,filename) |
| |
| |
| attr_details.Name = 'version'; |
| attr_details.AttachedTo = '/'; |
| attr_details.AttachType = 'group'; |
| hdf5write(filename, attr_details, 'v.0.0.39'); |
| |
| |
| try |
| h5info(filename,'/US') |
| catch |
| fid = H5F.open(filename,'H5F_ACC_RDWR','H5P_DEFAULT'); |
| gid = H5G.create(fid,'US','H5P_DEFAULT','H5P_DEFAULT','H5P_DEFAULT'); |
| H5G.close(gid); |
| H5F.close(fid); |
| end |
| |
| |
| group_name = 'US_DATASET0000'; |
| fid = H5F.open(filename,'H5F_ACC_RDWR','H5P_DEFAULT'); |
| gid = H5G.open(fid,'/US'); |
| s_gid = H5G.create(gid,group_name,'H5P_DEFAULT','H5P_DEFAULT','H5P_DEFAULT'); |
| H5G.close(s_gid); |
| H5G.close(gid); |
| H5F.close(fid); |
| location = ['/US/' group_name]; |
| |
| |
| |
| file = H5F.open(filename,'H5F_ACC_RDWR','H5P_DEFAULT'); |
| filetype = H5T.enum_create('H5T_NATIVE_INT'); |
| H5T.enum_insert(filetype, 'US', 0); |
| H5T.enum_insert(filetype, 'SR', 1); |
| gid = H5G.open(file,location); |
| space = H5S.create_simple(1,1,[]); |
|
|
| attr = H5A.create (gid,'type',filetype,space,'H5P_DEFAULT'); |
| H5A.write (attr,filetype, uint32(0)); |
| H5A.close (attr); |
| H5G.close(gid); |
| H5S.close(space); |
| H5T.close(filetype); |
| H5F.close(file); |
| |
| |
| file = H5F.open(filename,'H5F_ACC_RDWR','H5P_DEFAULT'); |
| filetype = H5T.enum_create('H5T_NATIVE_INT'); |
| H5T.enum_insert (filetype,'STA', 0); |
| H5T.enum_insert (filetype,'CPW', 1); |
| H5T.enum_insert (filetype,'VS', 2); |
| H5T.enum_insert (filetype,'BS', 3); |
| gid = H5G.open(file,location); |
| space = H5S.create_simple (1,1,[]); |
| attr = H5A.create (gid,'subtype',filetype,space,'H5P_DEFAULT'); |
| H5A.write (attr,filetype,uint32(1)); |
| |
| |
| file = H5F.open(filename,'H5F_ACC_RDWR','H5P_DEFAULT'); |
| filetype = H5T.enum_create('H5T_NATIVE_INT'); |
| H5T.enum_insert (filetype,'RF',0); |
| H5T.enum_insert (filetype,'IQ',1); |
| gid = H5G.open(file,location); |
| space = H5S.create_simple(1,1,[]); |
|
|
| attr = H5A.create (gid, 'signal_format', filetype, space, 'H5P_DEFAULT'); |
| H5A.write(attr, filetype, uint32(1)); |
| H5A.close(attr); |
| H5G.close(gid); |
| H5S.close(space); |
| H5T.close(filetype); |
| H5F.close(file); |
|
|
| |
| |
| |
| dset_details.Location = location; |
| dset_details.Name = 'x_axis'; |
| hdf5write(filename, dset_details, h.x_axis, 'WriteMode', 'append'); |
|
|
| |
| dset_details.Location = location; |
| dset_details.Name = 'z_axis'; |
| hdf5write(filename, dset_details, h.z_axis, 'WriteMode', 'append'); |
| |
| end |
| |
| |
| function read_file(h,filename) |
| |
| |
| |
| |
| |
| |
| [pathstr, name, ext] = fileparts(filename); |
| switch ext |
| case '.mat' |
| h.read_file_mat(filename); |
| case '.hdf5' |
| h.read_file_hdf5(filename); |
| otherwise |
| error('Unknown signal format!'); |
| end |
| |
| end |
| |
| |
| function write_file(h,filename) |
| |
| |
| |
| |
| |
| |
| [pathstr, name, ext] = fileparts(filename); |
| switch ext |
| case '.mat' |
| h.write_file_mat(filename); |
| case '.hdf5' |
| h.write_file_hdf5(filename); |
| otherwise |
| error('Unknown signal format!'); |
| end |
| |
| end |
| |
| |
| function read_file_hdf5(h,filename) |
| |
| |
| info = h5info(filename,'/US'); |
|
|
| |
| for n=1:length(info.Groups) |
| location = info.Groups(n).Name; |
| dstype = h5readatt(filename,location,'type'); |
| if strcmp(dstype,'US') |
| subtype = h5readatt(filename,location,'subtype'); |
| if strcmp(subtype{1},'CPW') |
| |
| dataset_subtype = h5readatt(filename,location,'subtype'); |
| assert(strcmp(dataset_subtype,'CPW'),'Only CPWC us_dataset are supported!'); |
| |
| signal_format = h5readatt(filename,location,'signal_format'); |
| switch(signal_format{1}) |
| case 'RF' |
| error('RF format not available!'); |
| case 'IQ' |
| ; |
| otherwise |
| error('Unknown signal format!'); |
| end |
| |
| |
| h.x_axis = h5read(filename,[location '/x_axis']); |
| |
| h.z_axis = h5read(filename,[location '/z_axis']); |
| end |
| end |
| end |
| |
| end |
|
|
| function read_file_mat(h,filename) |
|
|
| |
| load(filename); |
| |
| |
|
|
| |
| h.x_axis = PARAM.x_axis; |
|
|
| |
| h.z_axis = PARAM.z_axis; |
| |
| end |
| |
| function write_file_mat(h,filename) |
| |
| |
| |
| |
| PARAM.x_axis = h.x_axis; |
|
|
| |
| PARAM.z_axis = h.z_axis; |
|
|
| |
| save(filename,'PARAM'); |
| |
| end |
| |
| end |
| |
| end |
|
|
|
|