how to use Matlab netCDF functions for 4 dimensions data?
조회 수: 9 (최근 30일)
이전 댓글 표시
I have data with four dimensions, there are (lon,lat,level,time). I have no idea what should I do with this kind of data.. this is the display of my data:
Variablename Size: 249x249x34x2 Dimensions: west_east,south_north,bottom_top,Time Datatype: single Attributes: FieldType = 104 MemoryOrder = 'XYZ' description = 'pm10 dry mass' units = 'ug m^-3' stagger = '' coordinates = 'XLONG XLAT'
% code
clc
clear
file = 'F:\...\';
data = double (ncread(file,'variablename'));
DATA = squeeze(data(:,:,1,1)); % I just think this command usable to 4D data (lon,lat,level,time), I don't know for sure
DATA = log10(DATA);
% lattitude and longitude
lat = double(ncread(file,'XLAT'));
lon = double(ncread(file,'XLONG'));
xlat = lat(1,:,1);
xlon = lon(:,1,1);
[xlat,xlon] = meshgrid(xlat,xlon);
When I use 'surfacem(xlat,xlon,DATA);' with the codes that following above, my result it is not look good, the DATA only shown around the ocean (lat and lon). please give me the suggestions the correct way to read 4D data and get the result from that kind of data.. I really need your help Thank you
댓글 수: 1
Chad Greene
2016년 6월 9일
If you double-click on DATA in the workspace it will show you the values in DATA. So to identify whether the problem is with surfacem or the underlying DATA, what are the values in DATA?
채택된 답변
KSSV
2016년 6월 9일
편집: KSSV
2024년 7월 19일
as your matrix is 4D....you can read the variable 'var' of your interest in the following way...
data = ncread(ncfile,'var',start,count,jump)
where start,count,jump will be vectors of size 4X1 (because you are dealing with 4D data)...default values of jump is [1,1,1,1]...you can put your interested number, jump will skip the data by the numbers given in the vector jump.
If count is [inf,inf,inf,inf], it will consider the matrix till the end. This will specify the end point of the data.
If start is [1,1,1,1], matrix will be read from first position of each dimension.
Reading your own interest data is pretty straight forward by varying start,count,jump. Read the documentation multiple times, it makes things clear.
댓글 수: 0
추가 답변 (1개)
Muhammad Usman Saleem
2016년 6월 9일
if you are using NCAR reanalysis then use get_NCAR function to process
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 NetCDF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!