function [retn, deps] = extract_ncdepth(nc) %extract_nedepth: extracts everything associated with depth % % extracts depth associated attributes and the variable depth from an open % nc object % for use in validating runs of adj_tripod_depth % % usage [retn, deps]=extract_ncdepth(nc) % where the retn is 1 if no problems, and deps contains the info % the input argument is an open netCDF object % emontgomery@usgs.gov Nov. 2008 %%% 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); retn=0; return; end if length(nc{'depth'}(:)) > 1 vals_ori=[nc.WATER_DEPTH(:) nc{'depth'}(:)']; else vals_ori=[nc.WATER_DEPTH(:) nc{'depth'}(:)]; end vn=var(nc); dep_atts=ones(1,length(vn)-5); vars_ori=ncnames(vn(6:length(vn))); for ik=6:length(vn) if (~isempty(vn{ik}.sensor_depth(:))) if length(nc{name(vn{ik})}.sensor_depth(:)) > 1 nc{name(vn{ik})}.sensor_depth=nc{name(vn{ik})}.sensor_depth(1); end dep_atts(ik-5)=[nc{name(vn{ik})}.sensor_depth(:)]; end end deps.strs={'DEPTH_attr' 'depth_var' vars_ori}; deps.vals=[vals_ori dep_atts]; retn=1;