import netCDF4
import matplotlib.pyplot as plt
import numpy as np
import folium
from folium import plugins
year='2017'
month='03'
day='19'
hour='12z'
url='http://nomads.ncep.noaa.gov:9090/dods/nam/nam'+year+month+day+'/nam1hr_'+hour
url
file = netCDF4.Dataset(url)
lats = file.variables['lat'][:]
lons = file.variables['lon'][:]
temps = file.variables['tmpsfc'][2,:,:]
plt.imshow(temps)
plt.colorbar()
plt.show()
normed_temps = (temps - temps.min()) / (temps.max() - temps.min())
cm = plt.cm.get_cmap('rainbow')
colored_data = cm(normed_temps)
m = folium.Map()
map_image = plugins.ImageOverlay(np.flipud(colored_data),
[[lats.min(), lons.min()], [lats.max(), lons.max()]],
opacity=0.5,
mercator_project=True)
map_image.add_to(m)
m