function [st_time, end_time]=chk_time(fname) %chk_time: returns start and end times of a netCDF file as strings % % usage: [st_time, end_time]=chk_time(fname) % outputs: strings of start and end times of the time variables % input: filename %%% START USGS BOILERPLATE ------------- % These programs are intened for us in adjusting metadata terms in % netCDF files from the USGS CMGP Oceanographic time-series data % archive % % Program written Matlab 7.6.0.342 (R2008a) % Program ran on Linux PC with RHEL4 and on Windows XP PC. % % "Although this program has been used by the USGS, no warranty, % expressed or implied, is made by the USGS or the United States % Government as to the accuracy and functioning of the program % and related program material nor shall the fact of distribution % constitute any such warranty, and no responsibility is assumed % by the USGS in connection therewith." %%% END USGS BOILERPLATE -------------- if nargin ~= 1; help (mfilename); return; end %open the netcdf file eval(['nc=netcdf(''' fname ''');']) % % extract and save the time words in a sensible format % time is days, time2 is miliseconds st_time=gregorian(nc{'time'}(1)+(nc{'time2'}(1)/3600/1000/24)); end_time=gregorian(nc{'time'}(end)+(nc{'time2'}(end)/3600/1000/24)); tt=nc{'time'}(:)+(nc{'time2'}(:)/3600/1000/24); %disp(['Attribute start, stop are : ' nc.start_time(:) ' - ' nc.stop_time(:)]) dtime=nc.DELTA_T(:); close(nc) %figure %plot(diff(tt),'.'); %yl=get(gca,'YLim'); %offs=(yl(2)-yl(1))/10; %text(100,yl(1)+offs,['Mean difference in times is ' num2str(mean(diff(tt)).*86400) ' seconds']) %title(fname) %disp(['Data start, end times are ; ' datestr(st_time) ' - ' datestr(end_time)]) %disp(['DELTA_T attribute is: ' num2str(dtime)]) % now make sure they match st_dif=(datenum(nc.start_time(:))+1721059-(nc{'time'}(1)+(nc{'time2'}(1)/3600/1000/24))) if st_dif > .0001 disp (['start times not equal!']) end