
HOW TO READ CDF FILES ON PC UPDATE
Title: NOAA GFDL GFDL-ESM4 model output prepared for CMIP6 update of RCP8.5 based on SSP5 Or to look at all of the variables in your netcfd4 file, you can just print 'file2read': print(file2read)Īnd the output will include something like this (look at the end specifically): source_id: GFDL-ESM4 Which will give an output like this: dict_keys() To look at all of the variable keys: print(())
HOW TO READ CDF FILES ON PC FOR MAC
I am using Windows, so file directory will be different than for Mac or Linux. Where cwd is my current working directory for getting the file path for the. Var1 = file2read.variables # access a variable in the file If you want to check the various dimensions of your data so you know what you can plot simply do print(nc.shape)įor netCDF4 files (with python 3), use: import netCDF4įile2read = netCDF4.Dataset(cwd+'\filename.nc','r') Iteration of the vertical slize with y = 0, one of the vertical """Īccording to what I have said before this will plot the second

""" in this dataset each component will be

Nc = netCDF4.Dataset(fp) # reading the nc file and creating Dataset To answer your question I commented the code: from matplotlib import pyplot as plt # import librariesįp='uwstemp.nc' # your file name with the eventual path Then a quick way to plot say layer z at time t is: plt.contourf(data) Temp = file2read.variables # var can be 'Theta', 'S', 'V', 'U' etc. The easiest way to read the data is: file2read = netcdf.NetCDFFile(path+'state.nc','r')

Say you have your state.nc output.įirst of all make sure you import all you need: from scipy.io import netcdf
