Got error while converting the low resolution data to high resolution data

1 回表示 (過去 30 日間)
I have some satellite data sets, which have a resolution of 2.5 degree. I want to make it to 0.1 degree resolution data. I have used some technique, but everytime i got some error. I am attaching the corresponding file and the code by which I have tried to regrid the data in higher resolution.
>> [loni,lati] = meshgrid(min_lon:1/4:max_lon,max_lat:-1/4:min_lat);
>> [loni,lati] = meshgrid(min_lon:1/10:max_lon,max_lat:-1/10:min_lat);
>> h = xch4_l3_mean(:,:,1);
>> h2 = interp2(lon,lat,h,loni,lati);
Error using interp2>makegriddedinterp (line 232)
Input grid is not a valid MESHGRID.
Error in interp2 (line 136)
F = makegriddedinterp(X, Y, V, method,extrap);
>> h2 = griddata(lon,lat,h,loni,lati);
Error using scatteredInterpolant
The input points must be a double array.
Error in griddata>useScatteredInterp (line 185)
F = scatteredInterpolant(inargs{1}(:),inargs{2}(:),inargs{3}(:), ...
Error in griddata (line 126)
vq = useScatteredInterp(inputargs, numarg, method, 'none');
The data can be found using the following codes :
lon = h5read('GOSATTFTS2019010120190131_03C02SV0295.h5','/Data/geolocation/longitude');
lat = h5read('GOSATTFTS2019010120190131_03C02SV0295.h5','/Data/geolocation/latitude');
xch4 = h5read('GOSATTFTS2019010120190131_03C02SV0295.h5','/Data/mixingRatio/XCH4');)

採用された回答

Walter Roberson
Walter Roberson 2021 年 8 月 7 日
Your lat and lon are arranged in ndgrid format, not in meshgrid format. You need to make an adjustment:
h2 = interp2(lat,lon,h,lati,loni);
Your input data is single precision. To use griddata you need
h2 = griddata(double(lon),double(lat),h,double(loni),double(lati));
  2 件のコメント
SWARNENDU PAL
SWARNENDU PAL 2021 年 8 月 7 日
Thank you sir for your response. The first one is working perfectly. But I have one question, what is the difference between meshgrid and ndgrid? and how to understand which one is meshgrid and which one is ndgrid?
Walter Roberson
Walter Roberson 2021 年 8 月 7 日
[A, B] = meshgrid(1:2, 3:5)
A = 3×2
1 2 1 2 1 2
B = 3×2
3 3 4 4 5 5
So meshgrid outputs number of rows equal to the length of the second parameter, and number of columns equal to the length of the first parameter. The first output has the values from the first parameter across the rows and repeated down the columns. The second output has the values from the second parameter down the columns and repeated across the rows.
[C, D] = ndgrid( 1:2, 3:5)
C = 2×3
1 1 1 2 2 2
D = 2×3
3 4 5 3 4 5
So ndgrid outputs number of rows equal to the length of the first parameter, and number of columns equal to the length of the second parameter. The first output has values from the first parameter down the columns and repeated across the rows. The second output has the values from the second parameter across ther rows and repeated down the columns.
ndgrid corresponds closer to the way that MATLAB indexes, with the first index of an array going down columns and the second index going across.
meshgrid corresponds closer to (X, Y) coordinates.
Some functions such as surf() require meshgrid() coordinate systems -- which fits because surf() expects x, y coordinates.
Besides the difference in sizes that are produced, the first output of meshgrid is constant in any one column and the first output of ndgrid is constant in any one row.
If you were to look at your lat and lon array, you would see that the values were constant across the wrong orientation for (lon, lat) to have been built with meshgrid.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeReference Applications についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by