Exemplo n.º 1
0
def main_program(shuffi, isCrossValidation):
	list_all_test = shuffi[0]
	list_all_station = shuffi[1]
	global D
	#time.sleep(100)
	print len(list_all_station)
	trend_curve = generateGlobalMatrix(date_from, date_to, list_all_station)
	D = generateDistanceMatrix(list_all_station)
	area_id = 0
	genModelForArea(area_id, list_all_station, list_data, G, D)
	reGenerateSemiMatrix(list_all_station)
	print 'GLOBAL DATA'
	print global_data
	derivation = np.zeros([row,col])
	result = np.zeros([row,col])
	for i in xrange(0,row):
		#print i
		for j in xrange(0, col):
			#print i, j
			point = (minLat + i*shift,minLon + j*shift)
			f.write(str(i)+' '+ str(j)+ ':'+ str(point)  +'\n')
			#if isInVietnam(point):
			result[i][j], derivation[i][j] = krigeOne(point, neighbor, list_all_station, list_data, G, D)
			trendValue = getTrendValue(trend_curve, point[0], point[1])
			#print trendValue
			result[i][j] = result[i][j] + trendValue
	#exportGeotiff('filename', raster, row, col, shift, minLon, minLat)
	if isCrossValidation == False:	
		exportGeotiff('t08_GEOTIFF_simple_kriging_one_model', result, row, col, shift, minLon, minLat )
	saveAsPng(result)
	saveAsPng(derivation)
	if isCrossValidation:	
		return calculateSE(result, list_all_test, minLat, minLon, shift, date_to)
def main_program(shuffi, isCrossValidation):
    f_se = open("Moiseture_f_se.txt", "a")
    f_se.write("Moiseture_se statistic\n")
    f_da = open("Moiseture_f_da.txt", "a")
    f_da.write("Moiseture_da statistic\n")

    list_all_test = shuffi[0]
    list_all_station = shuffi[1]
    global D
    # time.sleep(100)
    print len(list_all_station)
    trend_curve = generateGlobalMatrix(date_from, date_to, list_all_station)
    D = generateDistanceMatrix(list_all_station)
    area_id = 0
    genModelForArea(area_id, list_all_station, list_data, G, D)
    reGenerateSemiMatrix(list_all_station)
    print "GLOBAL DATA"
    print global_data
    derivation = np.zeros([row, col])
    result = np.zeros([row, col])
    result_kri_backup = np.zeros([row, col])
    for i in xrange(0, row):
        # print i
        for j in xrange(0, col):
            # print i, j
            point = (minLat + i * shift, minLon + j * shift)
            f.write(str(i) + " " + str(j) + ":" + str(point) + "\n")
            result[i][j], derivation[i][j] = krigeOne(point, neighbor, list_all_station, list_data, G, D)
            trendValue = getTrendValue(trend_curve, point[0], point[1])
            # print trendValue
            result[i][j] = result[i][j] + trendValue
            result_kri_backup[i][j] = result[i][j]
            # DATA ASSIMILATION: assimilate
            # if sate_lite_value[i][j] != 0:
            # 	result[i][j] = assimilate(result[i][j], derivation[i][j], sate_lite_value[i][j], sate_lite_deri[i][j], f_da)
            # Assimilate with Utility.assimilate
    if isCrossValidation == False:
        exportGeotiff("Moiseture__GEOTIFF_universal_kriging", result, row, col, shift, minLon, minLat)
        exportGeotiff("Moiseture__GEOTIFF_universal_kriging_derivation", derivation, row, col, shift, minLon, minLat)
    saveAsPng(result)
    saveAsPng(derivation)
    f_da.close()
    f_se.close()
    if isCrossValidation:
        return calculateSE(
            result, result_kri_backup, list_all_test, minLat, minLon, shift, date_to, f, sate_lite_value, f_se
        )
Exemplo n.º 3
0
#export_temp_geotiff
import numpy as np
from get_data import getAvgAllStationAMonth
from Utility import exportGeotiff, resampling, interpolate
#SETTING
minLat = 5 #oy
maxLat = 25
minLon = 100 # ox
maxLon = 110
shift = 0.1 # grid
row = int((maxLat-minLat)/shift)
col = int((maxLon-minLon)/shift)

list = getAvgAllStationAMonth(3)
list_all = zip(*list)
list_temp = list_all[3]
avg= sum(list_temp)/len(list_temp)
#for item in list:
#	print item
grid = interpolate(list, row, col, shift, minLon, minLat, avg)
exportGeotiff('geo_temp_avg_all_one_month_Mar', grid, row, col, shift, minLon, minLat)
#exportGeotiff('geo_2_9years_Mar', resampling(geo_2_T), row, col, shift, minLon, minLat)
Exemplo n.º 4
0
col = int((maxLon-minLon)/shift)
xi = np.linspace(minLon,maxLon,shift)
yi = np.linspace(minLat,maxLat,shift)
derivation = np.zeros([row,col])
result = np.zeros([row,col])
for i in xrange(0,row):
	print i
	for j in xrange(0, col):
		#print i, j
		point = (minLat + i*shift,minLon + j*shift)
		f.write(str(i)+' '+ str(j)+ ':'+ str(point)  +'\n')
		#if isInVietnam(point):
		result[i][j], derivation[i][j] = krigeOne(point, neighbor, list_all_station, list_data, G, D)
f.close()
#exportGeotiff('filename', raster, row, col, shift, minLon, minLat)
exportGeotiff('t2_GEOTIFF_krige_AREA_MODEL', result, row, col, shift, minLon, minLat )
saveAsPng(result)
saveAsPng(derivation)


#for point in points:
#	value = 0
#	if isInVietnam(point):
#		value = krigeOne(point, neighbor, list_all_station, list_data, G, D)
	
	#time.sleep(5)

#area_id = 1

#list_station = getAllStaByAreaId(area_id)
#G = generateGlobalMatrix(date_from, date_to, list_station)