How to read netCDF file ?
27 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 4 de Mayo de 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?
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre NetCDF en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!