Exemplo n.º 1
0
start_index = field.reversemap(time=startdate)[field.time_dim].start
end_index = field.reversemap(time=enddate)[field.time_dim].start
slices[field.time_dim] = slice(start_index, end_index + 1)
predictand_data = field.variables[0][slices]
print "predictand_data.shape = ", predictand_data.shape

locations = predictands["sources"][predictands["sources"].keys()[0]]["fields"]["tasmax"].features()
# print locations

# for location in locations['features']:
# 	print location

locations = locations["features"][20:22]

pca = PCA_sklearn()
pca.fit(predictors, locations, startdate=startdate, enddate=enddate)
# pca.save('pca.nc')
# pca.load('pca.nc')
reduced_predictors = pca.transform(predictors, startdate=startdate, enddate=enddate)

vmin = 0
vmax = 50
mappable = ScalarMappable(cmap="Blues")
mappable.set_array(np.arange(vmin, vmax, 0.1))
mappable.set_clim((vmin, vmax))

id = 20
for pred in reduced_predictors:

    tree = BinaryTree(pred, maxdepth=10)