Esempio n. 1
0
def test_grdcontour_fails():
    """
    Should fail for unrecognized input.
    """
    fig = Figure()
    with pytest.raises(GMTInvalidInput):
        fig.grdcontour(np.arange(20).reshape((4, 5)))
Esempio n. 2
0
def test_grdcontour_interval_file_full_opts():
    """ Plot based on external contour level file """
    fig_ref, fig_test = Figure(), Figure()
    # Use single-character arguments for the reference image
    comargs_ref = {
        "grid": "@earth_relief_10m",
        "R": "-161.5/-154/18.5/23",
        "C": TEST_CONTOUR_FILE,
        "S": 100,
        "J": "M6i",
        "Q": 10,
    }
    fig_ref.grdcontour(**comargs_ref, L="-25000/-1", W=["a1p,blue", "c0.5p,blue"])
    fig_ref.grdcontour(**comargs_ref, L="0", W=["a1p,black", "c0.5p,black"])

    comargs_test = {
        "region": [-161.5, -154, 18.5, 23],
        "interval": TEST_CONTOUR_FILE,
        "grid": "@earth_relief_10m",
        "resample": "100",
        "projection": "M6i",
        "cut": 10,
    }
    fig_test.grdcontour(
        **comargs_test, limit=(-25000, -1), pen=["a1p,blue", "c0.5p,blue"]
    )
    fig_test.grdcontour(**comargs_test, limit=0, pen=["a1p,black", "c0.5p,black"])

    return fig_ref, fig_test
Esempio n. 3
0
def test_grdcontour(grid):
    """
    Plot a contour image using an xarray grid with fixed contour interval.
    """
    fig = Figure()
    fig.grdcontour(grid, interval="1000", projection="W0/15c", frame=True)
    return fig
Esempio n. 4
0
def test_grdcontour_interval_file_full_opts(grid):
    """
    Plot based on external contour level file.
    """
    fig = Figure()

    comargs = {
        "region": [-53, -49, -20, -17],
        "interval": TEST_CONTOUR_FILE,
        "grid": grid,
        "resample": 100,
        "projection": "M10c",
        "cut": 10,
    }
    # Plot contours below 650 in blue
    fig.grdcontour(**comargs,
                   limit=(0, 649),
                   pen=["a1p,blue", "c0.5p,blue"],
                   frame=True)
    # Plot contours above 650 in black
    fig.grdcontour(**comargs,
                   limit=(650, 1000),
                   pen=["a1p,black", "c0.5p,black"])

    return fig
Esempio n. 5
0
def test_grdcontour(grid):
    """Plot a contour image using an xarray grid
    with fixed contour interval
    """
    fig_ref, fig_test = Figure(), Figure()
    kwargs = dict(interval="1000", projection="W0/6i")
    fig_ref.grdcontour("@earth_relief_01d_g", **kwargs)
    fig_test.grdcontour(grid, **kwargs)
    return fig_ref, fig_test
Esempio n. 6
0
def test_grdcontour_slice(grid):
    """
    Plot an contour image using an xarray grid that has been sliced.
    """
    grid_ = grid.sel(lat=slice(-20, -10))

    fig = Figure()
    fig.grdcontour(grid=grid_, interval=100, projection="M10c", frame=True)
    return fig
Esempio n. 7
0
def test_grdcontour(grid):
    """
    Plot a contour image using an xarray grid with fixed contour interval.
    """
    fig = Figure()
    fig.grdcontour(grid=grid,
                   interval=50,
                   annotation=200,
                   projection="M10c",
                   frame=True)
    return fig
Esempio n. 8
0
def test_grdcontour_file():
    "Plot a contour image using grid file input"
    fig = Figure()
    fig.grdcontour(
        "@earth_relief_01d_g",
        interval="1000",
        limit="0",
        pen="0.5p,black",
        region=[-180, 180, -70, 70],
        projection="M10i",
    )
    return fig
Esempio n. 9
0
def test_grdcontour_slice(grid):
    "Plot an contour image using an xarray grid that has been sliced"

    fig_ref, fig_test = Figure(), Figure()

    grid_ = grid.sel(lat=slice(-30, 30))
    kwargs = dict(interval="1000", projection="M6i")
    fig_ref.grdcontour(
        grid="@earth_relief_01d_g", region=[-180, 180, -30, 30], **kwargs
    )
    fig_test.grdcontour(grid=grid_, **kwargs)
    return fig_ref, fig_test
Esempio n. 10
0
def test_grdcontour_labels(grid):
    """Plot a contour image using a xarray grid
    with contour labels and alternate colors
    """
    fig_ref, fig_test = Figure(), Figure()
    kwargs = dict(
        interval="1000",
        annotation="5000",
        projection="W0/6i",
        pen=["a1p,red", "c0.5p,black"],
        label_placement="d3i",
    )
    fig_ref.grdcontour("@earth_relief_01d_g", **kwargs)
    fig_test.grdcontour(grid, **kwargs)
    return fig_ref, fig_test
Esempio n. 11
0
def test_grdcontour_labels(grid):
    """
    Plot a contour image using a xarray grid with contour labels and alternate
    colors.
    """
    fig = Figure()
    fig.grdcontour(
        grid=grid,
        interval=50,
        annotation=200,
        projection="M10c",
        pen=["a1p,red", "c0.5p,black"],
        label_placement="d6c",
        frame=True,
    )
    return fig
Esempio n. 12
0
def test_grdcontour_interval_file_full_opts(grid):
    """
    Plot based on external contour level file.
    """
    fig = Figure()

    comargs = {
        "region": [-161.5, -154, 18.5, 23],
        "interval": TEST_CONTOUR_FILE,
        "grid": grid,
        "resample": "100",
        "projection": "M10c",
        "cut": 10,
    }
    fig.grdcontour(**comargs,
                   limit=(-25000, -1),
                   pen=["a1p,blue", "c0.5p,blue"])
    fig.grdcontour(**comargs,
                   limit=0,
                   pen=["a1p,black", "c0.5p,black"],
                   frame=True)

    return fig
Esempio n. 13
0
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
if interface:
    intfc = ("/Users/Chow/Documents/academic/vuw/data/carto/interface/"
             "williams_2013/supp_material_GMT/grid_exclude_wgs84.grd")
    contours = ("/Users/Chow/Documents/academic/vuw/data/carto/interface/"
                "williams_2013/supp_material_GMT/contours.txt")
    fig.grdcontour(
        intfc,
        interval=contours,
        frame="f",  # frame="a2f1g1", 
        annotation="40+f12",
        limit=[-100, 0],
        pen="thick,black,-",
        label_placement=interface_label)

# Valid bounds for plate interface, not necessary
if interface_bounds:
    bounds = ("/Users/Chow/Documents/academic/vuw/data/carto/interface/"
              "williams_2013/supp_material_GMT/bounds_wgs84.txt")
    fig.plot(data=bounds, columns=[0, 1], annotation="a2f1g1")

# Coastline towards the end so it plots over everything else
if coast:
    fig.coast(shorelines=["1/1.5p,black", "2/1p,black"],
              frame=["WSne", "xa", "ya"])