function proc2latest % proc2latest % % Last modified: Time-stamp: <2025-09-14 16:30:28 haines> % % Abstract: Get latest SABSOON data into smaller netCDF files as part of the % SEACOOS merged product effort. % % Usage: >> proc2latest % % % Author: Sara Haines, Sept 14, 2025 % Processing: % In general, for each tower and package want to produce a file of last 48 % hours of obs. This file is a netCDF file with agreed upon conventions (Sep % 12, 2003 -- see Celoxis Metadata Project, % http://aslnx1.oasis.unc.edu:8080/psa/servlet/project?bxn=cview&p_p_id=2139) % for metadata content, structure, format, and naming conventions. % % 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_nc_v20_dir = '/seacoos/data/nc-coos/latest_v2.0'; % 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''']); 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,['Processing latest 48 hour 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/2025] 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_nc_v20_dir = out_nc_v20_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 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