
function [spectra,spectra_velocity,time_hour,time_year,wavelength,IPP]=read_spectra_data_file(file_name)

% get time from file name	
	[k]=findstr(file_name,'rsmas.94ghz.spectra.');
	T=file_name(k+20:end);

	year=str2num(T(1:4));
	month=str2num(T(5:6));
	day=str2num(T(7:8));

	hour=str2num(T(10:11));
	min=str2num(T(12:13));
	sec=str2num(T(14:15));
	msec=str2num(T(17:19));

time_hour=hour+min/60+(sec+msec/1000)/3600 ;
time_year=time_to_year_fraction(year,month,day,hour,min,sec+1E-3*msec) ;
	
% if gzip ... then copy to unzipped version ... temporarily
if( strcmp(file_name(end-2:end),'.gz') )
	test=unix(['gzip -d -c ' file_name ' >temp.dat' ])
	fid=fopen('temp.dat','r','l');
else
	fid=fopen([file_name],'r','l');
end

wavelength=fread(fid,[1 1],'float');
IPP=fread(fid,[1 1],'float');

n_points_in_fft=fread(fid,[1 1],'int');
n_gates=fread(fid,[1 1],'int');

gates_selected=fread(fid,[1 n_gates],'short');

% calculate fft velocity
dummy=0.5*wavelength/(n_points_in_fft*IPP);
for i=1:n_points_in_fft
	spectra_velocity(i)=(i - 0.5*n_points_in_fft -1)*dummy;
end


spectra=zeros([n_gates n_points_in_fft]);
for j=1:n_gates
	if(gates_selected(j))
		spectra(j,(0.5*end+1):end)=fread(fid,[1 0.5*n_points_in_fft],'float');
		spectra(j,1:(0.5*end))=fread(fid,[1 0.5*n_points_in_fft],'float');
	end
end


fclose(fid);

return
