数据读取和LOFAR分析.zip

  • 小小放牛娃
    了解作者
  • matlab
    开发工具
  • 4.6KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 5 积分
    下载积分
  • 0
    下载次数
  • 2022-02-11 15:07
    上传日期
此程序为lofar分析程序,可运行使用,
数据读取和LOFAR分析.zip
  • 数据读取和LOFAR分析
  • Sony SIR-1000 LOFAR
  • resample_test3.m
    4KB
  • db20.m
    595B
  • readSIR.m
    4.3KB
内容介绍
function [data,fs,Snapshots,info]=readSIR(filename,No,BeginPoint,Len) % Read data from SONY SIR-1000 Data Record System % Usage: % (1) Read total data in one time % [data[,fs]]=readSIR(filename,No) % (2) Read part data in one time. % [data[,fs]]=readSIR(filename,No,BeginPoint,Len) % (3) Read total data in integer mode % [data,fs,Snapshots[,info]]=readSIR(filename,No) % Input parameters: % filename === Data file name, the extension name .BIN can be omitted % No === specified channel number to read data, sequenced from 1, % if No==0, all channels data are read. %BeginPoint=== the begin point to read, =0~N-1 % Len === the length of data to read, =0~N % If Len=0, all points after BeginPoint will be read % Output parameters: % data === read data, with columns of channels, rows of Snapshots. % For any error, data=[] % 如果LOG文件存在,且不存在Vcoef输出参数,data返回以V为单位的电压值, % 如果LOG文件不存在,或者LOG文件不存在但要求Vcoef输出参数,则返回A/D转换得到的带符号整数值。 % fs === If demanded, return the sampling frequency read from .LOG file. % If no .LOG file was found, fs=1 % If no .BIN file was found, fs=-1 % Snapshots=== 整个数据文件的快拍数(不是读取的快拍数) % info === 数据采集中的相关参数组成的结构变量,包括转换系数、采样日期等(V1.2,2008-7-30版本开始支持) % info.Vcoef -- A/D所得整数转换为电压值的转换系数向量,每个通道的系数可以不一样 % info.Date -- 数据采样日期和时间,如20080811 170331 % 作者: 张群飞 % Copyright 1998-2015, 西北工业大学 % $Revision: 1.2 $ $Date: 2008/7/30 $ if nargin<2 || nargin>4 || nargout<1 || nargout>4 || No<0, help readSIR, return end i=findstr(filename,'.'); if ~isempty(i), filename=filename(1:i-1); end % ********get parameters from .log file******** filename1=[filename,'.log']; fp=fopen(filename1,'r'); if fp==-1, disp(['file "',filename1,'" not found, cannot determine Fs !!']); Channels=1; %直接把.bin当成单通道数据来读取 fs=1; Vcoef=1; Snapshots=-1; temp=dir([filename,'.bin']); info.Date=temp.date; else %文件存在 Channels=0; Vcoef=[]; while ~feof(fp) line=fgetl(fp); i=findstr(line,'VOLUME_CH'); % 读取每通道采样点数(快拍数) if ~isempty(i) Snapshots=sscanf(line(i+15:length(line)),'%d'); end % i=findstr(line,'TAPE_SRATE_CH'); % 读取采样频率,该参数在有的LOG文件中含义不同 i=findstr(line,'TAPE_SRATE_CH'); % 读取采样间隔 if ~isempty(i) % fs=sscanf(line(i+15:i+22),'%d'); fs=sscanf(line(i+15:i+29),'%f'); end i=findstr(line,'Volt, *('); % 读取通道数和量程 if ~isempty(i) Channels=Channels+1; temp=sscanf(line(i+8:i+20),'%f'); Vcoef=[Vcoef,temp]; end i=findstr(line,'DATE_TIME'); % 读取采样日期和时间 if ~isempty(i) info.Date=sscanf(line(16:end),'%c'); end end fclose(fp); if No > Channels, error('readSIR:tooBigChannelNumber','The specified channel No. is too big!') elseif No >0 Vcoef=Vcoef(No); end end info.Vcoef=Vcoef; % ========== 开始读取数据 ========== filename1=[filename,'.bin']; fp=fopen(filename1,'r'); if fp==-1, disp(['file "',filename1,'" not found !!']); data=[]; fs=-1; return end if Snapshots==-1 %没有.LOG文件,通过读取.BIN文件的长度来获得快拍数 fseek(fp,0,'eof'); Snapshots=fix(ftell(fp)/2); fseek(fp,0,'bof'); end BeginPoint=round(BeginPoint); if nargin>2, status=fseek(fp,fix(BeginPoint*2*Channels),'bof'); if status==-1, %have errors data=[]; fs=-1; error('readSIR:tooBigBeginPoint','The specified BeginPoint is too big!') end end if nargin<4 Len=inf; else if Len==0, Len=inf; end end Len=round(Len); if No==0 % read all channels data=fread(fp,[Channels,Len],'int16'); else % read specified channel fread(fp,No-1,'int16'); data=fread(fp,Len,'int16',(Channels-1)*2); end fclose(fp); if No==0, data=data.'; end %else, data is already a column if nargout<3, data=data*diag(Vcoef); end %将A/D整数值转换为电压值 % data(:,13)=-data(:,13);
评论
    相关推荐