def test_basemap_power_axis(): "Create a power axis basemap plot" fig = Figure() fig.basemap(R=[0, 100, 0, 5000], J="x1p0.5/-0.001", B=['x1p+l"Crustal age"', "y500+lDepth"]) return fig
def test_solar_terminators(): """ Test passing the solar argument with a time string and no terminator type to confirm the default terminator type. """ fig = Figure() fig.basemap(region="d", projection="W0/15c", frame="a") fig.solar( terminator="d", pen="1p,blue", terminator_datetime="1990-02-17 04:25:00", ) fig.solar( terminator="a", pen="1p,red", terminator_datetime="1990-02-17 04:25:00", ) fig.solar( terminator="c", pen="1p,green", terminator_datetime="1990-02-17 04:25:00", ) fig.solar( terminator="n", pen="1p,yellow", terminator_datetime="1990-02-17 04:25:00", ) return fig
def test_extract_region_two_figures(): """ Extract region should handle multiple figures existing at the same time. """ # Make two figures before calling extract_region to make sure that it's # getting from the current figure, not the last figure. fig1 = Figure() region1 = np.array([0, 10, -20, -10]) fig1.coast(region=region1, projection="M6i", frame=True, land="black") fig2 = Figure() fig2.basemap(region="US.HI+r5", projection="M6i", frame=True) # Activate the first figure and extract the region from it # Use in a different session to avoid any memory problems. with clib.Session() as lib: lib.call_module("figure", f"{fig1._name} -") with clib.Session() as lib: wesn1 = lib.extract_region() npt.assert_allclose(wesn1, region1) # Now try it with the second one with clib.Session() as lib: lib.call_module("figure", f"{fig2._name} -") with clib.Session() as lib: wesn2 = lib.extract_region() npt.assert_allclose(wesn2, np.array([-165.0, -150.0, 15.0, 25.0]))
def test_basemap_winkel_tripel(): """ Create a Winkel Tripel basemap plot. """ fig = Figure() fig.basemap(region=[90, 450, -90, 90], projection="R270/20c", frame="afg") return fig
def test_plot3d_scalar_xyz(): "Plot symbols given scalar x, y, z coordinates" fig_ref, fig_test = Figure(), Figure() with GMTTempFile() as tmpfile: np.savetxt(tmpfile.name, np.c_[[-1.5, 0, 1.5], [1.5, 0, -1.5], [-1.5, 0, 1.5]]) fig_ref.basemap( R="-2/2/-2/2/-2/2", B=["xaf+lx", "yaf+ly", "zaf+lz"], Jz=2, p="225/30" ) fig_ref.plot3d(data=tmpfile.name, S="c1c", G="red", Jz="", p="", qi=0) fig_ref.plot3d(data=tmpfile.name, S="t1c", G="green", Jz="", p="", qi=1) fig_ref.plot3d(data=tmpfile.name, S="s1c", G="blue", Jz="", p="", qi=2) fig_test.basemap( region=[-2, 2, -2, 2, -2, 2], frame=["xaf+lx", "yaf+ly", "zaf+lz"], zscale=2, perspective=[225, 30], ) fig_test.plot3d( x=-1.5, y=1.5, z=-1.5, style="c1c", color="red", zscale=True, perspective=True ) fig_test.plot3d( x=0, y=0, z=0, style="t1c", color="green", zscale=True, perspective=True ) fig_test.plot3d( x=1.5, y=-1.5, z=1.5, style="s1c", color="blue", zscale=True, perspective=True ) return fig_ref, fig_test
def test_basemap_required_args(): """ Automatically set `frame=True` when required arguments are not given. """ fig = Figure() fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c") return fig
def test_basemap(): """ Create a simple basemap plot. """ fig = Figure() fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c", frame="afg") return fig
def test_basemap_required_args(): """ fig.basemap fails when not given required arguments. """ fig = Figure() with pytest.raises(GMTInvalidInput): fig.basemap(R="10/70/-3/8", J="X4i/3i")
def test_basemap_list_region(): """ Create a simple basemap plot passing the region as a list. """ fig = Figure() fig.basemap(R=[-20, 50, 200, 500], J="X3i/3i", B="a") return fig
def test_basemap_winkel_tripel(): """ Create a Winkel Tripel basemap plot. """ fig = Figure() fig.basemap(R="90/450/-90/90", J="R270/25c", B="afg") return fig
def test_basemap_required_args(): """ Figure.basemap fails when not given required arguments. """ fig = Figure() with pytest.raises(GMTInvalidInput): fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c")
def test_basemap(): """ Create a simple basemap plot. """ fig = Figure() fig.basemap(R="10/70/-3/8", J="X4i/3i", B="afg") return fig
def test_figure_show(): """ Test that show creates the correct file name and deletes the temp dir. """ fig = Figure() fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af") fig.show()
def test_basemap_polar(): """ Create a polar basemap plot. """ fig = Figure() fig.basemap(region=[0, 360, 0, 1000], projection="P8c", frame="afg") return fig
def test_plot3d_scalar_xyz(): """ Plot symbols given scalar x, y, z coordinates. """ fig = Figure() fig.basemap( region=[-2, 2, -2, 2, -2, 2], frame=["xaf+lx", "yaf+ly", "zaf+lz"], zscale=2, perspective=[225, 30], ) fig.plot3d(x=-1.5, y=1.5, z=-1.5, style="c1c", color="red", zscale=True, perspective=True) fig.plot3d(x=0, y=0, z=0, style="t1c", color="green", zscale=True, perspective=True) fig.plot3d(x=1.5, y=-1.5, z=1.5, style="s1c", color="blue", zscale=True, perspective=True) return fig
def test_figure_display_external(): """ Test to check that a figure can be displayed in an external window. """ fig = Figure() fig.basemap(region=[0, 3, 6, 9], projection="X1c", frame=True) fig.show(method="external")
def test_legend_entries(): """ Test different marker types/shapes. """ fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref = Figure() fig_ref.basemap(J="x1i", R="0/7/3/7", B="") fig_ref.plot( data="@Table_5_11.txt", S="c0.15i", G="lightgreen", W="faint", l="Apples", ) fig_ref.plot(data="@Table_5_11.txt", W="1.5p,gray", l='"My lines"') fig_ref.plot(data="@Table_5_11.txt", S="t0.15i", G="orange", l="Oranges") fig_ref.legend(D="JTR+jTR") fig_test.basemap(projection="x1i", region=[0, 7, 3, 7], frame=True) fig_test.plot( data="@Table_5_11.txt", style="c0.15i", color="lightgreen", pen="faint", label="Apples", ) fig_test.plot(data="@Table_5_11.txt", pen="1.5p,gray", label='"My lines"') fig_test.plot( data="@Table_5_11.txt", style="t0.15i", color="orange", label="Oranges" ) fig_test.legend(position="JTR+jTR") return fig_ref, fig_test
def test_basemap_aliases(): """ Make sure the argument aliases work. """ fig = Figure() fig.basemap(region=[0, 360, -90, 90], projection="W7i", frame=True) return fig
def test_colorbar_shading_list(): """ Create colorbar and set shading by passing the high/low values as a list. """ fig = Figure() fig.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig.colorbar(cmap="geo", shading=[-0.7, 0.2], frame=True) return fig
def test_colorbar_positioned_using_map_coordinates(): """ Create colorbar positioned at longitude,latitude 3,6 with length 2cm. """ fig = Figure() fig.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True) fig.colorbar(cmap="rainbow", position="g3/6+w2c") return fig
def test_figure_region(): """ Extract the plot region for the figure. """ region = [0, 1, 2, 3] fig = Figure() fig.basemap(region=region, projection="X1id/1id", frame=True) npt.assert_allclose(fig.region, np.array(region))
def test_colorbar_positioned_using_normalized_coords(): """ Create colorbar at normalized coordinates 0.75,0.25 with length 2cm. """ fig = Figure() fig.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True) fig.colorbar(cmap="rainbow", position="n0.75/0.25+w2c") return fig
def test_plot_scalar_xy(): "Plot symbols given scalar x, y coordinates" fig = Figure() fig.basemap(region=[-2, 2, -2, 2], frame=True) fig.plot(x=-1.5, y=1.5, style="c1c") fig.plot(x=0, y=0, style="t1c") fig.plot(x=1.5, y=-1.5, style="s1c") return fig
def test_basemap_rose(): "Create a map with coast and use basemap to add a rose" fig_ref, fig_test = Figure(), Figure() fig_ref.coast(R="127.5/128.5/26/27", W="1/0.5p") fig_ref.basemap(Td="jBR+w5c") fig_test.coast(region=[127.5, 128.5, 26, 27], shorelines="1/0.5p") fig_test.basemap(rose="jBR+w5c") return fig_ref, fig_test
def test_logo_on_a_map(): """ Plot the GMT logo at the upper right corner of a map. """ fig = Figure() fig.basemap(region=[-90, -70, 0, 20], projection="M15c", frame=True) fig.logo(position="jTR+o0.25c/0.25c+w7.5c", box=True) return fig
def test_basemap_map_scale(): "Create a map with coast and use basemap to add a map scale" fig_ref, fig_test = Figure(), Figure() fig_ref.coast(R="127.5/128.5/26/27", W="1/0.5p") fig_ref.basemap(L="jMB+c1+w10k+l+f") fig_test.coast(region=[127.5, 128.5, 26, 27], shorelines="1/0.5p") fig_test.basemap(map_scale="jMB+c1+w10k+f+l") return fig_ref, fig_test
def test_basemap_compass(): "Create a map with coast and use basemap to add a compass" fig_ref, fig_test = Figure(), Figure() fig_ref.coast(R="127.5/128.5/26/27", W="1/0.5p") fig_ref.basemap(Tm="jBR+w5c+d11.5") fig_test.coast(region=[127.5, 128.5, 26, 27], shorelines="1/0.5p") fig_test.basemap(compass="******") return fig_ref, fig_test
def test_colorbar_shading_boolean(): """ Create colorbar and set shading with a Boolean value. """ fig = Figure() fig.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a") fig.colorbar(cmap="geo", shading=True, frame=True) return fig
def test_basemap_polar(): "Create a polar basemap plot" fig_ref, fig_test = Figure(), Figure() # Use single-character arguments for the reference image fig_ref.basemap(R="0/360/0/1000", J="P6i", B="afg") fig_test.basemap(region=[0, 360, 0, 1000], projection="P6i", frame="afg") return fig_ref, fig_test
def test_basemap_rose(): """ Create a map with a rose. """ fig = Figure() fig.basemap( region=[127.5, 128.5, 26, 27], projection="H15c", frame=True, rose="jMC+w5c" ) return fig