# import libraries
import matplotlib.pyplot as plt
from netCDF4 import Dataset
import micom2reg as mr
    
# read sample data (3d temperature) 
nc = Dataset('datasample_tnx1v4.nc')
T_tnx1v4 = nc.variables['templvl'][:,:] # clip last row
depth = nc.variables['depth'][:]
nc.close()    

# interpolate data to 1x1 deg lonlat grid
T, lon, lat = mr.micom2reg(T_tnx1v4,'gridsample_tnx1v4.nc',1)

# plot map of surface temperature
plt.figure()
plt.pcolormesh(lon,lat,T[0,0,:,:]) # horizontal plot of SST 

# plot meridional temperature section through Atlantic
plt.figure()
plt.pcolormesh(lat[:,0],-depth,T[0,:,:,330]) 

plt.show()
