In [1]:
!conda install -y netcdf4
In [14]:
from netCDF4 import Dataset, num2date, date2num
from numpy import *
import matplotlib.pyplot as plt
%matplotlib inline
In [3]:
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
In [4]:
x=linspace(0,1,100)
f=2
In [5]:
plt.plot(x, sin(2*pi*x*f))
Out[5]:
In [6]:
def pltsin(f):
plt.plot(x,sin(2*pi*x*f))
In [7]:
pltsin(5)
In [8]:
interact(pltsin, f=(1,10,0.1))
Out[8]:
In [9]:
def pltsin(f,a):
plt.plot(x,a * sin(2*pi*x*f))
In [10]:
interact(pltsin, f=(1, 10, 0.1), a=(1, 10, 0.1))
Out[10]:
In [16]:
f=Dataset('ncep-data/air.sig995.2013.nc')
In [17]:
air=f.variables['air'] #get variable
In [25]:
plt.imshow(air[364,:,:]) #display first timestep
Out[25]:
In [19]:
def sh(time):
plt.imshow(air[time,:,:])
In [24]:
#now make it interactive
interact(sh, time=(0,364,1))
In [36]:
# Browse variable
def sh(var='air', time=0):
f=Dataset ('ncep-data/'+var+'.sig995.2013.nc')
vv=f.variables[var]
plt.imshow(vv[time,:,:])
In [37]:
# Give a list of varibles
variabs= ['air','uwnd','vwnd','rhum']
In [38]:
# Now interact with it
interact(sh, time=(0,355,1), var=variabs)
Out[38]:
In [49]:
# Browse variable
def sh(var='air', year="2013", time=0):
f=Dataset ('ncep-data/'+var+'.sig995.'+year+'.nc')
vv=f.variables[var]
plt.imshow(vv[time,:,:])
In [50]:
# Create a list of years
years= [str(x) for x in range (2013,2016)]
years = ['2013', '2014', '2015']
In [51]:
# Give a list of varibles
variabs= ['air','uwnd','vwnd','rhum']
In [53]:
# Now interact with it
interact(sh, time=(0,355,1), var=variabs, year=years)
In [ ]: