How to read netCDF file ?
이전 댓글 표시
l downloaded netCDF master. zip and GEBCO_2020.nc file.
I want to read this netCDF file and plot. But l met this error. What should I do?
Error using internal.matlab.imagesci.nc/openToRead (line 1272)
Could not open GEBCO_2020.nc for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncdisp (line 62)
ncObj = internal.matlab.imagesci.nc(ncFile);
Error in read_necdf (line 12)
ncdisp(file)
Below is the code I used.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; close all;
% set(0,'Units','pixels');
% scnsize = get(0,'ScreenSize');
% pos1 = [10, 10, 1910, 1070];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
file = 'GEBCO_2020.nc';
%
ncdisp(file)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
time = ncread(file,'time')
%
shot = ncread(file,'shot');
depth = ncread(file,'depth');
SS = ncread(file,'SS',[1 1],[Inf Inf]);
% SS = ncread(file,'temp',[1 1],[Inf Inf]);
% SS = ncread(file,'sal',[1 1],[Inf Inf]);
figure(1);
plot(shot);
figure(3);
plot(depth);
% %
% SS_struct = struct( 'shot', shot, 'depth', depth, 'SS', SS );
% SS_mod = struct('SS',SS_struct);
%
% [xx,yy] = meshgrid(SS_mod.SS_struct.shot,SS_mod.SS_struct.depth);
% zz = SS_mod.SS_struct.SS_struct(:,:,1);
figure(2);
% pcolor(double(xx),double(yy),double(zz))
pcolor( double(SS) );
% caxis([1500 1520]);
colorbar('location','EastOutside'); set(gca,'linewidth',1,'fontsize',16);
shading flat; axis('ij');
댓글 수: 7
Walter Roberson
2021년 5월 4일
Either it could not find the file on the MATLAB path, or else it found the file but you do not have read permission for the file.
KSSV
2021년 5월 4일
What does this line show?
ncdisp(file)
Walter Roberson
2021년 5월 4일
I am downloading the file from https://www.gebco.net/data_and_products/gridded_bathymetry_data/ but it is a bit slow...
주향 이
2021년 5월 4일
주향 이
2021년 5월 4일
Walter Roberson
2021년 5월 4일
I went to https://www.gebco.net/data_and_products/gridded_bathymetry_data/ and downloaded https://www.bodc.ac.uk/data/open_download/gebco/gebco_2020/zip/ which contains gebco_2020_netcdf.zip which contains a directory gebco_2020_netcdf which contains two .pdf files and GEBCO_2020.nc . The .zip is 4 Gigabytes, expanding to 7 gigabytes.
However.. that nc file does not have any time information, only lat, lon, and elevation.
Which file are you looking at?
주향 이
2021년 5월 5일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 NetCDF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!