import matplotlib.ticker as ticker
import pylab

import calcprob
reload(calcprob)



path = 'markov\\'
files = os.listdir(path)
mon_labels = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec']
array = np.loadtxt('markov\\83163.0_wetdry.dat',dtype='int',delimiter=',')
array.resize(np.shape(array)[0]/3,3) 

#--calc trans prob for entire series
monthly_trans = calcprob.trans(array)
print np.shape(array)



#--monte carlo control parameters
interval = 3650 #days
samp_range = [0,np.shape(array)[0]]
#numdraws = np.shape(array)[0]/interval
numdraws = 11
print numdraws

trans_draws = np.zeros((numdraws,13,2,2),dtype='float')
start_end = np.zeros((numdraws,2),dtype='int')
for draw in range(0,numdraws):
    this_start = draw*interval
示例#2
0
                     t_total[0,0] += 1
    
    row_total = np.sum(t_total,axis=1)        
    wet_prob = t_total[0,:]/row_total[0]
    dry_prob = t_total[1,:]/row_total[1]
    #print month
    #print wet_prob
    #print dry_prob
    monthly_trans[month-1,:,:] = [wet_prob,dry_prob]
    #print monthly_trans[month-1,1]
    cum_t_total += t_total
    cum_wd_total += wd_total
    t_total = np.zeros((2,2))
    wd_total = np.zeros((2)) 
    
func_monthly = calcprob.trans(array)
print func_monthly
#print '\n'
row_total =  np.sum(cum_t_total,axis=1)    
wet_prob = cum_t_total[0,:]/row_total[0]
dry_prob = cum_t_total[1,:]/row_total[1]
#print wet_prob
#print dry_prob
monthly_trans[12,:,:] = [wet_prob,dry_prob]
fig = pylab.figure()
ax = pylab.subplot(221)
ax.plot(np.arange(1,13),monthly_trans[:-1,0,0],'b+')
ax.plot(np.arange(1,13),monthly_trans[:-1,0,0],'b-')
ax.plot(np.arange(1,13),func_monthly[:-1,0,0],'r+')
ax.plot(np.arange(1,13),func_monthly[:-1,0,0],'r-')
#ax.bar(np.arange(0.25,12.25),monthly_trans[:-1,0,0],width=0.5,fc='b',alpha=0.5)
import pylab

import calcprob
reload(calcprob)

path = 'markov\\'
files = os.listdir(path)
mon_labels = [
    'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct',
    'nov', 'dec'
]
array = np.loadtxt('markov\\83163.0_wetdry.dat', dtype='int', delimiter=',')
array.resize(np.shape(array)[0] / 3, 3)

#--calc trans prob for entire series
monthly_trans = calcprob.trans(array)
print np.shape(array)

#--monte carlo control parameters
interval = 3650  #days
samp_range = [0, np.shape(array)[0]]
#numdraws = np.shape(array)[0]/interval
numdraws = 11
print numdraws

trans_draws = np.zeros((numdraws, 13, 2, 2), dtype='float')
start_end = np.zeros((numdraws, 2), dtype='int')
for draw in range(0, numdraws):
    this_start = draw * interval
    this_end = this_start + interval
    #print start,samp_range
示例#4
0
                    t_total[0, 0] += 1

    row_total = np.sum(t_total, axis=1)
    wet_prob = t_total[0, :] / row_total[0]
    dry_prob = t_total[1, :] / row_total[1]
    #print month
    #print wet_prob
    #print dry_prob
    monthly_trans[month - 1, :, :] = [wet_prob, dry_prob]
    #print monthly_trans[month-1,1]
    cum_t_total += t_total
    cum_wd_total += wd_total
    t_total = np.zeros((2, 2))
    wd_total = np.zeros((2))

func_monthly = calcprob.trans(array)
print func_monthly
#print '\n'
row_total = np.sum(cum_t_total, axis=1)
wet_prob = cum_t_total[0, :] / row_total[0]
dry_prob = cum_t_total[1, :] / row_total[1]
#print wet_prob
#print dry_prob
monthly_trans[12, :, :] = [wet_prob, dry_prob]
fig = pylab.figure()
ax = pylab.subplot(221)
ax.plot(np.arange(1, 13), monthly_trans[:-1, 0, 0], 'b+')
ax.plot(np.arange(1, 13), monthly_trans[:-1, 0, 0], 'b-')
ax.plot(np.arange(1, 13), func_monthly[:-1, 0, 0], 'r+')
ax.plot(np.arange(1, 13), func_monthly[:-1, 0, 0], 'r-')
#ax.bar(np.arange(0.25,12.25),monthly_trans[:-1,0,0],width=0.5,fc='b',alpha=0.5)
示例#5
0
import calcprob
reload(calcprob)

pdo = np.loadtxt('pdo.dat',usecols=[1,2,3,4,5,6,7,8,9,10,11])
pdo_yr = np.mean(pdo,axis=1)
print np.shape(pdo),np.shape(pdo_yr)

path = 'markov\\'
files = os.listdir(path)
mon_labels = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec']
array = np.loadtxt('83163.0_wetdry.dat',dtype='int',delimiter=',')
array.resize(np.shape(array)[0]/4,4) 

#--calc trans prob for entire series
monthly_trans = calcprob.trans(array[:,:-1])
print np.shape(array)



#--monte carlo control parameters
interval = 3650 #days
samp_range = [0,np.shape(array)[0]]
#numdraws = np.shape(array)[0]/interval
numdraws = 11
print numdraws

intervals = np.array([1910,1920,1930,1940,1950,1960,1970,1980,1990,2000,2010],dtype='int')

trans_draws = np.zeros((numdraws,13,2,2),dtype='float')
start_end = np.zeros((numdraws,2),dtype='int')