How to read netCDF file ?
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 4 Mai 2021
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
am 4 Mai 2021
What does this line show?
ncdisp(file)
Walter Roberson
am 4 Mai 2021
I am downloading the file from https://www.gebco.net/data_and_products/gridded_bathymetry_data/ but it is a bit slow...
주향 이
am 4 Mai 2021
주향 이
am 4 Mai 2021
Walter Roberson
am 4 Mai 2021
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?
주향 이
am 5 Mai 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu NetCDF finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!