Interpolating 3D Gridded Data in Matlab
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
I have a 3D gridded data and I want to interpolate to increase the size of the data. Current resolution is 5 deg long x 5 deg latitude and I want to change the resolution to 2 deg long x 2 deg latitude as I am interested in Lat = 2 deg. The dimension of the data is (Longitude x Latitude x Height) and current size is (72x36x40).
Long= 72x36x40
Lat = 72x36x40
Height =72x36x40
Temperature =72x36x40
I tried to use the interpn function but at the end I am only getting NaN values. Below are my codes.
file='data.nc';
Lat1 = ncread(file,'Latitude'); % Size is 72x36x40
Long1 = ncread(file1, 'Longitude'); % Size is 72x36x40
Height = ncread(file1,'Height'); % Size is 72x36x40
Temp1 = ncread(file,'Temperature'); % Size is 72x36x40
[LongI,LatI,HeightI] = ndgrid(0:5:360,-90:5:90,0:10:600);
TempI = interpn(Long1,Lat1,Height,Temp1,LongI,LatI,HeightI,'linear');`
My goal is to convert 3D data at 5 long x 5 lat resolution to 2 long x 2 lat resolution.
채택된 답변
This might be easier:
LUT= griddedInterpolant(Long1,Lat1,Height,Temp1,'linear','linear'); %create interp object
newgrid=LUT.GridVectors;
newgrid(1:2)=cellfun(@(z) z(1):2:z(end) , newgrid(1:2),'uni',0); %change the sampling lattice in the first two coordinates to be increments of 2
TempI = LUT(newgrid); %interpolate on newgrid
댓글 수: 11
Mark
2022년 11월 21일
Thanks @Matt J for your asistance here. Code is working now. Maybe if you could comment in your code so that I can get better sense out of it. Could you also advise how I will be able to take a slice at a particular latitude and longitude in TempI data.
I am interested in taking a slice at Lat= 2 degrees and Long = 2 degrees
I'm glad. Could you Accept-click the answer to indicate so?
I am interested in taking a slice at Lat= 2 degrees and Long = 2 degrees
At what heights? If at all the heights originally sampled, then,
Heights=LUT.GridVectors{3};
slice=LUT({2,2,Heights});
Mark
2022년 11월 21일
Thanks @Matt J. I should have been more specific. Actually, I want to take a slice at two specific point
Point one: Lat = 2 degrees and height = 100 km.
Point two: Long = 2 degrees and height = 100km.
My orignal latitude varies in a increment of 5 degrees from -90 to +90 i.e (-90:5:90).
Same thing.
[LATS,LONGS,HEIGHTS]=deal(LUT.GridVectors{:});
Point1=LUT({2,LONGS,100});
Point2=LUT({LATS,2,100});
Mark
2022년 11월 21일
Thank you so much. Is there a way to check if it is plotting at these points i.e can we see all these new gridded data like Lat, Long, Height and Temp in 2 deg long x 2 degree lat.
Matt J
2022년 11월 21일
It is not plotting. None of the code I gave you forms an actual plot.
Mark
2022년 11월 21일
I meant how to check if this point (Point1=LUT({2,LONGS,100})) actually crosspond to Lat = 2 degree and Height =100 km. Can we read or see all the parameters (Long, Lat, Height and Temp).
I meant how to check if this point (Point1=LUT({2,LONGS,100})) actually crosspond to Lat = 2 degree and Height =100 km. Can we read or see all the parameters (Long, Lat, Height and Temp).
Well, {Long,Lat,Height} are what we are specifying as input in the form {2,LONGS,100}. So, I don't know what you mean by "checking" it. It is something that we provided and which can be directly inspected. The temperature values are contained in the output Point1.
If you have reason to believe that LUT did not do the interpolation correctly when computing Point1, you have to say what sort of independent test would reassure you.
Or, do you mean you just want to retrieve the underlying data that is being interpolated? That is contained in LUT.GridVectors and LUT.Values.
Mark
2022년 11월 22일
Thanks @Matt J. I would like to retrieve the data that are been interpolated. All of the original data (Long, Lat,Height, Temp) are in a resolution of 5 long x 5 lat and I would like to increase the resolution of the data so that the resolution of the new data is 2 long x 2 lat. The dimension of the data is long x lat x height and I only want to change the size of long and lat. After interpolation I want to access or read all of my new data like long, lat, height and Temp so that I can do some plotting.
That was given in my original answer. After the upsampling to 2 long x 2 lat, the upsampled {long,lat,height} are in newgrid, while the upsampled temperatures are in TempQ.
Mark
2022년 11월 22일
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기
참고 항목
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
