% scriptexample - example file for running the ADCP toolbox in automated mode %%% 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 -------------- clear % a good idea % --------- set up the information needed by the programs % % this is what should be used if using a single source of global attributes % 9/15/07 etm % modified to use the universal metadata file : 7751glatt.txt % change the line below to fit your system path for the location of m_cmg mfRoot='C:\home\ellyn\mtl\'; gatt=read_globalatts('globatt_805.txt'); % assign the rootName based on the Mooring #, then plug in values from % the global attributes. UNIX users : check CASE of files carefully! rootName=[num2str(gatt.MOORING) ]; rootName=[rootName '1']; % ADCP is usually the top thing, but it could be % second or third- change this value accordingly %% the basics settings.numRawFile = 1; % number of raw binary ADCP files (*.000 or *.PD0), max = 2 settings.rawdata1 = [rootName 'WH000.000']; % raw file #1 settings.rawdata2 = ''; % raw file #2, if numrawfile=2, must have a name settings.rawcdf = [rootName 'wh.cdf']; % output file name for the raw data in netCDF format settings.theFilledFile = [rootName 'whF.cdf']; % the name of the fill file settings.theMaskFile = [rootName 'wh.msk']; % the name of the mask file settings.theNewADCPFile = [rootName 'whM.cdf']; % the name of the new file with the mask applied settings.trimFile = [rootName 'whT.cdf']; % the name of the file trimmed by time out of water and by bin settings.deployed_orientation = 'UP'; % or DOWN, to check against what is set in the ADCP %% conversion from RDI binary to raw netCDF settings.rdi2cdf.run = 1; % force runadcp to run rdi2cdf settings.rdi2cdf.Mooring_number = gatt.MOORING; % mooring number (USGS) or other identifier settings.rdi2cdf.platform_type = gatt.platform_type; settings.rdi2cdf.Deployment_date = gatt.Deployment_date; % the in water time settings.rdi2cdf.Recovery_date = gatt.Recovery_date; % the out of water time settings.rdi2cdf.water_depth = gatt.WATER_DEPTH; % m (DO NOT OMIT!) settings.rdi2cdf.water_depth_source = 'Mooring Log'; % the user needs to edit the ones below settings.rdi2cdf.ADCP_serial_number = 185; settings.rdi2cdf.transducer_offset = 3.34; % ADCP transducer offset from the sea bed settings.rdi2cdf.pred_accuracy = 0.35; % from TRDI PLAN in cm/s settings.rdi2cdf.slow_by = -45; % clock drift settings.rdi2cdf.long = gatt.longitude; % negative degrees in western hemisphere settings.rdi2cdf.latit = gatt.latitude; % always positive degrees in northern settings.rdi2cdf.burst_sampling = 'No'; % if TB and TC were used %settings.rdi2cdf.TB_command = '01:00:00.00'; % use the actual setting %settings.rdi2cdf.TC_command = 1024; % use the actual setting settings.rdi2cdf.AZ_applied = 'Yes'; % was pressure zeroed before deployment %% now look for missing ensembles (restarts) settings.fixens.run = 1; % force runadcp to run fixens (future implementation) %% now trim the profiles % there are several methods one can use to trim bins to the surface % see trimbins.m documentation for more information %methods: 'RDI Surface Program' | 'User Input' | 'Pressure Sensor' | 'USGS Surface Program' % use pressure sensor, if available! settings.trimbins.method = 'Pressure Sensor'; %'USGS Surface Program'; % percent of water column to make sure is preserved when trimming (1 = 100%) settings.trimbins.percentwc = 1.12; % to capture full range of tide settings.trimbins.ADCP_offset = settings.rdi2cdf.transducer_offset; % leave this alone % these control the MATLAB surface detect algorithm findsurface.m settings.trimbins.findsurface.cdfFile = settings.rawcdf; % leave this alone settings.trimbins.findsurface.S = 32; % local salinity assumption % if you know the approximate range of the surface, you can avoid a % dialog box by entering that information here settings.trimbins.findsurface.trimrange = []; % range to clip surface data %% set up adcp2ep, the final rotation to earth, conversion to EPIC conventions settings.adcp2ep.epDataFile = [rootName 'wh.nc']; % final output file name settings.adcp2ep.origin = gatt.DATA_ORIGIN; % with collaborator's data, could be USC, etc. settings.adcp2ep.experiment = gatt.EXPERIMENT; settings.adcp2ep.descript = gatt.DESCRIPTION; settings.adcp2ep.SciPi = gatt.SciPi; settings.adcp2ep.conventions = gatt.Conventions; settings.adcp2ep.project = gatt.PROJECT; % might also use OFA funding agency, such as MWRA, EPA, WCMG settings.adcp2ep.cmnt = ''; % your metadata settings.adcp2ep.water_mass = ' '; % an EPIC requirement settings.adcp2ep.magnetic_variation_at_site = gatt.magnetic_variation; % your data will be rotated byt his value! settings.adcp2ep.magnetic_variation_applied = settings.adcp2ep.magnetic_variation_at_site; % the dialog file for your ADCP, there is one in the Demo directory. % the toolbox use the instrument elevation and azimuth specific to each ADCP % which can vary slightly as the manufacturing process does not line up the % transducers exactly, and RDI has a correction for this. % if you want to use the default matrix, use 'default' for the file name settings.adcp2ep.dlgFile = 'wh185.dlg'; % generated by the ADCP using the PS3 command settings.adcp2ep.ADCPtype = 'WH'; % WH for workhorse or BB for broadband % --------------------- run the programs % % turn each step "on" by setting "if 1" and off by using "if 0" % steps must be run in sequence settings.rdi2cdf.goodens = [1 500]; % use [1 inf] to process all diary(sprintf('run%s',datestr(now, 30))) % sometimes ADCPs don't know which way they were really facing. % do rdi2cdf and fixorientation only for deployments that need orientation fixed: % if 0, % run rdi2cdf separately to fix the orientation % rdi2cdf(settings.rawdata1,settings.rawcdf,[],[],... % settings.rdi2cdf); % user's provideing metadata % orientation = 'UP'; % 'UP' or 'DOWN' % fixorientation(settings.rawcdf,orientation); % % when rdi2cdf is run the second time via runadcp (below) % % the file converted here will not be overwritten % end if 1, % translate to netcdf, mask for basic errors and trim the data % this encompasses doing a LOT of processing: % rdi2cdf Convert raw file to cdf. % fixEns Find and correct for missing ensembles % runmas applies mask from fixEns % trimbin WaterDepth computed & bins above the surface discarded runadcp(settings) end if 0, % apply a mask that tracks the surface - if you wish to [path, name, ext] = fileparts(settings.trimFile); theMaskFile = fullfile(path,[name, '.msk']); theNewADCPFile = fullfile(path,[name, 'P.cdf']); [theNewADCPFile, theMaskFile] = pressuremask (settings.trimFile,... theMaskFile,theNewADCPFile) end if 1, % rotate from beam to earth coordinates, translate raw netCDF to EPIC [path, name, ext] = fileparts(settings.trimFile); theNewADCPFile = fullfile(path,[name, 'P.cdf']); if exist(theNewADCPFile,'file'), settings.trimFile = theNewADCPFile; disp(['Using ',settings.trimFile,' for adcp2ep']) end adcp2ep(settings.trimFile, settings.adcp2ep.epDataFile, ... settings.adcp2ep.ADCPtype, settings.adcp2ep.dlgFile, settings.adcp2ep) end diary off