EAPS 42200 fall 2018

skeleton python code for HW #1


import numpy as np import matplotlib.pyplot as plt%matplotlib inline
# set up range of x-axis and y-axis valuesx = np.arange(-100000., 100000.1, 10000.)y = np.arange(-100000., 100000.1, 10000.)# create a grid of x,y values using rangesxx,yy = np.meshgrid(x, y)
# initialize arrays for T, u, vT=np.zeros_like(xx)u=np.zeros_like(xx)v=np.zeros_like(xx)# demonstrate numpyprint(np.pi)print((np.pi)**2.0)print(np.cos(np.pi/2.0))print(np.sin(np.pi/2.0))

# create wind field using functionsu=xx/(2000.)v=yy/(2000.)# could set this up like in notes u=u0+(D1+div)*x/2.+(D2-zeta)*y/2.
# plot streamlines convert axes to kmplt.figure(figsize=(12,9))plt.streamplot(x/1000.,y/1000.,u,v)plt.xlabel('x km')plt.ylabel('y km')plt.title('streamlines u=x/2 v=y/2')
# plot wind vectorsplt.figure(figsize=(12,9))plt.quiver(x/1000.,y/1000.,u,v)plt.xlabel('x km')plt.ylabel('y km')plt.title('vectors u=x/2 v=y/2')
# convert m/s to ktsu_kt=u*1.94v_kt=v*1.94
# plot wind barbs which are usually in ktsplt.figure(figsize=(12,9))plt.barbs(x/1000.,y/1000.,u_kt,v_kt)plt.xlabel('x km')plt.ylabel('y km')plt.title('barbs u=x/2 v=y/2')
# set up T field using functionT=273.15+xx/10000.-yy/10000.print(np.max(T))print(np.min(T))
# plot and label isothermsintervals=np.arange(250.,295.,5.)plt.figure(figsize=(12,9))CS=plt.contour(x/1000.,y/1000.,T,intervals)plt.clabel(CS)plt.xlabel('x km')plt.ylabel('y km')plt.title('T = 273.15+x/10-y/10')