Exemplo n.º 1
0
def test_coast_required_args():
    """
    Test if fig.coast fails when not given required arguments.
    """
    fig = Figure()
    with pytest.raises(GMTInvalidInput):
        fig.coast(region="EG")
Exemplo n.º 2
0
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]))
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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
Exemplo n.º 6
0
def test_coast_iceland():
    "Test passing in R as a list"
    fig_ref, fig_test = Figure(), Figure()
    # Use single-character arguments for the reference image
    fig_ref.coast(R="-30/-10/60/65", J="m1c", B="", G="p28+r100")
    fig_test.coast(region=[-30, -10, 60, 65],
                   projection="m1c",
                   frame=True,
                   land="p28+r100")
    return fig_ref, fig_test
Exemplo n.º 7
0
def test_coast_region():
    """
    Test plotting a regional map with coastlines.
    """
    fig = Figure()
    fig.coast(region="JP",
              projection="M10c",
              frame=True,
              land="gray",
              shorelines=1)
    return fig
Exemplo n.º 8
0
def test_coast_world_mercator():
    "Test passing generating a global Mercator map with coastlines"
    fig = Figure()
    fig.coast(
        region=[-180, 180, -80, 80],
        projection="M10i",
        frame="af",
        land="#aaaaaa",
        resolution="l",
        water="white",
    )
    return fig
Exemplo n.º 9
0
def test_coast_dcw_list():
    """
    Test passing a list of country codes and fill options to dcw.
    """
    fig = Figure()
    fig.coast(
        region=[-10, 15, 25, 44],
        frame="a",
        projection="M15c",
        land="brown",
        dcw=["ES+gbisque+pgreen", "IT+gcyan+pblue"],
    )
    return fig
Exemplo n.º 10
0
def test_coast_dcw_single():
    """
    Test passing a single country code to dcw.
    """
    fig = Figure()
    fig.coast(
        region=[-10, 15, 25, 44],
        frame="a",
        projection="M15c",
        land="brown",
        dcw="ES+gbisque+pblue",
    )
    return fig
Exemplo n.º 11
0
def test_plot_colors_sizes_proj(data, region):
    "Plot the data using z as sizes and colors with a projection"
    fig = Figure()
    fig.coast(region=region, projection="M10i", frame="af", water="skyblue")
    fig.plot(
        x=data[:, 0],
        y=data[:, 1],
        color=data[:, 2],
        sizes=0.5 * data[:, 2],
        style="cc",
        cmap="copper",
    )
    return fig
Exemplo n.º 12
0
def test_logo_on_a_map():
    "Plot a GMT logo in the upper right corner of a map"
    fig_ref, fig_test = Figure(), Figure()
    # Use single-character arguments for the reference image
    fig_ref.coast(R="-90/-70/0/20", J="M6i", G="chocolate", B="")
    fig_ref.logo(D="jTR+o0.1i/0.1i+w3i", F="")

    fig_test.coast(region=[-90, -70, 0, 20],
                   projection="M6i",
                   land="chocolate",
                   frame=True)
    fig_test.logo(position="jTR+o0.1i/0.1i+w3i", box=True)
    return fig_ref, fig_test
Exemplo n.º 13
0
def test_coast_dcw_continent():
    """
    Test passing a continent code to dcw.
    """
    fig_ref, fig_test = Figure(), Figure()
    # Use single-character arguments for the reference image
    fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="=AF+gbisque+pblue")
    fig_test.coast(
        region=[-10, 15, 25, 44],
        frame="a",
        projection="M15c",
        land="brown",
        dcw="=AF+gbisque+pblue",
    )
    return fig_ref, fig_test
Exemplo n.º 14
0
def test_coast():
    "Simple plot from the GMT docs"
    fig = Figure()
    fig.coast(
        R="-30/30/-40/40",
        J="m0.1i",
        B=5,
        I="1/1p,blue",
        N="1/0.25p,-",
        W="0.25p,white",
        G="green",
        S="blue",
        D="c",
        A=10000,
    )
    return fig
Exemplo n.º 15
0
def test_coast_dcw_state():
    """
    Test passing a US state code to dcw.
    """
    fig_ref, fig_test = Figure(), Figure()
    # Use single-character arguments for the reference image
    fig_ref.coast(
        R="-75/-69/40/44", J="M15c", B="a", G="brown", E="US.MA+gbisque+pblue"
    )
    fig_test.coast(
        region=[-75, -69, 40, 44],
        frame="a",
        projection="M15c",
        land="brown",
        dcw="US.MA+gbisque+pblue",
    )
    return fig_ref, fig_test
Exemplo n.º 16
0
def test_coast_aliases():
    """
    Test that all aliases work.
    """
    fig_ref, fig_test = Figure(), Figure()
    fig_ref.coast(
        R="-30/30/-40/40",
        J="M25c",
        B="afg",
        I="1/1p,black",
        N="1/0.5p,-",
        W="0.25p,white",
        G="moccasin",
        S="skyblue",
        D="i",
        A=1000,
        L="jCM+c1+w1000k+f+l",
        X="a4c",
        Y="a10c",
        p="135/25",
        t=13,
        E="MA+gred",
        C="blue",
    )
    fig_test.coast(
        region=[-30, 30, -40, 40],  # R
        projection="M25c",  # J
        frame="afg",  # B
        rivers="1/1p,black",  # I
        borders="1/0.5p,-",  # N
        shorelines="0.25p,white",  # W
        land="moccasin",  # G
        water="skyblue",  # S
        resolution="i",  # D
        area_thresh=1000,  # A
        map_scale="jCM+c1+w1000k+f+l",  # L
        xshift="a4c",  # X
        yshift="a10c",  # Y
        perspective=[135, 25],  # p
        transparency=13,  # t
        dcw="MA+gred",  # E
        lakes="blue",  # C
    )
    return fig_ref, fig_test
Exemplo n.º 17
0
def test_coast_dcw_list():
    """
    Test passing a list of country codes and fill options to dcw.
    """
    fig_ref, fig_test = Figure(), Figure()
    # Use single-character arguments for the reference image
    fig_ref.coast(
        R="-10/15/25/44",
        J="M15c",
        B="a",
        G="brown",
        E=["ES+gbisque+pgreen", "IT+gcyan+pblue"],
    )
    fig_test.coast(
        region=[-10, 15, 25, 44],
        frame="a",
        projection="M15c",
        land="brown",
        dcw=["ES+gbisque+pgreen", "IT+gcyan+pblue"],
    )
    return fig_ref, fig_test
Exemplo n.º 18
0
region = [-168., -140., 64.5, 72.]  # Northern Alaska
frame = ["WSnE", "xa", "ya"]
projection = "L-155/68/67/69/12c"   # Lambert Conic Conformal Projection
map_scale = "g-144/71+w200"  # reference point and length

# Overwrite config parameters for specific look using .py files
if overwrite_default_config:
	print("OVERWRITING DEFAULT CONFIGURATION")
	from cfg_neasz import *

# ==============================================================================

# Set up standard map look
fig = Figure()
fig.coast(projection=projection, region=region, resolution="h",
          shorelines=[f"1/1.5p,{coast}", f"2/1p,{coast}"], 
          frame=frame, land=land, water=water, lakes=lakes,
		  area_thresh=10000)

# Plot moment tensors which should be in a file in the psmeca format from GCMT
# lon lat depth mrr mtt mpp mrt mrp mtp iexp name 
if moment_tensors and mt_fid:
	# Make the colormap to shade MTs by depth
	depths = np.loadtxt(mt_fid, usecols=2, dtype=float)
	makecpt(cmap=mt_cmap, series=[min(depths), max(depths), 1])
	
	mts = fig.meca(mt_fid, scale=mt_scale, convention="mt", component="dc",
				   C=True, verbose=True, L="1p/black")

	if mt_colorbar:
		fig.colorbar(position="n.95/.825+w-2c/.45c", frame='af+l"depth [km]"')
Exemplo n.º 19
0
# Determine where we're mapping
region = [173., 179, -42.5, -37.]
projection = "U60S/12c"
interface_label = "l173/-39/177/-42"
map_scale = "g178/-42+c178/-42+w100"

# Overwrite config parameters for specific look using .py files, comment to skip
# from mahia_cfg import *
from cartoon_cfg import *
# ==============================================================================

# Set up standard map look
fig = Figure()
fig.coast(projection=projection,
          region=region,
          shorelines=[f"1/1.5p,{coast_color}", f"2/1p,{coast_color}"],
          frame=["WSne", "xa", "ya"])
# land="white", water="white")

# Set up colormap for plate coupling
cpt = "/Users/Chow/Documents/academic/vuw/data/carto/plate_coupling/rwb.cpt"
makecpt(cmap=cpt, series=[0, 1])

# Plot the plate coupling / slip rate deficit with a no-label colorbar
if plate_coupling:
    srd = "/Users/Chow/Documents/academic/vuw/data/carto/plate_coupling/hik.gmt"
    fig.plot(data=srd, cmap=True, close=True, color="+z")
    if colorbar:
        fig.colorbar(frame='af+l"Plate Coupling"')

# Plot the plate interface model as contours