Loading example_07_SLTAC_monthly_mean_uv_off_Brazil.m +57 −37 Original line number Diff line number Diff line Loading @@ -4,12 +4,10 @@ clear all close all % define path to data base_path = '/data/c2/TMdata/git_geomar_de_data/SLTAC_GLO_PHY_L4_REP/'; SLTAC_version = 'v1.x.x'; path_to_data = [base_path, SLTAC_version, '/data/']; % find indices of the region lat_lim = [-12 -4]; lon_lim = [-40 -30] + 360; Loading @@ -21,41 +19,61 @@ idy = find(lat_nc > lat_lim(1) & lat_nc < lat_lim(2)); % choose time period year_folder = [2000 : 2017]; % allocate fields % allocate monthly fields u_geo_m = NaN(length(idx), length(idy), length(year_folder) * 12); v_geo_m = u_geo_m; time_m = NaN(length(year_folder) * 12, 1); % init progressbar % initialize progressbar h = waitbar(0, 'Loading and averaging ...'); % load all files of one month and average for iy = 1 : length(year_folder) % find all data files for current year (determined by iy) filename_year = [path_to_data, num2str(year_folder(iy))]; KK = dir(filename_year); KK = KK(3 : end); % for all file names, extract months from file name for id = 1 : length(KK) mm(id) = str2num(KK(id).name(29 : 30)); end % for all months, find files for this month and average for im = 1:12 kk = find(mm == im); kk = find(mm == im); % returns indices matching current month % allocate temporary data fields u_geo = NaN(length(idx),length(idy),length(kk)); v_geo = u_geo; % load all files for current month for ik = 1:length(kk) time(ik) = double(ncread([filename_year,'/',KK(kk(ik)).name],'time'))+datenum(1950,1,1,0,0,0); ugos = double(ncread([filename_year,'/',KK(kk(ik)).name],'ugos')); filename_current_day = [filename_year, '/', KK(kk(ik)).name]; time(ik) = double(ncread(filename_current_day, 'time')); time(ik) = time(ik) + datenum(1950, 1, 1, 0, 0, 0); ugos = double(ncread(filename_current_day, 'ugos')); u_geo(:,:,ik) = ugos(idx, idy); vgos = double(ncread([filename_year,'/',KK(kk(ik)).name],'vgos')); vgos = double(ncread(filename_current_day, 'vgos')); v_geo(:,:,ik) = vgos(idx, idy); end % average and store in final arrays u_geo_m(:, :, (iy - 1) * 12 + im) = nanmean(u_geo, 3); v_geo_m(:, :, (iy - 1) * 12 + im) = nanmean(v_geo, 3); time_m((iy - 1) * 12 + im) = nanmean(time); % update status bar waitbar(((iy - 1) * 12 + im) / (length(year_folder) * 12), h) end clear mm KK end % close status bar close(h) % save as matfile Loading @@ -64,13 +82,15 @@ lat = lat_nc(idy); time = time_m; ugeo_mon = u_geo_m; vgeo_mon = v_geo_m; save example_07_SLTAC_monthly_mean_uv_off_Brazil lon lat time ugeo_mon vgeo_mon save geo_surf_vel lon lat time ugeo_mon vgeo_mon % figure(1);clf % m_proj('mercator','long',[-40 -30],'lat',[-12 -4]);hold on % m_contourf(lon_nc(idx)-360,lat_nc(idy),nanmean(u_geo_m,3)',[-.5:1/63:.5],'edgecolor','none') % m_gshhs_h('patch',[.5 .5 .5]); hold on % colorbar % and plot figure(1); m_proj('mercator', 'long', [-40 -30], 'lat', [-12 -4]); hold on m_contourf( ... lon_nc(idx) - 360, lat_nc(idy), nanmean(u_geo_m, 3)', ... [-.5 : 1 / 63 : .5], 'edgecolor', 'none') m_gshhs_h('patch', [.5 .5 .5]); colorbar savefig('example_07_SLTAC_monthly_mean_uv_off_Brazil.png') Loading
example_07_SLTAC_monthly_mean_uv_off_Brazil.m +57 −37 Original line number Diff line number Diff line Loading @@ -4,12 +4,10 @@ clear all close all % define path to data base_path = '/data/c2/TMdata/git_geomar_de_data/SLTAC_GLO_PHY_L4_REP/'; SLTAC_version = 'v1.x.x'; path_to_data = [base_path, SLTAC_version, '/data/']; % find indices of the region lat_lim = [-12 -4]; lon_lim = [-40 -30] + 360; Loading @@ -21,41 +19,61 @@ idy = find(lat_nc > lat_lim(1) & lat_nc < lat_lim(2)); % choose time period year_folder = [2000 : 2017]; % allocate fields % allocate monthly fields u_geo_m = NaN(length(idx), length(idy), length(year_folder) * 12); v_geo_m = u_geo_m; time_m = NaN(length(year_folder) * 12, 1); % init progressbar % initialize progressbar h = waitbar(0, 'Loading and averaging ...'); % load all files of one month and average for iy = 1 : length(year_folder) % find all data files for current year (determined by iy) filename_year = [path_to_data, num2str(year_folder(iy))]; KK = dir(filename_year); KK = KK(3 : end); % for all file names, extract months from file name for id = 1 : length(KK) mm(id) = str2num(KK(id).name(29 : 30)); end % for all months, find files for this month and average for im = 1:12 kk = find(mm == im); kk = find(mm == im); % returns indices matching current month % allocate temporary data fields u_geo = NaN(length(idx),length(idy),length(kk)); v_geo = u_geo; % load all files for current month for ik = 1:length(kk) time(ik) = double(ncread([filename_year,'/',KK(kk(ik)).name],'time'))+datenum(1950,1,1,0,0,0); ugos = double(ncread([filename_year,'/',KK(kk(ik)).name],'ugos')); filename_current_day = [filename_year, '/', KK(kk(ik)).name]; time(ik) = double(ncread(filename_current_day, 'time')); time(ik) = time(ik) + datenum(1950, 1, 1, 0, 0, 0); ugos = double(ncread(filename_current_day, 'ugos')); u_geo(:,:,ik) = ugos(idx, idy); vgos = double(ncread([filename_year,'/',KK(kk(ik)).name],'vgos')); vgos = double(ncread(filename_current_day, 'vgos')); v_geo(:,:,ik) = vgos(idx, idy); end % average and store in final arrays u_geo_m(:, :, (iy - 1) * 12 + im) = nanmean(u_geo, 3); v_geo_m(:, :, (iy - 1) * 12 + im) = nanmean(v_geo, 3); time_m((iy - 1) * 12 + im) = nanmean(time); % update status bar waitbar(((iy - 1) * 12 + im) / (length(year_folder) * 12), h) end clear mm KK end % close status bar close(h) % save as matfile Loading @@ -64,13 +82,15 @@ lat = lat_nc(idy); time = time_m; ugeo_mon = u_geo_m; vgeo_mon = v_geo_m; save example_07_SLTAC_monthly_mean_uv_off_Brazil lon lat time ugeo_mon vgeo_mon save geo_surf_vel lon lat time ugeo_mon vgeo_mon % figure(1);clf % m_proj('mercator','long',[-40 -30],'lat',[-12 -4]);hold on % m_contourf(lon_nc(idx)-360,lat_nc(idy),nanmean(u_geo_m,3)',[-.5:1/63:.5],'edgecolor','none') % m_gshhs_h('patch',[.5 .5 .5]); hold on % colorbar % and plot figure(1); m_proj('mercator', 'long', [-40 -30], 'lat', [-12 -4]); hold on m_contourf( ... lon_nc(idx) - 360, lat_nc(idy), nanmean(u_geo_m, 3)', ... [-.5 : 1 / 63 : .5], 'edgecolor', 'none') m_gshhs_h('patch', [.5 .5 .5]); colorbar savefig('example_07_SLTAC_monthly_mean_uv_off_Brazil.png')