function [sst]=read_rss_oi_sst(file_path_and_name)

% this function reads RSS Microwave (MW) OI SST files
%
% RRS MW OI SST files must be unzipped before reading with this function
%
% Pass the full path and file name to this function
%
% it returns a 1440 by 720 array (quarter degree earth grid) of SST and other code values
%
% RRS MW OI SST files contain single byte values which must be decoded to obtain meaningful geophysical data
%
% Valid SST byte values (0 - 250) must be scaled and offset.
% Byte values (251 - 255) have special meanings:
%      251 = missing data
%      252 = sea ice
%      253 = missing data
%      254 = missing data
%      255 = land mass
%
% for a detailed desription see: http://www.remss.com/sst and click Description
%
% questions should be addressed to both: gentemann@remss.com,brewer@remss.com


centigrade_scale = .15;
centigrade_offset = -3;


if exist(file_path_and_name)
    fid = fopen(file_path_and_name, 'r');
    sst = fread(fid, [1440 720], 'uchar');
    fclose(fid);
    sst_indices = find(sst <= 250);
    sst(sst_indices) = (sst(sst_indices) * centigrade_scale) + centigrade_offset;
else
    ['FILE NOT FOUND: ' file_path_and_name]
    sst=[];
    return;
end;

