In [48]:
import netCDF4
import matplotlib.pyplot as plt
import numpy as np
import folium
from folium import plugins
In [3]:
year='2017'
month='03'
day='19'
hour='12z'
url='http://nomads.ncep.noaa.gov:9090/dods/nam/nam'+year+month+day+'/nam1hr_'+hour
url
Out[3]:
'http://nomads.ncep.noaa.gov:9090/dods/nam/nam20170319/nam1hr_12z'
In [4]:
file = netCDF4.Dataset(url)
In [14]:
lats = file.variables['lat'][:]
lons = file.variables['lon'][:]
In [51]:
temps = file.variables['tmpsfc'][2,:,:]
In [52]:
plt.imshow(temps)
plt.colorbar()
plt.show()
In [50]:
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
Out[50]:
In [ ]: