How to read and plot NetCDF files with Matlab, file extension .nc - with script (2020)

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • This is a tutorial of how to read netcdf files and plot its variables in a matlab colored graph. This code also works in octave. Have a look to the script: bernardobastie...

Комментарии • 61

  • @umedina98
    @umedina98 4 года назад

    Amazing video! Saved me. For some people who have asked in the comments:
    1. I am currently running Matlab 2020 and I needed to download the "Mapping Toolbox" in order for the load coast command to work.
    2. If the map appears all black you need to the remove the edges using the .EdgeAlpha=0 function.

  • @annanickoloff810
    @annanickoloff810 2 года назад

    Thanks so much for the video, Bernardo. super helpful and comprehensible! I really appreciate it :)

  • @pedroperezsanchez9984
    @pedroperezsanchez9984 4 года назад

    Eres una máquina Bernardo, me acabas de salvar el TFG muchas gracias!!

  • @RAHUL-bd2vu
    @RAHUL-bd2vu 7 лет назад

    wow man ..you are great , saved my life ..thank you so much from india :)

  • @JoseCervantespiinnn
    @JoseCervantespiinnn 7 лет назад +1

    Tu vídeo solucionó totalmente mis dudas, muchas gracias :)

  • @zoekriona5835
    @zoekriona5835 5 лет назад +5

    Hi Bernardo!Thank you for this helpful video. I would like to ask you how to plot ECMWF ERA-Interim data for the sea surface temperature. I have opened the netCDF file but the matrix for the SST has an extra dimension ' time' and this makes it more cmplicated for me.Has anyone any suggestions how to plot my data in matlab?

    • @avirupsen5390
      @avirupsen5390 4 года назад +1

      Yes, I am facing the same issue too. Any updates? Did you manage to figure it out?

  • @camilorendonvaldez944
    @camilorendonvaldez944 3 года назад

    Hi Bernardo, I tried like you show, but appear and error after executing :
    >>ncdisp(filename)
    Error using internal.matlab.imagesci.nc/openToRead (line 1272)
    Could not open gebco_2020_n24.400634765625_s22.965087667107582_w-107.59277299046518_e-105.77636629343034.nc for reading.
    In the current folder appears some files, Do I need them? I am using a R2020b, regards

  • @agirl3517
    @agirl3517 Год назад

    Sir to plot a graph, my third variable is in column matrix, hence it is not plotting graph, can you plz tell me how I can make it a matrix so that I can use it in plotting

  • @sandyherho1997
    @sandyherho1997 4 года назад

    Hi I got this error:
    Error using pcolor (line 61)
    Matrix dimensions must agree.
    when running :
    filename = 'xndcaa.pmh9jul.nc';
    lat = ncread(filename, 'latitude');
    lon = ncread(filename, 'longitude');
    temp = ncread(filename, 'surf_temp') - 273.15;
    mymap = pcolor(lon, lat, temp);
    Do you know how to fix that? I'm running Matlab 2018a.

  • @geoffreysaville2439
    @geoffreysaville2439 7 лет назад

    Nice one, Berny. This is really helpful as I develop my Matlab NetCDF skills :) Thanks mate!

  • @alidanandehmehr7147
    @alidanandehmehr7147 5 лет назад

    Hi, I tried to use the relevant m file, but got the error below:
    Error using netcdflib
    The NetCDF library encountered an error during execution of 'inqVar' function - 'Variable not found
    (NC_ENOTVAR)'
    Any suggestion?

  • @suckawatziproduction
    @suckawatziproduction 3 года назад

    Ben Osborne the great sent me here. COool stuff man. Do a meet and greet so I can give you me XD

  • @ericklsv
    @ericklsv 6 лет назад

    Hi Bernardo, I'm trying to extract the points inside a watershed from a netcdf file. The file is a cmip5 output file in a daily time step and has four dimensions (lat, lon, time and bnds) and seven variables (lat, lat_bnds, lon, lon_bnds, time, time_bnds, pr).
    Could you please help me with this problem?

  • @hansclarke8932
    @hansclarke8932 7 лет назад +2

    Hi this is very useful. Thanks Bernardo Adolfo Bastién Olvera! Just trying to plot the upwelling case for ROMS, if anyone is familiar with that...attempting to plot:
    pcolor(x_rho, y_rho, h)
    with the error:
    Warning: MATLAB has disabled some advanced graphics rendering features by
    switching to software OpenGL. For more information, click here.
    Thanks

    • @bredo91
      @bredo91  7 лет назад

      hi, thabk you! I haven't heard about ROMS, and also the warning looks wierd. Maybe is not the coding but the matlab version or something in your computer. I am not sure, sorry.

  • @adamumustapha7868
    @adamumustapha7868 5 лет назад

    Extremely uselful video, thanks bunch for this

  • @princeabraham2419
    @princeabraham2419 2 года назад

    load coast is not working in my matlab. its saying its unknown.

  • @tsehayenegash8394
    @tsehayenegash8394 Год назад

    Thank you for your help. I have the data in the same extension but doesn't the figure the dimensio is not equal.How can I extract globally longitude and a specific latitude at a given globally longitude and latitude data. If you help me to extract my data I can write your contribution in my paper puplished. Thank you

  • @drtamiz
    @drtamiz 3 года назад

    Why when I print a variable I get a bunch of NaNs?

  • @paaowu5173
    @paaowu5173 3 года назад

    Hi what if I want o display the name of the oceans and the continents on my graph?

  • @giorgiosperandio8708
    @giorgiosperandio8708 4 года назад +1

    Good video. What about 3d arrays (sometimes Cordex data are reported as 3d arrays) with rotated lat lon? How can we easily read and extract these types of data?

  • @darthsquirrel4247
    @darthsquirrel4247 6 лет назад

    awesome! thank you very much for doing this helpful video

  • @MichaelGTadesse
    @MichaelGTadesse 6 лет назад

    Thank you so much for the illustration!

    • @chatupaul
      @chatupaul 6 лет назад

      Do u have the scripts ? Link is not working

  • @josevallesleon
    @josevallesleon 6 лет назад +1

    Very useful!! thank you so much!!

    • @MichaelGTadesse
      @MichaelGTadesse 6 лет назад

      Hey Jos, how u doin man
      Yeah I also find it very hepful, the video

  • @guilhermemartinsaragao5571
    @guilhermemartinsaragao5571 4 года назад

    Great vídeo. Very helpful !! Tks

  • @wanchingtan2621
    @wanchingtan2621 7 лет назад

    Hi Bernardo! I've just started using MATLAB to open NetCDF files and mine is different dataset(Sea Surface Height Altimeter). When I tried to create the figure using pcolor (X,Y,C) function I got the error below and I can't create my figure. Any suggestion?
    Error using pcolor (line 54)
    Color data input must be a matrix.
    I've tried the input pcolor(C) still the error is there. Can help?

    • @deepas3167
      @deepas3167 6 лет назад +1

      Have you solve this ?

  • @yorkshire_tea_innit8097
    @yorkshire_tea_innit8097 4 года назад

    If your data is 3-D use this to take slices out of it. slice = squeeze(var( : , : , "your desired slice e.g. 10"));

  • @gemmaives5839
    @gemmaives5839 7 лет назад +2

    Thanks so much for this!!

    • @bredo91
      @bredo91  7 лет назад

      Gemma Ives you're welcome!! :)

  • @emanuelvaldes1216
    @emanuelvaldes1216 6 лет назад

    Estimado Bernardo, Muchas gracias por este tutorial! Mi variable tiene 3 dimensiones (T2) y eso no me permite graficarla, qué debo hacer? Agradecería mucho tu ayuda!

  • @meteoboy
    @meteoboy 4 года назад

    It was a great video. Thanks.

  • @MuhammadHussain-wr7hv
    @MuhammadHussain-wr7hv 4 года назад

    Can you please help me in resolving the error during 'pcolor' command as it says "dimension of matrix must same",?

    • @efembilgic8683
      @efembilgic8683 4 года назад

      Probably, dimension of your data is reverse. You can transpoze of the data you want to plot. For example: transpose(temp)

  • @maicoldlc4844
    @maicoldlc4844 2 года назад

    Hola Bernardo, gracias por el vídeo, ayúdame por favor. A la hora de colocar el comando "load coast" me bota el siguiente error:
    Error using load
    Unable to read file 'coast'. No such file or directory.
    que puedo hacer en este caso?

  • @tradingdarija2981
    @tradingdarija2981 6 лет назад

    thanks man for this but im looking to extract and export data from netCDF data with matlab ...there is a solution for this ?

  • @emiletouzard9332
    @emiletouzard9332 6 лет назад

    Great video, very helpful

  • @jaypatel3233
    @jaypatel3233 4 года назад

    Thanks. very helpful.

  • @barrjohnm
    @barrjohnm 4 года назад

    thanks so much for the file, I can't get the map to load, and thoughts?

  • @nikhilshahare6241
    @nikhilshahare6241 2 года назад

    hello Bernardo! thanks for the useful video. I would like to ask you, why you have added 360 to the long values ? as we know that the basemap has endpoints longitudes as -180 and -180 (let's say where these two met) so you should have added 180 only to the long values. it would show the actual world map. Now here in your video, the left and right side of the world map got shifted, which will give wrong latitude, longitude, and temp values. please correct me if I am wrong.

    • @igorgylycheyev9294
      @igorgylycheyev9294 Год назад

      may i help? firstly, the coastline data is shifted but the temp is not because the coastline comes from different source, which is matlab. secondly, 360 is added because if we only add 180, the two half of the coastline map would be stacked on top of each other. The temp map has endpoints from 0 to 360 when the coastline from -180 to 180, to shift -180 to 180, you need to add 360.

  • @Ayman-sl4fc
    @Ayman-sl4fc 4 года назад

    How to get some specific coordinates from the global data..BTW your video was was very easy,thank you for sharing!

  • @Data-with-Mo
    @Data-with-Mo 2 года назад

    Thank you very helpful , can i make a correlation on the geographic map between two variables?

  • @adetayoeyelade7924
    @adetayoeyelade7924 5 лет назад

    very helpful video. can you help us with ordinary CDF file data from THEMIS satellite . all the data from it are stored in CDF format.

  • @ayuervinia1446
    @ayuervinia1446 7 лет назад

    Hi Bernardo, Thanks a lot. This tutorial is so helpful :) In matlab, can we display the data covering only the specific area (e.g. watershed)?

    • @bredo91
      @bredo91  7 лет назад

      Hi Ayu! is good to know that =)
      I think it would be possible. I would suggest to look to the function shaperead(filename)to read the watershed shapefile and then try to "crop" the gcm data. Actually I need to do the same in a problem that I'm solving. So as soon as I know the clear path to do it I might upload a video.

    • @tilayeworku5608
      @tilayeworku5608 2 года назад

      Thanks, Ayu, this is very important

  • @madangopal7778
    @madangopal7778 3 года назад

    Hi can you kindly update a video where we can plot data between particular lat long... say over india region

  • @tedwango9989
    @tedwango9989 3 года назад

    Thanks

  • @chatupaul
    @chatupaul 6 лет назад

    Hello Link is not working can anyone help

    • @bredo91
      @bredo91  6 лет назад

      Hi, try this one: createclimate.wordpress.com/codesandmodels/

  • @maxkotz7168
    @maxkotz7168 7 лет назад +1

    Hi Bernardo! I am just getting started using MatLab to handle NetCDF files and this is very useful. I'm trying with a slightly different data set (Sea Level Data) and keep getting a pcolor plot which shows up all black. Can you offer any advice as to why this may be the case?
    This is the data set!
    podaac.jpl.nasa.gov/dataset/SEA_SURFACE_HEIGHT_ALT_GRIDS_L4_2SATS_5DAY_6THDEG_V_JPL1609

    • @maxkotz7168
      @maxkotz7168 7 лет назад

      more specifically, the plot is not actually black, but the mymap.EdgeAlpha=0 command returns the error "Warning: Struct field assignment overwrites a value with class "double"", and the pixel edges are not removed. Any help?

    • @bredo91
      @bredo91  7 лет назад

      Hi Max, I promise to look at it as soon as I have a break from a current deadline that I'm working in. Hope you can solve this!

    • @maxkotz7168
      @maxkotz7168 7 лет назад

      i managed to work it out don't worry!

    • @wanchingtan2621
      @wanchingtan2621 7 лет назад +1

      Hi Max. I'm facing the same case like you. Did you get anything by inputing mymap=pcolor(x,y,z)? I got is Error using pcolor (line 54). Can help?

    • @salmahazim7987
      @salmahazim7987 7 лет назад

      You have found a solution for this problème??