How to read netCDF file ?

27 visualizaciones (últimos 30 días)
주향 이
주향 이 el 4 de Mayo de 2021
Comentada: KSSV el 5 de Mayo de 2021
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
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?
주향 이
주향 이 el 5 de Mayo de 2021
Ah... I just thught this funtion reads my netCDF file and plots figure.
I don't need time information.
So l delete time = ncread(file,'time') ?

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 4 de Mayo de 2021
  4 comentarios
주향 이
주향 이 el 5 de Mayo de 2021
Thank you!
Out of memory. The likely cause is an infinite recursion within the program.
l met this error..
KSSV
KSSV el 5 de Mayo de 2021
Reduce the bounding box.... The data which you are trying to read is huge and your RAM cannot support that much size.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by