function his = read_HIS_record(file,index); % % function his_record = read_HIS_record(file,fp,index); % % ....This Matlab function reads one HIS record based on the file % pointer fp and the file index. % % Written by Von P. Walden % 14 May 1998 % fp = fopen(file); % if filename is not specified, get from user if nargin == 0 [fname,pname] = uigetfile('*.ume'); file = [pname fname]; end his.filename = file; % % ....Skips to appropriate record and reads header and data. % fseek(fp,(index-1)*2150*4,'bof'); header = fread(fp,100,'float32'); data = fread(fp,2050,'float32'); npts = header(31); % grab the radiances his.header = header; his.rad = data(1:npts)'; clear data; % define some specific header data his.record_number = header(1); his.channel_number = header(2); his.mirror_position = header(3); his.no_pts_in_ifgm = header(8); his.seconds = header(11); his.hbb_temp = header(12); his.cbb_temp = header(13); his.dc_ch1 = header(14); his.dc_ch2 = header(15); his.dc_ch3 = header(16); his.year = header(17) + 1900; his.month = header(18); his.day = header(19); his.bad_flag = header(20); his.noise_flag = header(21); his.std_phase = header(22); his.begin_time = header(23); % HHMMSS his.current_time = header(24); % HHMMSS his.qc_flag = header(25); % 2 = spectrum o.k. his.no_pts_in_fft = header(30); his.no_pts_in_spectrum = header(31); his.aircraft_lat = header(51); his.aircraft_lon = header(52); his.aircraft_alt = header(53); his.aircraft_heading = header(54); % Create frequency scale. low = header(34); high = header(35); his.freq = linspace(low,high,npts); % compute brightness temperatures his.bt = real(rad2bt(his.freq,his.rad/1E3)); % define min, max wavenumbers for regions of good data if his.channel_number(1) == 3 his.wn1 = 600; his.wn2 = 1075; elseif his.channel_number(1) == 2 his.wn1 = 1080;his.wn2=1800; elseif his.channel_number(1) == 1 his.wn1 = 2050;his.wn2=2650; end % pull hour, minute, second from current_time (HHMMSS) his.hour = fix(his.current_time/1e4); his.minute = fix((his.current_time - 1e4*his.hour)/1e2); his.second = fix(his.current_time - his.hour*1e4 - his.minute*1e2); % compute # seconds since 1970 (dont' ask why) his.nss1970 = nosecsince1970(his.year,his.month,his.day,his.hour,his.minute,his.second); % define wavenumber regions for radiance vs time if his.channel_number(1) == 3 his.wnbr1(1) = 898;his.wnbr2(1) = 904; his.wnbr1(2) = 700;his.wnbr2(2) = 710; elseif his.channel_number(1) == 2 his.wnbr1(1) = 1124;his.wnbr2(1) = 1132; his.wnbr1(2) = 1582;his.wnbr2(2) = 1588; elseif his.channel_number(1) == 1 his.wnbr1(1) = 2384;his.wnbr2(1) = 2392; his.wnbr1(2) = 2460;his.wnbr2(2) = 2470; end fclose(fp);