How to regrid from finer to coarser resolution?

조회 수: 8 (최근 30일)
SUDIPTA GHOSH
SUDIPTA GHOSH 2014년 10월 8일
답변: Suraj Kumar 2025년 3월 4일
Hi! I want to regrid a data from 1degree X 1degree to a coarser resolution of 2degree X 5degree. I have used meshgrid and interp2 to change from coarser to finer resolution but I am not getting a way to change from finer to coarser resolution. Can anybody please help?

답변 (1개)

Suraj Kumar
Suraj Kumar 2025년 3월 4일
Based on my understanding your query is about regridding data from a finer resolution (1-degree by 1-degree) to a coarser resolution (2-degree by 5-degree) in MATLAB. This task involves aggregating or averaging the data over larger grid cells to achieve the desired coarser resolution.
You can refer to the following steps alongwith the attached code snippets for more information:
1. Define the original grid and data on a 1-degree by 1-degree grid.
% Original grid resolution
lat_resolution = 1;
lon_resolution = 1;
lat = -90:lat_resolution:90;
lon = 0:lon_resolution:360;
2. Initialize the coarser grid and define the new grid with 2-degree by 5-degree resolution.
% Define the new grid resolution
new_lat_resolution = 2;
new_lon_resolution = 5;
new_lat = -90:new_lat_resolution:90;
new_lon = 0:new_lon_resolution:360;
new_data = zeros(length(new_lat)-1, length(new_lon)-1);
3. Aggregate data for each cell in the coarser grid, averaging the corresponding cells from the finer grid.
% Regrid the data
for i = 1:length(new_lat)-1
for j = 1:length(new_lon)-1
lat_indices = find(lat >= new_lat(i) & lat < new_lat(i+1));
lon_indices = find(lon >= new_lon(j) & lon < new_lon(j+1));
data_block = data(lat_indices, lon_indices);
new_data(i, j) = mean(data_block(:), 'omitnan');
end
end
Hope this resolves your query!

카테고리

Help CenterFile Exchange에서 Physical Channels에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by