In [1]:
%matplotlib inline

In [3]:
from mpl_toolkits.basemap import Basemap
import numpy as np
import scipy.stats as ss
import matplotlib.pyplot as plt

In [30]:
meanvals = np.load('C:/users/tman1_000/Downloads/96z_mslp_meanPa.npy')
sprdvals = np.load('C:/users/tman1_000/Downloads/96z_mslp_sprd.npy')
meanvals=np.delete(meanvals,[3300,3301],axis=0)
sprdvals=np.delete(sprdvals,[3300,3301],axis=0)

In [6]:
lats = np.linspace(23,52,30)
lons = np.linspace(233,295,63)

In [8]:
m = Basemap(llcrnrlon=265,llcrnrlat=lats.min(),urcrnrlon=lons.max(),urcrnrlat=lats.max(),projection='cyl',resolution='c')

In [9]:
x,y = m(*np.meshgrid(lons,lats))  
z0 = m.contourf(x,y,np.zeros((30,63)))
cbar = m.colorbar(z0,ticks=np.linspace(0,10,num=11),location='bottom',pad='5%')
m.drawcountries()
m.drawcoastlines()
m.drawstates()


Out[9]:
<matplotlib.collections.LineCollection at 0x8c02f60>

In [18]:
q = np.zeros((30,63))
q[16:25,47:60] = 10

In [19]:
m = Basemap(llcrnrlon=265,llcrnrlat=lats.min(),urcrnrlon=lons.max(),urcrnrlat=lats.max(),projection='cyl',resolution='c')

x,y = m(*np.meshgrid(lons,lats))  
z0 = m.contourf(x,y,q)
cbar = m.colorbar(z0,ticks=np.linspace(0,10,num=11),location='bottom',pad='5%')
m.drawcountries()
m.drawcoastlines()
m.drawstates()


Out[19]:
<matplotlib.collections.LineCollection at 0xdf49dd8>

In [31]:
linx = sprdvals[:,16:25,47:60]
liny = meanvals[:,16:25,47:60]

In [32]:
flinx=linx.flatten()
fliny=liny.flatten()

In [33]:
slope, intercept, r_value, p_value, std_err = ss.linregress(flinx,fliny)

In [35]:
plt.figure(figsize=(20,10))
plt.scatter(flinx,fliny)


Out[35]:
<matplotlib.collections.PathCollection at 0xe428d68>

In [39]:
plt.figure(figsize=(20,10))
plt.scatter(flinx,fliny)
plt.plot(flinx, slope*flinx + intercept, '-', color='g',linewidth='3')


Out[39]:
[<matplotlib.lines.Line2D at 0xede9a20>]

In [45]:
flinylow=fliny[fliny<=100000]
flinxlow=flinx[fliny<=100000]

In [47]:
slope, intercept, r_value, p_value, std_err = ss.linregress(flinxlow,flinylow)
plt.figure(figsize=(20,10))
plt.scatter(flinxlow,flinylow)
plt.plot(flinxlow, slope*flinxlow + intercept, '-', color='g',linewidth='3')


Out[47]:
[<matplotlib.lines.Line2D at 0x129c2cf8>]

In [51]:
flinxlog=np.log(flinx)
flinylog=np.log(fliny)
slope, intercept, r_value, p_value, std_err = ss.linregress(flinxlog,flinylog)

plt.figure(figsize=(20,10))
plt.scatter(flinxlog,flinylog)
plt.plot(flinxlog, slope*flinxlog + intercept, '-', color='g',linewidth='3')


Out[51]:
[<matplotlib.lines.Line2D at 0x16014588>]

In [54]:
np.ones((1,2))


Out[54]:
array([[ 1.,  1.]])

In [ ]: