function proc2ndbc % proc2ndbc % % Last modified: Time-stamp: <2004-10-12 17:10:22 haines> % % Abstract: Extract latest NCCOOS data into NDBC encoder input format. % % Usage: >> proc2ndbc % % % Author: Sara Haines, Oct 17, 2004 % Not using Tae Lerch's C++ (dods2ndbc) because I cannot get all DAP, STL % classes to compile and all DAP, SSL libraries to link. This needs to be % revisited soon. % Processing: % In general, for each tower and met package want to produce small NDBC % files. We will need to address in-water and multiple tower/buoys in near future. % % Uses the monthly netCDF files, but these are in a state of flux, so % expect changes that might break this routine. % proc_nc_dir = '/seacoos/data/nc-coos/tower/proc_data'; out_dir = '/seacoos/data/nc-coos/latest_ndbc'; % testing on pitot % proc_nc_dir = './test_data'; % out_dir = './test_data'; % get the current time (GMT), as processing time reference point especially % for auto mode. This unix call is required to get date in GMT since MATLAB % has no function to get this without hardcoding it. [e,z]=unix(['date -u ''+%d-%b-%Y %H:%M:%S''']); pause(1); current_time_dn = datenum(z(1:end-1)); % show time of run for the log files fprintf(2,'\nStart time: %s\n', datestr(current_time_dn, 'dd-mmm-yyyy HH:MM:SS')); fprintf(2,['Data to NDBC for latest 6 hours data from all towers, all packages ...\n']); % get info for processing latest data % info = config_latest; % use current time (current_time_dn) to set month and previous month strings % month_str = datestr(current_time_dn, 'mmmyy'); % e.g. Apr03 month_str = [datestr(current_time_dn, 'yyyy') '_' ... datestr(current_time_dn, 'mm')]; % e.g. 2003_04 % determine previous month string from current. Need this to make the % month transition. dv = datevec([month_str(6:7) '/01/' month_str(1:4)]); % make it 04/01/2000] prev_month_str = [datestr(datenum(dv(1),dv(2),-1,0,0,0),'yyyy') '_' ... datestr(datenum(dv(1),dv(2),-1,0,0,0),'mm')]; % e.g. 2003_04 % directory of stations x = dir([proc_nc_dir '/*']); % remove any parent or current directories or not a directory x = struct2cell(x); x = x(1,:); whichnot = find(strcmp(x,'.') | strcmp(x,'..') | strcmp(x,'latest_v2.0') | strcmp(x,'T1')); x(whichnot)=[]; [n, numtowers] = size(x); info.current_time_dn = current_time_dn; info.month_str = month_str; info.prev_month_str = prev_month_str; info.proc_nc_dir = proc_nc_dir; info.out_dir = out_dir; % **** just R4 for now info.ncdir = [info.proc_nc_dir '/R4']; info.platform_name = 'R4'; info.package_name = 'met'; info.location_name = 'US Navy Tower R4'; info.location_lat = 30.8; info.location_lon = -80.316; info.baro_ht = 19; % meters info.wind_ht = 35; % meters info.atemp_ht = 19; % meters % for NDBC info.station = 'SECG1'; info.routing_id = 'NTXX90 KWBG'; info.msgfmt = 'CMAN'; info.wsunits = 'meters/second'; get_latest_met(info); % for each station % for i=1:numtowers % determine package names % y = dir([proc_nc_dir '/' char(x(i)) '/*']); % y = struct2cell(y); % y = y(1,:); % whichnot = find(strcmp(y,'.') | strcmp(y,'..')); % y(whichnot) = []; % [n, numpack] = size(y); % % for each package % for j=1:numpack % fprintf(2, ['... %s/%s\n'], char(x(i)), char(y(j))); % % info.platform_name = upper(char(x(i))); % info.package_name = char(y(j)); % % switch char(y(j)) % case {'met', 'metB'} % info.ncdir = [info.proc_nc_dir '/' char(x(i)) '/' char(y(j))]; % get_latest_met(info); % case { 'near_surf', 'near_bot' } % info.ncdir = [info.proc_nc_dir '/' char(x(i)) '/' char(y(j))]; % get_latest_near_surf(info); % case { 'press' } % case { 'adcp' } % otherwise % end % end % % end