function [data] = readBinary(machineFormat, filename)

% read data from a binary file
% Input: input filename
%        machineFormat to read data file in
% Input: data as supplied by read_eos_fields_airs
%
% Output arranged starting from upper left corner of data matrix
% Format is the following for each pixel (total records=1354*2030)
%

if nargin == 0
  machineFormat = 'ieee_le';
end

if nargin == 0 || nargin == 1
  [fn,pn] = uiputfile('*.bin','Read binary file');
  filename = [pn fn];
end

fid = fopen(filename, 'rb', machineFormat);

while 0
[m, n] = size(data);
for j = 1:n
for i = 1:m
  fwrite(fid, data(i,j), 'float32');	
end
end
end

data = fread(fid, 'float32');	

fclose(fid);
