% Make a list of the all the HDF files str=['find . -name "3B*.HDF" > list_hdf.txt']; unix(str); % Convert all HDF files into NETCDF and store in folder netcdf mkdir netcdf file = textread('list_hdf.txt','%s','delimiter','\n','whitespace',''); for i=1:length(file) hdffile=file{i}; ncfile=['netcdf/',hdffile(12:23),'nc']; str=['hdf2netcdf ',hdffile, ' ', ncfile]; unix(str); end % Now extract the fields and put them all in one netcdf file trmm_create_trmm_precip_file % Create single empty netcdf file month={'01' '02' '03' '04' '05' '06' '07' '08' '09' '10' '11' '12'} it=0; ncout=netcdf('trmm_precipitation.nc','w'); for yr=1998:2010 for imon=1:12 tmp=num2str(yr); str=[tmp(3:end),month{imon},'01']; file=['netcdf/3B43.',str,'.nc']; disp(file); nc=netcdf(file); p=nc{'precipitation'}(:); it=it+1; ncout{'precipitation'}(it,:,:)=p; ncout{'time'}(it)=datenum(yr,imon, 15); close(nc) end end for yr=2011 for imon=1:6 tmp=num2str(yr); str=[tmp(3:end),month{imon},'01']; file=['netcdf/3B43.',str,'.nc']; disp(file); nc=netcdf(file); p=nc{'precipitation'}(:); it=it+1; ncout{'precipitation'}(it,:,:)=p; ncout{'time'}(it)=datenum(yr,imon, 15); close(nc) end end close(ncout);