var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opens = _____WB$wombat$assign$function_____("opens"); function get_latest_met(info) % get_latest_met(info) % % Last modified: Time-stamp: <2025-09-14 17:21:11 haines> % % Abstract: Function that loads, appends new data, and saves with all data % % Usage: get_latest_met(info) % Processing steps % (1) load previous month and current month data from netCDF % (2) append current to previous % (3) subset data for latest 48 hours % (4) calc u and v, and air_pressure_at_sea_level, and other times % (5) create new file of global attributes, dimensions, and variables % (6) save (ncclose) file % Author: Sara Haines, Sep 14, 2025 have_this_month = 0; have_prev_month = 0; x = dir([info.ncdir '/*.nc']); for i=1:length(x) % x(i).name if strfind(x(i).name, [info.platform_name '_' info.month_str '.nc']) have_this_month = 1; ncfile_this_month = [info.ncdir '/' x(i).name]; elseif strfind(x(i).name, [info.platform_name '_' info.prev_month_str '.nc']) have_prev_month = 1; ncfile_prev_month = [info.ncdir '/' x(i).name]; end end % have_this_month % have_prev_month % (1) load previous and current months of data if (have_this_month & have_prev_month) % if have both append this month data to previous month data nc_prev = netcdf(ncfile_prev_month, 'nowrite'); nc_this = netcdf(ncfile_this_month, 'nowrite'); % get variables % (2) append current to previous dn = [nc_prev{'time'}(:); nc_this{'time'}(:)]; % size(dn) awspd = [nc_prev{'WSPDA'}(:); nc_this{'WSPDA'}(:)]; awdir = [nc_prev{'WDIRA'}(:); nc_this{'WDIRA'}(:)]; wgust = [nc_prev{'WGSTA'}(:); nc_this{'WGSTA'}(:)]; atemp = [nc_prev{'ATEMP'}(:); nc_this{'ATEMP'}(:)]; rh = [nc_prev{'RH'}(:); nc_this{'RH'}(:)]; abaro = [nc_prev{'BARO'}(:); nc_this{'BARO'}(:)]; elseif (have_this_month & ~have_prev_month) % if only this month just only use this month nc_this = netcdf(ncfile_this_month, 'nowrite'); % get variables dn = nc_this{'time'}(:); % size(dn) awspd = [nc_prev{'WSPDA'}(:)]; awdir = [nc_prev{'WDIRA'}(:)]; wgust = [nc_prev{'WGSTA'}(:)]; atemp = [nc_prev{'ATEMP'}(:)]; rh = [nc_prev{'RH'}(:)]; abaro = [nc_prev{'BARO'}(:)]; else % if don't have, don't write out new netcdf file fprintf(2, ['... ... no current met data to read\n']); end % (3) subset data to within the last 48 hours (2 days) if have_this_month current_dn = info.current_time_dn; two_days_ago = current_dn-2; % datenum is in units of days which_latest = find(two_days_ago<=dn & dn