Beispiel #1
0
def generate_plates(seed, world_name, output_dir, width, height,
                    num_plates=10):
    """
    Eventually this method should be invoked when generation is called at
    asked to stop at step "plates", it should not be a different operation
    :param seed:
    :param world_name:
    :param output_dir:
    :param width:
    :param height:
    :param num_plates:
    :return:
    """
    elevation, plates = generate_plates_simulation(seed, width, height,
                                                   num_plates=num_plates)

    world = World(world_name, width, height, seed, num_plates, -1.0, "plates")
    world.set_elevation(array_to_matrix(elevation, width, height), None)
    world.set_plates(array_to_matrix(plates, width, height))

    # Generate images
    filename = '%s/plates_%s.png' % (output_dir, world_name)
    # TODO calculate appropriate sea_level
    sea_level = 1.0
    draw_simple_elevation_on_file(world.elevation['data'], filename, width,
                                  height, sea_level)
    print("+ plates image generated in '%s'" % filename)
    geo.center_land(world)
    filename = '%s/centered_plates_%s.png' % (output_dir, world_name)
    draw_simple_elevation_on_file(world.elevation['data'], filename, width,
                                  height, sea_level)
    print("+ centered plates image generated in '%s'" % filename)
Beispiel #2
0
 def world(self):
     world = World(self.name, self.width, self.height, self.seed,
                   self.n_plates, self.ocean_level,
                   Step.get_by_name("plates"))
     hm = platec.get_heightmap(self.p)
     pm = platec.get_platesmap(self.p)
     world.set_elevation(array_to_matrix(hm, self.width, self.height), None)
     world.set_plates(array_to_matrix(pm, self.width, self.height))
     return world
Beispiel #3
0
 def world(self):
     world = World(self.name, self.width, self.height, self.seed,
                   self.n_plates, self.ocean_level,
                   Step.get_by_name("plates"))
     hm = platec.get_heightmap(self.p)
     pm = platec.get_platesmap(self.p)
     world.set_elevation(array_to_matrix(hm, self.width, self.height), None)
     world.set_plates(array_to_matrix(pm, self.width, self.height))
     return world
Beispiel #4
0
def _plates_simulation(name, width, height, seed, num_plates=10,
                       ocean_level=1.0, step=Step.full(),
                       verbose=get_verbose()):
    e_as_array, p_as_array = generate_plates_simulation(seed, width, height,
                                                        num_plates=num_plates,
                                                        verbose=verbose)

    world = World(name, width, height, seed, num_plates, ocean_level, step)
    world.set_elevation(array_to_matrix(e_as_array, width, height), None)
    world.set_plates(array_to_matrix(p_as_array, width, height))
    return world
Beispiel #5
0
def generate_plates(seed, world_name, output_dir, width, height,
                    num_plates=10):
    """
    Eventually this method should be invoked when generation is called at
    asked to stop at step "plates", it should not be a different operation
    :param seed:
    :param world_name:
    :param output_dir:
    :param width:
    :param height:
    :param num_plates:
    :return:
    """
    elevation, plates = generate_plates_simulation(seed, width, height,
                                                   num_plates=num_plates)

    world = World(world_name, width, height, seed, num_plates, -1.0, "plates")
    world.set_elevation(numpy.array(elevation).reshape(height, width), None)
    world.set_plates(array_to_matrix(plates, width, height))

    # Generate images
    filename = '%s/plates_%s.png' % (output_dir, world_name)
    # TODO calculate appropriate sea_level
    sea_level = 1.0
    draw_simple_elevation_on_file(world, filename, None)
    print("+ plates image generated in '%s'" % filename)
    geo.center_land(world)
    filename = '%s/centered_plates_%s.png' % (output_dir, world_name)
    draw_simple_elevation_on_file(world, filename, None)
    print("+ centered plates image generated in '%s'" % filename)
Beispiel #6
0
def _plates_simulation(name,
                       width,
                       height,
                       seed,
                       num_plates=10,
                       ocean_level=1.0,
                       step=Step.full(),
                       verbose=get_verbose()):
    e_as_array, p_as_array = generate_plates_simulation(seed,
                                                        width,
                                                        height,
                                                        num_plates=num_plates,
                                                        verbose=verbose)

    world = World(name, width, height, seed, num_plates, ocean_level, step)
    world.set_elevation(array_to_matrix(e_as_array, width, height), None)
    world.set_plates(array_to_matrix(p_as_array, width, height))
    return world
Beispiel #7
0
def _plates_simulation(name, width, height, seed, temps=
                       [.874, .765, .594, .439, .366, .124], humids=
                       [.941, .778, .507, .236, 0.073, .014, .002], gamma_curve=1.25,
                       curve_offset=.2, num_plates=10, ocean_level=1.0,
                       step=Step.full(), verbose=get_verbose()):
    e_as_array, p_as_array = generate_plates_simulation(seed, width, height,
                                                        num_plates=num_plates,
                                                        verbose=verbose)

    world = World(name, width, height, seed, num_plates, ocean_level, step, temps,
                  humids, gamma_curve, curve_offset)
    world.set_elevation(numpy.array(e_as_array).reshape(height, width), None)
    world.set_plates(array_to_matrix(p_as_array, width, height))
    return world
Beispiel #8
0
 def test_array_to_matrix(self):
     array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     self.assertEqual([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]], array_to_matrix(array, 5, 2))
     self.assertEqual([[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]], array_to_matrix(array, 2, 5))