diff --git a/biomes/details.py b/biomes/details.py new file mode 100644 index 0000000..83619db --- /dev/null +++ b/biomes/details.py @@ -0,0 +1,11 @@ +import pandas as pd +from utils import normalize_ndarray + +df = pd.read_pickle('data.p') + +print('Columns', df.columns); +print(df[df.columns[0:8]]) + +columns = ['longitude', 'latitude', 'biome_num', 'elevation', 'distance_to_water', 'temp_winter_1900', 'precip_winter_1900', 'temp_spring_1900', 'precip_spring_1900'] +normalized = normalize_ndarray(df[columns].to_numpy()) +print(pd.DataFrame(columns=columns, data=normalized)) diff --git a/biomes/map_generator.py b/biomes/map_generator.py index d0d89b1..572220f 100644 --- a/biomes/map_generator.py +++ b/biomes/map_generator.py @@ -39,10 +39,10 @@ parameters = { 'step': 0.01 }, 'max_elevation': { - 'default': 1e4, + 'default': 10000, 'type': 'int', 'min': 0, - 'max': 1e4, + 'max': 10000, }, 'min_elevation': { 'default': -400, @@ -51,10 +51,10 @@ parameters = { 'max': 0 }, 'ground_noise': { - 'default': 6e3, + 'default': 6000, 'type': 'int', 'min': 0, - 'max': 1e5, + 'max': 10000, }, 'water_proportion': { 'default': 0.3, @@ -315,7 +315,7 @@ def generate_map(biomes=False, **kwargs): greys = cm.get_cmap('Greys') greys.set_under(color=SEA_COLOR) - # ground = ndimage.gaussian_filter(ground, sigma=4) + ground = ndimage.gaussian_filter(ground, sigma=1) ground = ndimage.generic_filter(ground, constant_filter, size=1) print(np.min(ground), np.max(ground), p['max_elevation']) @@ -325,13 +325,13 @@ def generate_map(biomes=False, **kwargs): plt.imshow(ground.T, cmap=greys, norm=norm) plt.gca().invert_yaxis() + if biomes: + generate_biomes(ground) + figfile = BytesIO() plt.savefig(figfile, format='png') figfile.seek(0) - if biomes: - generate_biomes(ground) - return figfile diff --git a/biomes/predict.py b/biomes/predict.py index 3446439..ff18745 100644 --- a/biomes/predict.py +++ b/biomes/predict.py @@ -138,7 +138,7 @@ def predicted_precips_cmd(checkpoint='checkpoints/precip.h5', year=2000): Precip.restore(checkpoint) predicted_precips(Precip, year=year) -def predict_end_to_end(Temp, Precip, Biomes, df=pd.read_pickle('data.p'), year=2000): +def predict_end_to_end(Temp, Precip, Biomes, df=pd.read_pickle('data.p'), year=2000, path=None): columns = INPUTS inputs = df[INPUTS] @@ -207,9 +207,9 @@ def predict_end_to_end(Temp, Precip, Biomes, df=pd.read_pickle('data.p'), year=2 new_data = new_data.append(f) print(new_data) - draw(new_data) + draw(new_data, path=path) -def predict_end_to_end_cmd(checkpoint_temp='checkpoints/temp.h5', checkpoint_precip='checkpoints/precip.h5', checkpoint_biomes='checkpoints/b.h5', year=2000, **kwargs): +def predict_end_to_end_cmd(checkpoint_temp='checkpoints/temp.h5', checkpoint_precip='checkpoints/precip.h5', checkpoint_biomes='checkpoints/b.h5', year=2000, path=None, **kwargs): batch_size = A_params['batch_size']['grid_search'][0] layers = A_params['layers']['grid_search'][0] optimizer = A_params['optimizer']['grid_search'][0](A_params['lr']['grid_search'][0]) @@ -242,7 +242,7 @@ def predict_end_to_end_cmd(checkpoint_temp='checkpoints/temp.h5', checkpoint_pre Biomes.prepare_for_use() Biomes.restore(checkpoint_biomes) - predict_end_to_end(Temp=Temp, Precip=Precip, Biomes=Biomes, year=year, **kwargs) + predict_end_to_end(Temp=Temp, Precip=Precip, Biomes=Biomes, year=year, path=path, **kwargs) if __name__ == "__main__": diff --git a/biomes/static/script.js b/biomes/static/script.js index 18b3ed0..660bf4c 100644 --- a/biomes/static/script.js +++ b/biomes/static/script.js @@ -12,7 +12,7 @@ function generate() { const queryString = new URLSearchParams(formData).toString() map.src = '/map?' + queryString; map.classList.add('d-none'); - map.width = formData.get('width'); + //map.width = formData.get('width'); } mapSettings.addEventListener('submit', (e) => { diff --git a/biomes/templates/index.html b/biomes/templates/index.html index f13345f..42f6899 100644 --- a/biomes/templates/index.html +++ b/biomes/templates/index.html @@ -11,7 +11,7 @@
- +
Loading... diff --git a/biomes/train.py b/biomes/train.py index 4f9b43d..ac3d1a7 100644 --- a/biomes/train.py +++ b/biomes/train.py @@ -10,7 +10,7 @@ from model import Model B_params = { 'batch_size': tune.grid_search([256]), 'layers': tune.grid_search([[512, 512]]), - 'lr': tune.grid_search([3e-4]), + 'lr': tune.grid_search([1e-4]), 'optimizer': tune.grid_search([tf.keras.optimizers.Adam]), }