function fixlatlon(ncfilename,gdlat, gdlon) %fixlatlon: corrects lat, lon coordinate variables and attibutes for a given .nc file % usage fix_latlon('7431mc-a', 33.649, -78.849) % etm (after fl code) 5/23/06 %%% 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 -------------- perloc=findstr('.',ncfilename); new_nm=[ncfilename(1:perloc-1) '_old.nc']; result=fcopy(ncfilename,new_nm); nc = netcdf(ncfilename, 'write'); if isempty(nc), return, end %% Global attributes: lfeed = char(10); nc.CREATION_DATE = ncchar(datestr(now,0)); history = ['Global attributes corrected.:' nc.history(:)]; ifeed = findstr(history,lfeed); history(ifeed) = ':'; nc.history = ncchar(history); nc.history = ncchar(history); nc.latitude = ncfloat(gdlat); nc{'lat'}(1)=gdlat; nc.longitude = ncfloat(gdlon); nc{'lon'}(1)=gdlon; close(nc)