def test_write_output(output_dir): """ render the basemap """ r = Renderer(bna_star, output_dir, image_size=(600, 600), draw_back_to_fore=True, formats=['png']) r.draw_background() BB = r.map_BB (min_lon, min_lat) = BB[0] (max_lon, max_lat) = BB[1] N = 100 # create some random particle positions: lon = random.uniform(min_lon, max_lon, (N, )) lat = random.uniform(min_lat, max_lat, (N, )) # create a sc sc = sample_sc_release(num_elements=N) sc['positions'][:, 0] = lon sc['positions'][:, 1] = lat r.cache = FakeCache(sc) r.write_output(0) r.save_foreground(os.path.join(output_dir, 'map_and_elements.png')) r.draw_back_to_fore = False r.clear_foreground() r.write_output(1) r.save_foreground(os.path.join(output_dir, 'just_elements.png'))
def test_write_output(output_dir): """ render the basemap """ r = Renderer(bna_star, output_dir, image_size=(600, 600), draw_back_to_fore=True, formats=['png']) r.draw_background() BB = r.map_BB (min_lon, min_lat) = BB[0] (max_lon, max_lat) = BB[1] N = 100 # create some random particle positions: lon = random.uniform(min_lon, max_lon, (N, )) lat = random.uniform(min_lat, max_lat, (N, )) # create a sc sc = sample_sc_release(num_elements=N) sc['positions'][:, 0] = lon sc['positions'][:, 1] = lat r.cache = FakeCache(sc) r.write_output(0) r.save_foreground(os.path.join(output_dir, 'map_and_elements.png')) r.draw_back_to_fore = False r.clear_foreground() r.write_output(1) r.save_foreground(os.path.join(output_dir, 'just_elements.png'))
def test_render_basemap_with_bounds(output_dir): """ render the basemap """ r = Renderer(bna_sample, output_dir, image_size=(600, 600)) r.draw_background() r.save_background(os.path.join(output_dir, 'basemap_bounds.png'))
def test_render_basemap_with_bounds(output_dir): """ render the basemap """ r = Renderer(bna_sample, output_dir, image_size=(600, 600)) r.draw_background() r.save_background(os.path.join(output_dir, 'basemap_bounds.png'))
def test_show_hide_map_bounds(output_dir): r = Renderer(bna_star, output_dir, image_size=(600, 600)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_background.png')) # try again without the map bounds: r.draw_map_bounds = False r.draw_background() r.save_background(os.path.join(output_dir, 'star_background_no_bound.png'))
def test_show_hide_map_bounds(output_dir): r = Renderer(bna_star, output_dir, image_size=(600, 600)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_background.png')) # try again without the map bounds: r.draw_map_bounds = False r.draw_background() r.save_background(os.path.join(output_dir, 'star_background_no_bound.png'))
def test_draw_raster_map(output_dir): """ tests drawing the raster map Note: you need to look at the output to know if it did it right... """ import gnome r = Renderer(bna_sample, image_size=(1000, 1000)) r.viewport = ((-127.47, 48.10), (-127.22, 48.24)) r.draw_background() # make a raster map out of the BNA: r.raster_map = gnome.map.MapFromBNA(bna_sample, raster_size=10000) r.raster_map_outline = True r.draw_raster_map() r.save_background(os.path.join(output_dir, 'raster_map_render.png'))
def test_draw_raster_map(output_dir): """ tests drawing the raster map Note: you need to look at the output to know if it did it right... """ import gnome r = Renderer(bna_sample, image_size=(1000, 1000)) r.viewport = ((-127.47, 48.10), (-127.22, 48.24)) r.draw_background() # make a raster map out of the BNA: r.raster_map = gnome.map.MapFromBNA(bna_sample, raster_size=10000) r.raster_map_outline = True r.draw_raster_map() r.save_background(os.path.join(output_dir, 'raster_map_render.png'))
def test_set_viewport(output_dir): """ tests various rendering, re-zooming, etc NOTE: this will only test if the code crashes, you have to look at the rendered images to see if it does the right thing """ r = Renderer( bna_star, output_dir, image_size=(600, 600), projection=GeoProjection(), ) # re-scale: # should show upper right corner r.viewport = ((-73, 40), (-70, 43)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_upper_right.png')) # re-scale: # should show lower right corner r.viewport = ((-73, 37), (-70, 40)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_lower_right.png')) # re-scale: # should show lower left corner r.viewport = ((-76, 37), (-73, 40)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_lower_left.png')) # re-scale: # should show upper left corner r.viewport = ((-76, 40), (-73, 43)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_upper_left.png'))
def test_set_viewport(output_dir): """ tests various rendering, re-zooming, etc NOTE: this will only test if the code crashes, you have to look at the rendered images to see if it does the right thing """ r = Renderer(bna_star, output_dir, image_size=(600, 600), projection=GeoProjection(), ) # re-scale: # should show upper right corner r.viewport = ((-73, 40), (-70, 43)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_upper_right.png')) # re-scale: # should show lower right corner r.viewport = ((-73, 37), (-70, 40)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_lower_right.png')) # re-scale: # should show lower left corner r.viewport = ((-76, 37), (-73, 40)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_lower_left.png')) # re-scale: # should show upper left corner r.viewport = ((-76, 40), (-73, 43)) r.draw_background() r.save_background(os.path.join(output_dir, 'star_upper_left.png'))