feaT(draw): alpha value for biomes

This commit is contained in:
Mahdi Dibaiee 2019-05-18 22:06:09 +04:30
parent d965474974
commit d91c04e2f5
2 changed files with 6 additions and 12 deletions

View File

@ -8,7 +8,7 @@ from constants import BIOMES
import pandas as pd
import cartopy.crs as ccrs
def draw(df, earth=True, width=23.22, height=13, only_draw=False, path=None):
def draw(df, earth=True, width=23.22, height=13, only_draw=False, path=None, alpha=1):
logger.debug('draw(df, %s)', path)
biomes = {}
biome_numbers = df['biome_num'].unique()
@ -36,6 +36,7 @@ def draw(df, earth=True, width=23.22, height=13, only_draw=False, path=None):
patches = [Circle(p, radius=0.4) for p in biomes[n]]
collection = PatchCollection(patches, color=color)
collection.set_alpha(alpha)
legend_handles.append(Patch(color=color, label=BIOMES[n]['name']))
ax.add_collection(collection)

View File

@ -51,7 +51,7 @@ parameters = {
'max': 0
},
'ground_noise': {
'default': 1.1e4,
'default': 6e3,
'type': 'int',
'min': 0,
'max': 1e5,
@ -299,8 +299,6 @@ def generate_map(biomes=False, **kwargs):
position = (position[0] + np.random.randint(p['continent_spacing'] * width * 0.8, p['continent_spacing'] * width * 1.2),
position[1] + ym * np.random.randint(p['continent_spacing'] * height * 0.8, p['continent_spacing'] * height * 1.2))
print(position)
ym = ym * -1
random_size = ground_size / continents
@ -319,9 +317,8 @@ def generate_map(biomes=False, **kwargs):
ground = ndimage.gaussian_filter(ground, sigma=4)
ground = ndimage.generic_filter(ground, constant_filter, size=1)
print(np.min(ground), np.max(ground), p['max_elevation'])
print(np.unique(ground))
print(np.count_nonzero(ground) / ground.size)
print('water proportion', np.count_nonzero(ground) / ground.size)
plt.gca().invert_yaxis()
plt.imshow(ground.T, cmap=greys, norm=norm)
@ -436,7 +433,6 @@ def predict_end_to_end(input_df, boundary, checkpoint_temp='checkpoints/temp.h5'
inputs = inputs.to_numpy()
inputs = normalize_ndarray(inputs, inputs_copy)
print(inputs)
out_columns = ['temp_{}_{}'.format(season, year) for season in SEASONS]
out = Temp.predict(inputs)
temp_output = pd.DataFrame(data=denormalize(out, df[out_columns].to_numpy()), columns=out_columns)
@ -449,7 +445,6 @@ def predict_end_to_end(input_df, boundary, checkpoint_temp='checkpoints/temp.h5'
inputs = inputs.to_numpy()
inputs = normalize_ndarray(inputs, inputs_copy)
print(inputs)
out_columns = ['precip_{}_{}'.format(season, year) for season in SEASONS]
out = Precip.predict(inputs)
@ -493,15 +488,13 @@ def predict_end_to_end(input_df, boundary, checkpoint_temp='checkpoints/temp.h5'
new_data = new_data.append(f)
#print(new_data)
draw(new_data, earth=False, only_draw=True, width=p['width'], height=p['height'])
draw(new_data, earth=False, only_draw=True, width=p['width'], height=p['height'], alpha=0.7)
# TODO: reduce opacity of biome layer
if __name__ == "__main__":
# p['width'] = 50
# p['height'] = 50
p['water_proportion'] = 0.9
p['continents'] = 3
p['seed'] = 1
p['seed'] = 3
generate_map(True)
# print(normalize_ndarray(np.array([[ 5.59359803,0.99879546,-90., 45.24], [ 5.54976747, 0.99879546,-86.4, 45.24 ]])))
plt.show()