pinwheel_map_generator.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from scripts.spatial_maps.supplement_pinwheel_map.pinwheel_map import PinwheelMap
  2. import warnings
  3. warnings.simplefilter(action='ignore', category=FutureWarning) # Otherwise pypet's FutureWarning spams the console output
  4. from pypet import Environment, cartesian_product
  5. from scripts.spatial_network.supplement_pinwheel_map.run_simulation_pinwheel_map import SCALE_RANGE, SEED_RANGE, \
  6. TRAJ_NAME_PINWHEEL_MAPS
  7. DATA_FOLDER = "../../../data/"
  8. LOG_FOLDER = "../../../logs/"
  9. def generate_and_save_seeded_map(traj):
  10. scale = traj.scale
  11. seed = traj.seed
  12. print('Generating pinwheel map with scale {} and seed {}'.format(scale, seed))
  13. dim = 60
  14. size = 900
  15. pinwheel_map = PinwheelMap(dim, dim, scale, size, size, seed)
  16. pinwheel_map.improve(10)
  17. traj.f_add_result('pinwheel_map', pinwheel_map.angle_grid, comment='Pinwheel map with scale {} and seed {}'.format(pinwheel_map.scale, pinwheel_map.seed))
  18. print('Pinwheel map with scale {} and seed {} saved'.format(pinwheel_map.scale, pinwheel_map.seed))
  19. return pinwheel_map.angle_grid
  20. def create_seeded_maps_in_scale_range():
  21. env = Environment(trajectory=TRAJ_NAME_PINWHEEL_MAPS, filename=DATA_FOLDER,
  22. file_title='pinwheel_map_set',
  23. comment='A number of precalculated pinwheel maps!',
  24. large_overview_tables=True,
  25. overwrite_file=True,
  26. multiproc=True,
  27. log_folder=LOG_FOLDER,
  28. ncores=0)
  29. traj = env.trajectory
  30. traj.f_add_parameter('scale', 200.0, comment='Scale factor c, see methods')
  31. traj.f_add_parameter('seed', 1, comment='Seed for random initialization')
  32. scale_range = SCALE_RANGE
  33. seed_range = SEED_RANGE
  34. traj.f_explore(cartesian_product({'scale': scale_range, 'seed': seed_range}))
  35. env.run(generate_and_save_seeded_map)
  36. env.disable_logging()
  37. if __name__ == "__main__":
  38. create_seeded_maps_in_scale_range()