read_obs_210.m ( File view )

  • By warming 2015-06-29
  • View(s):5
  • Download(s):1
  • Point(s): 1
			%――――――――――――――――――――――
% 函数:读取rinex观测量
% 输入:文件路径,起始时间
% 输出:观测量,结束时间
%――――――――――――――――――――――
function [obs_gps,obs_bd,obs_name,obs_num,t_fst,t_end]=read_obs_210(file,thz)

fid1=fopen(file,'r');

while 1 
    tline=fgetl(fid1);
    %data_char=sscanf(tline,'%c');
    head_id=strtrim(tline(61:80));
    TO=strcmp(head_id,'# / TYPES OF OBSERV');
    TF=strcmp(head_id,'TIME OF FIRST OBS'); % 含有时间标识的行
    EH=strcmp(head_id,'END OF HEADER'); % 结束行
    
    if TO==1	
        obs_num=str2double(tline(5:6));
        for i=1:obs_num	
            obs_name{
i
}=strrep(tline(6*i+4:6*i+6),' ',''); % 取函数名并消除空格
            %eval([obs_name{
i
},'=0;']);% 赋初值
        end
    end   

    if TF==1
%         year=str2double(tline(3:6));        % 年
%         month=str2double(tline(11:12));     % 月
%         day=str2double(tline(17:18));       % 日
        hour=str2double(tline(23:24));    % 时
        minute=str2double(tline(29:30));  % 分
        second=str2double(tline(34:38));  % 秒
        
        t_fst=(hour*3600+minute*60+second)*thz; % 天内秒
        t_fst=round(t_fst);
    end
    
    if EH==1 %跳过头文件
        break;
    end
end

init=0;
while 1
    if ~init
        day_sec=t_fst;        
        G(:,:,length(obs_name))=0;
        C(:,:,length(obs_name))=0;
        init=1;
    end
    
    tline=fgetl(fid1);
    if ~ischar(tline)
        break;
    end
    sat_inf=sscanf(tline,'%c');
    %%%%日期信息,目前只计天内秒%%%%
    year=str2double(sat_inf(2:3));      % 年
    month=str2double(sat_inf(5:6));     % 月
    day=str2double(sat_inf(8:9));       % 日
    hour=str2double(sat_inf(11:12));    % 时
    minute=str2double(sat_inf(14:15));  % 分
    second=str2double(sat_inf(17:21));  % 秒

    day_sec=(hour*3600+minute*60+second)*thz; % 天内秒
    day_sec=round(day_sec);
    t=day_sec-t_fst+1;                     % 序号
    
    %%%%卫星总数%%%%
    sat_num=str2double(sat_inf(31:32)); % 可视星总数
    if sat_num>12 % 卫星数超过12颗,卫星号信息存储为两行,需要再读一行
        %%%%再读一行%%%%
        tline =fgetl(fid1);        
        sat_inf2=sscanf(tline,'%c');    % 剩余卫星通道的信息存到sat_inf2
    end

    %%%%读卫星通道的信息%%%%
    for j=1:sat_num
        if j>12 % 超过12时,卫星标志和编号在sat_inf2中
            k=j-12;
            sat_symb=sat_inf2(30+k*3);% 可视星的标志(GPS/BD)
            sat_order=str2double(sat_inf2((31+k*3):(32+k*3)));% 可视星的编号
        else    % 没超过12时,卫星标志和编号在sat_inf中
            sat_symb=sat_inf(30+j*3);% 可视星的标志(GPS/BD)
            sat_order=str2double(sat_inf((31+j*3):(32+j*3)));% 可视星的编号
        end
        %每个通道读两行,包括6个观测量
        tline=fgetl(fid1);
        channel_obs=sscanf(tline,'%c'); % 前5个观测量
        if i>5  % 再读一行,另一个观测量
            tline=fgetl(fid1);              
            channel_obs2=sscanf(tline,'%c');
        end
            
        if (sat_symb=='G') %GPS卫星观测量
            for i=1:obs_num
                if i<=5
                    G(sat_order,t,i)=str2double(channel_obs(16*i-15:16*i));
                else
                	G(sat_order,t,i)=str2double(channel_obs2(16*i-95:16*i-80)); 
                end
            end
        elseif (sat_symb=='C') %北斗卫星观测量
            for i=1:obs_num
                if i<=5
                    C(sat_order,t,i)=str2double(channel_obs(16*i-15:16*i));
                else
                	C(sat_order,t,i)=str2double(channel_obs2(16*i-95:16*i-80)); 
                end
            end
        else
            G(sat_order,t,:)=0;
            C(sat_order,t,:)=0;
        end
    end
end

for i=1:obs_num
    obs_gps.(obs_name{
i
})=G(:,:,i);    
    obs_bd.(obs_name{
i
})=C(:,:,i);
end

t_end=day_sec;

			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
read_obs_210.m3.83 kB26-06-15 15:58
...
Sponsored links

read_obs_210.m (1.42 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D