% read_v2_grip_HIRADnc.m 
% This Script reads HIRAD netcdf files and generates MATLAB binary files
% (.mat) with the same name
% Sayak Biswas, sayak.k.biswas@nasa.gov
clear all;
clc;
filename = 'HIRAD_TBdata_20100901_221009-222000_leg01.nc';

%open a netCDF file
ncid = netcdf.open(filename,'NC_NOWRITE');
% Get information
[ndims,nvars,ngatts,unlimdimid] = netcdf.inq(ncid);

% Get variable names
for ivar = 1:nvars
    varid = ivar-1;
    [varname,xtype,dimids,natts] = netcdf.inqVar(ncid,varid);
    eval([ 'hirad.' varname ' = netcdf.getVar(ncid,varid);']);
end

hirad.time_serial = datenum([num2str(hirad.DATE) num2str(hirad.TIME,'%0.6d')],'yyyymmddHHMMSS');

%return variable ID's
% DateID = netcdf.inqVarID(ncid,'DATE');

netcdf.close(ncid);

opname = [filename(1:end-2) 'mat'];
save(opname,'hirad'); 
