![]() ![]() ![]() To look at all of the variable keys: print(()) 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
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |