Read .nc (netcdf) files using python
<p>I am trying to learn how to read .nc (netcdf) files using Python in the most easiest/fastest way. I heard that it can be done with 3 lines of code but I really don't know how.</p>

<p>I am running the MITgcm numerical model. I'm trying to get an easy way to visualize the output data in the same way as programs like NCview does but with Python, so I can customise the parameters to read and everything.</p>

<p>I found this:</p>

<pre><code>from matplotlib import pyplot as plt
import pandas as pd
import netCDF4
fp='uwstemp.nc'
nc = netCDF4.Dataset(fp)
plt.imshow(nc['Temp'][1,:,0,:])
plt.show()
</code></pre>

<p>It worked roughly like I want it, but I would like to understand word by word what is it doing. I guess 'Temp' is one of my variables, but I don't know how to figure out what all my variables are.</p>

<p>Specially, I don't understand <code>plt.imshow(nc['Temp'][1,:,0,:])</code> thhat [1,:,0,:] I tried to change it and does not compile; but I don't understand what is it doing and why this numbers.</p>