function n = EPIC_plus_polar(in_name,out_name) % EPIC_plus_polar: add polar current components (direction, speed) % to an EPIC data file. % % in_name is the name of an epic netcdf file. % out_name is the name of an epic netcdf file which will be % written, and will contain all the variables and % attributes of in_name. % % Fran Hotchkiss, 04 Nov 1999. % Copy inc to outc. result=fcopy(in_name,out_name) % Open outc. outc = netcdf(out_name, 'write') %Update attributes for out_name. outc.CREATION_DATE = ncchar(datestr(now,0)); history = ['Current direction and speed added: ' outc.history(:)]; outc.history = ncchar(history); VAR_DESC = [outc.VAR_DESC(:) ':CS:CD']; outc.VAR_DESC = VAR_DESC; % Create new out_name variables and their attributes. outc{'CS_300'} = ncfloat('time', 'depth', 'lat', 'lon') outc{'CS_300'}.name = ncchar('CS'); outc{'CS_300'}.long_name = ncchar('CURRENT SPEED (CM/S) '); outc{'CS_300'}.generic_name = ncchar('vspd'); outc{'CS_300'}.FORTRAN_format = ncchar('f8.2'); outc{'CS_300'}.units = ncchar('cm s-1 '); outc{'CS_300'}.epic_code = nclong(300); outc{'CS_300'}.sensor_depth = ncfloat(0); outc{'CS_300'}.serial_number = ncchar(' '); outc{'CS_300'}.minimum = ncfloat(0); outc{'CS_300'}.maximum = ncfloat(0); outc{'CS_300'}.valid_range = ncfloat([0 1000]); outc{'CS_300'}.FillValue_ = 1.0e35; outc{'CD_310'} = ncfloat('time', 'depth', 'lat', 'lon') outc{'CD_310'}.name = ncchar('CD'); outc{'CD_310'}.long_name = ncchar('CURRENT DIRECTION (T) '); outc{'CD_310'}.generic_name = ncchar('vdir'); outc{'CD_310'}.FORTRAN_format = ncchar('f8.2'); outc{'CD_310'}.units = ncchar('degrees'); outc{'CD_310'}.epic_code = nclong(310); outc{'CD_310'}.sensor_depth = ncfloat(0); outc{'CD_310'}.serial_number = ncchar(' '); outc{'CD_310'}.minimum = ncfloat(0); outc{'CD_310'}.maximum = ncfloat(0); outc{'CD_310'}.valid_range = ncfloat([0 360]); outc{'CD_310'}.FillValue_ = 1.0e35; outv = outc{'v_1206'}(:); outu = outc{'u_1205'}(:); [dir,spd] = uv2polar(outu,outv); %Update min/max attributes. outc{'CD_310'}.minimum = ncfloat(min(dir)); outc{'CD_310'}.maximum = ncfloat(max(dir)); outc{'CS_300'}.minimum = ncfloat(min(spd)); outc{'CS_300'}.maximum = ncfloat(max(spd)); %Put data in out_name. n = length(dir); outc{'CD_310'}(1:n) = dir(1:n); outc{'CS_300'}(1:n) = spd(1:n); ncclose