Ejemplo n.º 1
0
def generateGlobalMatrix( date_from, date_to, list_all_station):
	global trend_curve
	list_station = list_all_station
	#print list_station
	meteo_size = len(list_station)
	list_mean = []
	for i in xrange(0,meteo_size):
		#print list_station[i][0]
		item = getTempOfAAtationFromTo( list_station[i][3],date_from, date_to)
		list_all = zip(*item)
		#3 for temp, 4 for humid, 5 for rain
		list_temp = list_all[3]
		#print list_temp
		list_data.append(list_temp)
		mean_item = (list_all[1][0],list_all[2][0], sum(list_all[3])/len(list_all[3]))
		print mean_item
		list_mean.append(mean_item)
	f.write('MEAN: ' + str(list_mean) + '\n')
	trend_curve = curveFitting(list_mean)
	print trend_curve
	#plotSurface(trend_curve, list_mean)
	#print len(list_mean)
	#print list_data[0]
	#G = np.zeros([meteo_size, meteo_size])
	for x in xrange(0,meteo_size):#x 0->97 is Meteo_id 1->98
		for y in xrange(0,meteo_size):#0->97 is Meteo_id 1->98
			#gen covariance for [x][y]
			a = list_data[x]
			b = list_data[y]
			#cov =np.cov(a,b)[0][1]
			semi = semivariance( a, b)
			cov = covariance(a,b)
			#print 'a: ', a
			#print 'b: ',b
			#print 'cov a b = ', str(cov)
			#print covariance(a,b)
			G[x][y]= semi
			G_COV[x][y] = cov
	'''
	f.write('G_SEMI ----------------------------------------- \n')
	for item in G:
		f.write(str(item) + '\n')
	f.write('G_COV  ----------------------------------------- \n')
	for item in G_COV:
		f.write(str(item) + '\n')
	'''
	#print G[0:5,0:5]
	return trend_curve
Ejemplo n.º 2
0
import numpy as np
import matplotlib.pyplot as plt
from get_data import getTempOfAAtationFromTo
import os.path

id1 = 15
id2 = 17
list_value = []
list_time =[]

for x in xrange(2004,2015):
	print x
	date_from = str(x) + '-01-01'
	date_to = str(x) + '-12-30'
	list_1 = getTempOfAAtationFromTo(id1, date_from, date_to)
	list_2 = getTempOfAAtationFromTo(id2, date_from, date_to)
	size1= len(list_1)
	size2= len(list_2)
	print size1,' ', size2
	if size1 == 0:
		continue
	list_1_all = zip(*list_1)
	list_1_temp = list_1_all[3]
	list_1_humid = list_1_all[4]
	list_1_rain = list_1_all[5]
	list_2_all = zip(*list_2)
	list_2_temp = list_2_all[3]
	list_2_humid = list_2_all[4]
	list_2_rain = list_2_all[5]
	#print list_1_temp
	#print list_1_humid
Ejemplo n.º 3
0
#date_to = '2015-01-01'  # for all pairs
date_from= '2011-01-01'
date_to = '2011-01-20'

x1 = np.linspace(0.0, 5.0)
x2 = np.linspace(0.0, 2.0)
y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
y2 = np.cos(2 * np.pi * x2)
query_date = '2011-01-02'
list = getObservationList(query_date)
size = len(list)# 98 Tram
item0 = list[0]
list_index = []
list_station_all = [] #98 tram
for x in xrange(1,size+1):
	list_station_all.append(getTempOfAAtationFromTo(str(x), date_from, date_to))
	#list_index.append(x)
	#list_h.append(haversine(item0[2], item0[1], list[x][2], list[x][1]))
list_corr_tuple = []
list_value = []
list_h = []
def calculateOneStation(id):
	item0 = list[id]
	station_0 = list_station_all[id]
	for x in xrange(1,size):
		print x
		item = list_station_all[x]
		leng = len(item)
		#print leng
		#cov =np.cov(station_0,item)[0][1]