profile
viewpoint
Dongdong Tian seisman Michigan State University East Lansing, MI, USA https://seisman.info Postdoc of Geophysics in Michigan State University. Core developer of @GenericMappingTools.

seisman/how-to-write-makefile 1085

跟我一起写Makefile重制版

openjournals/joss-reviews 360

Reviews for the Journal of Open Source Software

seisman/HinetPy 36

A Python package to request and process seismic waveform data from Hi-net.

seisman/cv 35

My academic CV powered by LaTeX

seisman/blog.seisman.info 15

SeisMan博客v3.0

seisman/GMT5_Docs 8

本项目已迁移至GMT中文社区 https://github.com/gmt-china/GMT_docs

seisman/academic-homepage 6

My academic homepage

GenericMappingTools/try-gmt 4

Try GMT, PyGMT, and GMT.jl online! All in one place!

seisman/FnetPy 4

A Python package to request seismic waveform data from F-net.

push eventseisman/academic-homepage

Dongdong Tian

commit sha d6a9f1ba58bb94a90549e124d2447938568f501a

Update to theme 20201027

view details

push time in 13 hours

push eventGenericMappingTools/gmt

AzurePipelines

commit sha c00740f938b35d98954cafcc498c49657047e906

Deploy documentation from Azure Pipelines

view details

push time in 21 hours

push eventGenericMappingTools/gmt

AzurePipelines

commit sha 8947b573c63d0e4d4ed15e57bb29836d11d291ba

Deploy documentation from Azure Pipelines

view details

push time in a day

Pull request review commentGenericMappingTools/gmt

Simplify addition of category labels to CPT files

 we always get a color regardless of the *z* value, try      gmt makecpt -Cjet -T0/500 -Ww > wrapped.cpt +To build a categorical table with 3 categories and add specific category+names to them, try::++    gmt makecpt -Ccubhelix -T0/3/1 -F+cClouds,Trees,Water > cat.cpt++To instead add unique category labels A, B, C, ... to a 10-item categorical CPT, try::++    gmt makecpt -Cjet -T0/q0/1 -F+cA

Typo here? q0 should be 10?

PaulWessel

comment created time in a day

PullRequestReviewEvent

push eventGenericMappingTools/gmt

AzurePipelines

commit sha 431cad312d7843be8555427ef6cea64f9ac3c124

Deploy documentation from Azure Pipelines

view details

push time in a day

PullRequestReviewEvent

fork seisman/obsplus

A Pandas-Centric ObsPy Expansion Pack

fork in a day

PullRequestReviewEvent

startedniosh-mining/obsplus

started time in 2 days

push eventseisman/HinetPy

Dongdong Tian

commit sha e014134cc1051124e4182be0147007cb94ef167b

Exclude files for black

view details

push time in 2 days

delete branch seisman/HinetPy

delete branch : action

delete time in 2 days

push eventseisman/HinetPy

Dongdong Tian

commit sha b19f2fa977a05f86b003a9f16fab7f9db114553c

Use the new way to add bin to PATH (#41)

view details

push time in 2 days

PR merged seisman/HinetPy

Use the new way to add bin to PATH

Description of proposed changes

See https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

Reminders

  • [ ] Run make format and make check to make sure the code follows the style guide.
  • [ ] Add tests for new features or tests that would have caught the bug that you're fixing.
  • [ ] Write detailed docstrings for all functions/methods.
  • [ ] If adding new functionality, add an example to docstrings or tutorials.
+1 -1

0 comment

1 changed file

seisman

pr closed time in 2 days

PR opened seisman/HinetPy

Use the new way to add bin to PATH

Description of proposed changes

See https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

Reminders

  • [ ] Run make format and make check to make sure the code follows the style guide.
  • [ ] Add tests for new features or tests that would have caught the bug that you're fixing.
  • [ ] Write detailed docstrings for all functions/methods.
  • [ ] If adding new functionality, add an example to docstrings or tutorials.
+1 -1

0 comment

1 changed file

pr created time in 2 days

create barnchseisman/HinetPy

branch : action

created branch time in 2 days

delete branch seisman/SeisLinks

delete branch : park

delete time in 2 days

push eventseisman/SeisLinks

Dongdong Tian

commit sha 4c5815f4c4500024f324c14893e11d37fc5ae1c6

Add Sunyoung Park's site (#20)

view details

push time in 2 days

PR merged seisman/SeisLinks

Add Sunyoung Park's site
+1 -0

0 comment

1 changed file

seisman

pr closed time in 2 days

PR opened seisman/SeisLinks

Add Sunyoung Park's site
+1 -0

0 comment

1 changed file

pr created time in 2 days

create barnchseisman/SeisLinks

branch : park

created branch time in 2 days

push eventseisman/SeisLinks

Dongdong Tian

commit sha 8081c34d3f805ad957735490c8ec663e305db169

Update some links (#19) 1. Add a tutorial for numpy 2. Separate "Seismology" learning resources into subsections 3. Remove a few broken links

view details

push time in 2 days

delete branch seisman/SeisLinks

delete branch : update-links

delete time in 2 days

PR merged seisman/SeisLinks

Update some links
  1. Add a tutorial for numpy
  2. Separate "Seismology" learning resources into subsections
  3. Remove a few broken links
+11 -2

0 comment

2 changed files

seisman

pr closed time in 2 days

PR opened seisman/SeisLinks

Update some links
+11 -2

0 comment

2 changed files

pr created time in 2 days

create barnchseisman/SeisLinks

branch : update-links

created branch time in 2 days

Pull request review commentGenericMappingTools/pygmt

Upload artifacts showing diff images on test failure

 def test_grdimage_central_meridians(grid, proj_type, lon0): # are still slightly different with an RMS error of 25, see issue at # https://github.com/GenericMappingTools/pygmt/issues/390 # TO-DO remove tol=1.5 and pytest.mark.xfail once bug is solved in upstream GMT-@check_figures_equal(tol=1.5)+# @check_figures_equal(tol=1.5)

Remember to remove the changes before merging.

weiji14

comment created time in 2 days

Pull request review commentGenericMappingTools/pygmt

Upload artifacts showing diff images on test failure

 jobs:       # Run the tests       - name: Test with pytest         run: make test PYTEST_EXTRA="-r P"++      # Upload diff images on test failure+      - name: Upload diff images if any test fails+        uses: actions/upload-artifact@v2+        if: ${{ failure() }}+        with:+          name: artifact-GMT ${{ matrix.gmt_git_ref }}-${{ runner.os }}
          name: artifact-GMT${{ matrix.gmt_git_ref }}-${{ runner.os }}

or

          name: artifact-GMT-${{ matrix.gmt_git_ref }}-${{ runner.os }}
weiji14

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

push eventGenericMappingTools/gmt

AzurePipelines

commit sha b89cf850b3ee427fec415af7aef852d5a0e226cc

Deploy documentation from Azure Pipelines

view details

push time in 2 days

startedjalammar/jalammar.github.io

started time in 2 days

push eventseisman/HinetPy

Dongdong Tian

commit sha 5a4f069d2b9b6dc7dcc2e7098bbbfd38eacdc49d

Fix more lint issues

view details

push time in 2 days

issue commentGenericMappingTools/gmt

Annotations for categorical CPT

BTW, the categorical CPT looks correct:

gmt makecpt -Ccubhelix -T0/3/1 -F+c
0	24/45.5/72.5	L
1	159.5/121/72.5	L
2	194/215.5/242	B
B	black
F	white
N	red
seisman

comment created time in 2 days

issue commentGenericMappingTools/gmt

Annotations for categorical CPT

colorbar -Li doesn't change anything.

seisman

comment created time in 2 days

Pull request review commentGenericMappingTools/pygmt

Upload artifacts showing diff images on test failure

 jobs:         shell: bash -l {0}         run: make test PYTEST_EXTRA="-r P" +      # Upload diff images on test failure+      - name: Upload diff images if any test fails+        uses: actions/upload-artifact@v2+        if: ${{ failure() }}+        with:+          name: artifact-${{ matrix.os }}-${{ matrix.python-version }}

It works as expected now.

image

What about changing the names to:

          name: artifact-${{ runner.os }}-Python${{ matrix.python-version }}

runner.os's possible values are Linux, Windows, or macOS.

Then the artifacts will be artifact-Windows-Python3.8.

weiji14

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

 Plotting data and laying out the map:     Figure.coast     Figure.colorbar     Figure.plot+    Figure.plot3d

Yes.

weiji14

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+3D Scatter plots+----------------++The :meth:`pygmt.Figure.plot3d` method can be used to plot symbols in 3D.+In the example below, we show how the Iris flower dataset can be visualized+using a perspective 3-dimensional plot. The ``region`` argument has to be set+to include the :math:`x`, :math:`y`, :math:`z` axis limits in the form of+(xmin, xmax, ymin, ymax, zmin, zmax), and this can be done automatically using+:meth:`pygmt.info`. To include the z-axis stick, ``frame`` needs to be set as a+minimum to something like ``frame=["WsNeZ", "zaf"]``. Use ``perspective`` to+control the azimuth and elevation angle of the view, and ``zscale`` to adjust+the vertical exaggeration factor.+"""++import pandas as pd+import pygmt++# Load sample iris data, and convert 'species' column to categorical dtype+df = pd.read_csv("https://github.com/mwaskom/seaborn-data/raw/master/iris.csv")+df["species"] = df.species.astype(dtype="category")++# Use pygmt.info to get region bounds (xmin, xmax, ymin, ymax, zmin, zmax)+# The below example will return a numpy array like [0., 3., 4., 8., 1., 7.]+region = pygmt.info(+    table=df[["petal_width", "sepal_length", "petal_length"]],  # x, y, z columns+    per_column=True,  # report output as a numpy array+    spacing="1/2/0.5",  # rounds x, y and z intervals by 1, 2 and 0.5 respectively+)++# Make our 3D scatter plot, coloring each of the 3 species differently+fig = pygmt.Figure()+pygmt.makecpt(cmap="cubhelix", series=(0, 3, 1))

Already reported to upstream https://github.com/GenericMappingTools/gmt/issues/4387 and https://github.com/GenericMappingTools/gmt/issues/4388.

weiji14

comment created time in 2 days

PullRequestReviewEvent

issue openedGenericMappingTools/gmt

Annotations for categorical CPT

makecpt -F+c can produce a categorical CPT, but when plotting the colorbar, the annotations look weird. See the example below. Why the annotations are "0-1", "1-2", and "2-3". Should they be "0", "1", and "2", no?

gmt begin map png
gmt basemap -R0/10/0/10 -JX4c -Baf -BWSen
gmt makecpt -Ccubhelix -T0/3/1 -F+c
gmt colorbar
gmt end show

image

created time in 2 days

issue openedGenericMappingTools/gmt

gridlines for 3D basemap sometimes don't work as expected

gmt basemap -R0/3/4/8/1/7 -Jz1.5 -p315/25 -BWsNeZ3 -Bxafg -Byafg -Bzafg -png map

image

The gridlines in the YZ and XZ planes don't extend to the Z limits.

created time in 2 days

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+3D Scatter plots+----------------++The :meth:`pygmt.Figure.plot3d` method can be used to plot symbols in 3D.+In the example below, we show how the Iris flower dataset can be visualized+using a perspective 3-dimensional plot. The ``region`` argument has to be set+to include the :math:`x`, :math:`y`, :math:`z` axis limits in the form of+(xmin, xmax, ymin, ymax, zmin, zmax), and this can be done automatically using+:meth:`pygmt.info`. To include the z-axis stick, ``frame`` needs to be set as a+minimum to something like ``frame=["WsNeZ", "zaf"]``. Use ``perspective`` to+control the azimuth and elevation angle of the view, and ``zscale`` to adjust+the vertical exaggeration factor.+"""++import pandas as pd+import pygmt++# Load sample iris data, and convert 'species' column to categorical dtype+df = pd.read_csv("https://github.com/mwaskom/seaborn-data/raw/master/iris.csv")+df["species"] = df.species.astype(dtype="category")++# Use pygmt.info to get region bounds (xmin, xmax, ymin, ymax, zmin, zmax)+# The below example will return a numpy array like [0., 3., 4., 8., 1., 7.]+region = pygmt.info(+    table=df[["petal_width", "sepal_length", "petal_length"]],  # x, y, z columns+    per_column=True,  # report output as a numpy array+    spacing="1/2/0.5",  # rounds x, y and z intervals by 1, 2 and 0.5 respectively

I feel that we should use spacing=[1, 2, 0.5] here, but unfortunately, it's unimplemented in pygmt.info().

weiji14

comment created time in 2 days

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+3D Scatter plots+----------------++The :meth:`pygmt.Figure.plot3d` method can be used to plot symbols in 3D.+In the example below, we show how the Iris flower dataset can be visualized+using a perspective 3-dimensional plot. The ``region`` argument has to be set+to include the :math:`x`, :math:`y`, :math:`z` axis limits in the form of+(xmin, xmax, ymin, ymax, zmin, zmax), and this can be done automatically using+:meth:`pygmt.info`. To include the z-axis stick, ``frame`` needs to be set as a+minimum to something like ``frame=["WsNeZ", "zaf"]``. Use ``perspective`` to+control the azimuth and elevation angle of the view, and ``zscale`` to adjust+the vertical exaggeration factor.+"""++import pandas as pd+import pygmt++# Load sample iris data, and convert 'species' column to categorical dtype+df = pd.read_csv("https://github.com/mwaskom/seaborn-data/raw/master/iris.csv")+df["species"] = df.species.astype(dtype="category")++# Use pygmt.info to get region bounds (xmin, xmax, ymin, ymax, zmin, zmax)+# The below example will return a numpy array like [0., 3., 4., 8., 1., 7.]+region = pygmt.info(+    table=df[["petal_width", "sepal_length", "petal_length"]],  # x, y, z columns+    per_column=True,  # report output as a numpy array+    spacing="1/2/0.5",  # rounds x, y and z intervals by 1, 2 and 0.5 respectively+)++# Make our 3D scatter plot, coloring each of the 3 species differently+fig = pygmt.Figure()+pygmt.makecpt(cmap="cubhelix", series=(0, 3, 1))

This makecpt command produces a discrete CPT (see the figure below). It doesn't make sense for the categorical data here. image.

Instead, we should use makecpt -F+c, which produces categorical CPT.

image

But the colorbar annotations don't make sense to me. Perhaps another GMT bug.

Note: the gridlines are not shown in GMT 6.1.1. It's a new future in GMT master (see https://github.com/GenericMappingTools/gmt/pull/3993), but the gridlines in XZ and YZ planes may also have bugs. Will report to GMT later.

weiji14

comment created time in 2 days

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+3D Scatter plots+----------------++The :meth:`pygmt.Figure.plot3d` method can be used to plot symbols in 3D.+In the example below, we show how the Iris flower dataset can be visualized

Add a link to the "Iris flower dataset"? e.g., https://en.wikipedia.org/wiki/Iris_flower_data_set?

weiji14

comment created time in 2 days

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

 Plotting data and laying out the map:     Figure.coast     Figure.colorbar     Figure.plot+    Figure.plot3d

A little off-topic, but should we sort all the methods alphabetically?

weiji14

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

@weiji14 I think this PR is good to merge (except the conflict and the pending CI). Please give it a final review if you have time.

hemmelig

comment created time in 2 days

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+Tests plot3d.+"""+import os++import numpy as np+import pytest++from .. import Figure+from ..exceptions import GMTInvalidInput+from ..helpers import GMTTempFile+from ..helpers.testing import check_figures_equal+++TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")+POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")+++@pytest.fixture(scope="module", name="data")+def fixture_data():+    "Load the point data from the test file"+    return np.loadtxt(POINTS_DATA)+++@pytest.fixture(scope="module", name="region")+def fixture_region():+    "The data region"+    return [10, 70, -5, 10, 0, 1]+++@check_figures_equal()+def test_plot3d_red_circles_zscale(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zscale = 5"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_red_circles_zsize(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zsize = 3i"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        JZ="3i",+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zsize="3i",+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++def test_plot3d_fail_no_data(data, region):+    "Plot should raise an exception if no data is given"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            region=region, projection="X4i", style="c0.2c", color="red", frame="afg"+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            y=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    # Should also fail if given too much data+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            y=data[:, 1],+            z=data[:, 2],+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+++def test_plot3d_fail_size_color(data, region):+    "Should raise an exception if array sizes and color are used with matrix"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color=data[:, 2],+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="cc",+            sizes=data[:, 2],+            color="red",+            frame="afg",+        )+++@check_figures_equal()+def test_plot3d_projection(data, region):+    "Plot the data in green squares with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="R270/4i",+        S="s1c",+        G="green",+        B=["ag", "zag"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="R270/4i",+        style="s1c",+        color="green",+        frame=["ag", "zag"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors(data, region):+    "Plot the data using z as colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        G="+z",+        R="/".join(map(str, region)),+        J="X3i",+        S="c0.5c",+        C="cubhelix",+        B=["afg", "zafg"],+        i="0,1,2,2",+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        region=region,+        projection="X3i",+        style="c0.5c",+        cmap="cubhelix",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_sizes(data, region):+    "Plot the data using z as sizes"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X4i",+        S="cc",+        G="blue",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X4i",+        style="cc",+        color="blue",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes(data, region):+    "Plot the data using z as sizes and colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X3i",+        S="cc",+        C="copper",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X3i",+        style="cc",+        cmap="copper",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes_proj(data, region):+    "Plot the data using z as sizes and colors with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="M10i",+        B=["af", "zaf"],+        G="+z",+        i="0,1,2,2,2+s1",

Please report the bug to GMT, and also add a few comments in the tests explaining why we use inches.

weiji14

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Upload artifacts showing diff images on test failure

 def test_grdimage_central_meridians(grid, proj_type, lon0): # are still slightly different with an RMS error of 25, see issue at # https://github.com/GenericMappingTools/pygmt/issues/390 # TO-DO remove tol=1.5 and pytest.mark.xfail once bug is solved in upstream GMT-@check_figures_equal(tol=1.5)+# @check_figures_equal(tol=1.5) @pytest.mark.parametrize("lat0", [0, 30]) @pytest.mark.parametrize("lon0", [0, 123, 180]) @pytest.mark.parametrize("proj_type", [pytest.param("Q", marks=pytest.mark.xfail), "S"])

That's weird. The master branch CI says these tests are xfail:

../tests/test_grdimage.py::test_grdimage_central_meridians_and_standard_parallels[Q-123-0-png] XFAIL [ 52%]
../tests/test_grdimage.py::test_grdimage_central_meridians_and_standard_parallels[Q-123-30-png] XFAIL [ 53%]
../tests/test_grdimage.py::test_grdimage_central_meridians_and_standard_parallels[Q-180-0-png] XFAIL [ 53%]
../tests/test_grdimage.py::test_grdimage_central_meridians_and_standard_parallels[Q-180-30-png] XFAIL [ 53%]
weiji14

comment created time in 2 days

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+Tests plot3d.+"""+import os++import numpy as np+import pytest++from .. import Figure+from ..exceptions import GMTInvalidInput+from ..helpers import GMTTempFile+from ..helpers.testing import check_figures_equal+++TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")+POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")+++@pytest.fixture(scope="module", name="data")+def fixture_data():+    "Load the point data from the test file"+    return np.loadtxt(POINTS_DATA)+++@pytest.fixture(scope="module", name="region")+def fixture_region():+    "The data region"+    return [10, 70, -5, 10, 0, 1]+++@check_figures_equal()+def test_plot3d_red_circles_zscale(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zscale = 5"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_red_circles_zsize(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zsize = 3i"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        JZ="3i",+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zsize="3i",+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++def test_plot3d_fail_no_data(data, region):+    "Plot should raise an exception if no data is given"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            region=region, projection="X4i", style="c0.2c", color="red", frame="afg"+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            y=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    # Should also fail if given too much data+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            y=data[:, 1],+            z=data[:, 2],+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+++def test_plot3d_fail_size_color(data, region):+    "Should raise an exception if array sizes and color are used with matrix"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color=data[:, 2],+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="cc",+            sizes=data[:, 2],+            color="red",+            frame="afg",+        )+++@check_figures_equal()+def test_plot3d_projection(data, region):+    "Plot the data in green squares with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="R270/4i",+        S="s1c",+        G="green",+        B=["ag", "zag"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="R270/4i",+        style="s1c",+        color="green",+        frame=["ag", "zag"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors(data, region):+    "Plot the data using z as colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        G="+z",+        R="/".join(map(str, region)),+        J="X3i",+        S="c0.5c",+        C="cubhelix",+        B=["afg", "zafg"],+        i="0,1,2,2",+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        region=region,+        projection="X3i",+        style="c0.5c",+        cmap="cubhelix",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_sizes(data, region):+    "Plot the data using z as sizes"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X4i",+        S="cc",+        G="blue",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X4i",+        style="cc",+        color="blue",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes(data, region):+    "Plot the data using z as sizes and colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X3i",+        S="cc",+        C="copper",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X3i",+        style="cc",+        cmap="copper",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes_proj(data, region):+    "Plot the data using z as sizes and colors with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="M10i",+        B=["af", "zaf"],+        G="+z",+        i="0,1,2,2,2+s1",

I think you're right. -Suc and -Sui give the same result. It may be a GMT bug.

weiji14

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+Tests plot3d.+"""+import os++import numpy as np+import pytest++from .. import Figure+from ..exceptions import GMTInvalidInput+from ..helpers import GMTTempFile+from ..helpers.testing import check_figures_equal+++TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")+POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")+++@pytest.fixture(scope="module", name="data")+def fixture_data():+    "Load the point data from the test file"+    return np.loadtxt(POINTS_DATA)+++@pytest.fixture(scope="module", name="region")+def fixture_region():+    "The data region"+    return [10, 70, -5, 10, 0, 1]+++@check_figures_equal()+def test_plot3d_red_circles_zscale(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zscale = 5"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_red_circles_zsize(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zsize = 3i"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        JZ="3i",+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zsize="3i",+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++def test_plot3d_fail_no_data(data, region):+    "Plot should raise an exception if no data is given"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            region=region, projection="X4i", style="c0.2c", color="red", frame="afg"+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            y=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    # Should also fail if given too much data+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            y=data[:, 1],+            z=data[:, 2],+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+++def test_plot3d_fail_size_color(data, region):+    "Should raise an exception if array sizes and color are used with matrix"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color=data[:, 2],+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="cc",+            sizes=data[:, 2],+            color="red",+            frame="afg",+        )+++@check_figures_equal()+def test_plot3d_projection(data, region):+    "Plot the data in green squares with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="R270/4i",+        S="s1c",+        G="green",+        B=["ag", "zag"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="R270/4i",+        style="s1c",+        color="green",+        frame=["ag", "zag"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors(data, region):+    "Plot the data using z as colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        G="+z",+        R="/".join(map(str, region)),+        J="X3i",+        S="c0.5c",+        C="cubhelix",+        B=["afg", "zafg"],+        i="0,1,2,2",+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        region=region,+        projection="X3i",+        style="c0.5c",+        cmap="cubhelix",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_sizes(data, region):+    "Plot the data using z as sizes"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X4i",+        S="cc",+        G="blue",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X4i",+        style="cc",+        color="blue",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes(data, region):+    "Plot the data using z as sizes and colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X3i",+        S="cc",+        C="copper",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X3i",+        style="cc",+        cmap="copper",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes_proj(data, region):+    "Plot the data using z as sizes and colors with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="M10i",+        B=["af", "zaf"],+        G="+z",+        i="0,1,2,2,2+s1",

I only see one artifact in this page: https://github.com/GenericMappingTools/pygmt/actions/runs/330476822

weiji14

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+Tests plot3d.+"""+import os++import numpy as np+import pytest++from .. import Figure+from ..exceptions import GMTInvalidInput+from ..helpers import GMTTempFile+from ..helpers.testing import check_figures_equal+++TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")+POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")+++@pytest.fixture(scope="module", name="data")+def fixture_data():+    "Load the point data from the test file"+    return np.loadtxt(POINTS_DATA)+++@pytest.fixture(scope="module", name="region")+def fixture_region():+    "The data region"+    return [10, 70, -5, 10, 0, 1]+++@check_figures_equal()+def test_plot3d_red_circles_zscale(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zscale = 5"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_red_circles_zsize(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zsize = 3i"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        JZ="3i",+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zsize="3i",+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++def test_plot3d_fail_no_data(data, region):+    "Plot should raise an exception if no data is given"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            region=region, projection="X4i", style="c0.2c", color="red", frame="afg"+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            y=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    # Should also fail if given too much data+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            y=data[:, 1],+            z=data[:, 2],+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+++def test_plot3d_fail_size_color(data, region):+    "Should raise an exception if array sizes and color are used with matrix"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color=data[:, 2],+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="cc",+            sizes=data[:, 2],+            color="red",+            frame="afg",+        )+++@check_figures_equal()+def test_plot3d_projection(data, region):+    "Plot the data in green squares with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="R270/4i",+        S="s1c",+        G="green",+        B=["ag", "zag"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="R270/4i",+        style="s1c",+        color="green",+        frame=["ag", "zag"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors(data, region):+    "Plot the data using z as colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        G="+z",+        R="/".join(map(str, region)),+        J="X3i",+        S="c0.5c",+        C="cubhelix",+        B=["afg", "zafg"],+        i="0,1,2,2",+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        region=region,+        projection="X3i",+        style="c0.5c",+        cmap="cubhelix",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_sizes(data, region):+    "Plot the data using z as sizes"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X4i",+        S="cc",+        G="blue",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X4i",+        style="cc",+        color="blue",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes(data, region):+    "Plot the data using z as sizes and colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X3i",+        S="cc",+        C="copper",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X3i",+        style="cc",+        cmap="copper",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes_proj(data, region):+    "Plot the data using z as sizes and colors with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="M10i",+        B=["af", "zaf"],+        G="+z",+        i="0,1,2,2,2+s1",

P.S. Will cherry-pick commit 413ff77 into a separate Pull Request.

There are 3 failing jobs, but it seems I only see one artifact. Perhaps in 413ff77c98facb8370cd5bf8e53c6dfe54bd7848 we should use unique names for artifacts from different jobs?

weiji14

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

+"""+Tests plot3d.+"""+import os++import numpy as np+import pytest++from .. import Figure+from ..exceptions import GMTInvalidInput+from ..helpers import GMTTempFile+from ..helpers.testing import check_figures_equal+++TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")+POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")+++@pytest.fixture(scope="module", name="data")+def fixture_data():+    "Load the point data from the test file"+    return np.loadtxt(POINTS_DATA)+++@pytest.fixture(scope="module", name="region")+def fixture_region():+    "The data region"+    return [10, 70, -5, 10, 0, 1]+++@check_figures_equal()+def test_plot3d_red_circles_zscale(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zscale = 5"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_red_circles_zsize(data, region):+    "Plot the 3D data in red circles passing in vectors and setting zsize = 3i"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        JZ="3i",+        p="225/30",+        R="/".join(map(str, region)),+        J="X4i",+        S="c0.2c",+        G="red",+        B=["afg", "zafg"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zsize="3i",+        perspective=[225, 30],+        region=region,+        projection="X4i",+        style="c0.2c",+        color="red",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++def test_plot3d_fail_no_data(data, region):+    "Plot should raise an exception if no data is given"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            region=region, projection="X4i", style="c0.2c", color="red", frame="afg"+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            y=data[:, 0],+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+    # Should also fail if given too much data+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            x=data[:, 0],+            y=data[:, 1],+            z=data[:, 2],+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color="red",+            frame="afg",+        )+++def test_plot3d_fail_size_color(data, region):+    "Should raise an exception if array sizes and color are used with matrix"+    fig = Figure()+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="c0.2c",+            color=data[:, 2],+            frame="afg",+        )+    with pytest.raises(GMTInvalidInput):+        fig.plot3d(+            data=data,+            region=region,+            projection="X4i",+            style="cc",+            sizes=data[:, 2],+            color="red",+            frame="afg",+        )+++@check_figures_equal()+def test_plot3d_projection(data, region):+    "Plot the data in green squares with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="R270/4i",+        S="s1c",+        G="green",+        B=["ag", "zag"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        region=region,+        projection="R270/4i",+        style="s1c",+        color="green",+        frame=["ag", "zag"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors(data, region):+    "Plot the data using z as colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        G="+z",+        R="/".join(map(str, region)),+        J="X3i",+        S="c0.5c",+        C="cubhelix",+        B=["afg", "zafg"],+        i="0,1,2,2",+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        region=region,+        projection="X3i",+        style="c0.5c",+        cmap="cubhelix",+        frame=["afg", "zafg"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_sizes(data, region):+    "Plot the data using z as sizes"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X4i",+        S="cc",+        G="blue",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X4i",+        style="cc",+        color="blue",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes(data, region):+    "Plot the data using z as sizes and colors"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        i="0,1,2,2,2+s0.5",+        R="/".join(map(str, region)),+        J="X3i",+        S="cc",+        C="copper",+        B=["af", "zaf"],+    )+    fig_test.plot3d(+        x=data[:, 0],+        y=data[:, 1],+        z=data[:, 2],+        zscale=5,+        perspective=[225, 30],+        color=data[:, 2],+        sizes=0.5 * data[:, 2],+        region=region,+        projection="X3i",+        style="cc",+        cmap="copper",+        frame=["af", "zaf"],+    )+    return fig_ref, fig_test+++@check_figures_equal()+def test_plot3d_colors_sizes_proj(data, region):+    "Plot the data using z as sizes and colors with a projection"+    fig_ref, fig_test = Figure(), Figure()+    fig_ref.plot3d(+        data=POINTS_DATA,+        Jz=5,+        p="225/30",+        R="/".join(map(str, region)),+        J="M10i",+        B=["af", "zaf"],+        G="+z",+        i="0,1,2,2,2+s1",

We should upload the testing directory (tmp-test-dir-with-unique-name) as an artifact (https://github.com/actions/upload-artifact) if the testing fails.

weiji14

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

 def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):                 arg_str = " ".join([fname, build_arg_string(kwargs)])                 lib.call_module("plot", arg_str) +    @fmt_docstring+    @use_alias(+        A="straight_line",+        B="frame",+        C="cmap",+        D="offset",+        G="color",+        I="intensity",+        J="projection",+        Jz="zscale",+        JZ="zsize",+        L="close",+        N="no_clip",+        Q="no_sort",+        R="region",+        S="style",+        V="verbose",+        W="pen",+        X="xshift",+        Y="yshift",+        Z="zvalue",+        i="columns",+        l="label",+        p="perspective",+        t="transparency",+    )+    @kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")+    def plot3d(+        self, x=None, y=None, z=None, data=None, sizes=None, direction=None, **kwargs+    ):+        """+        Plot lines, polygons, and symbols in 3-D++        Takes a matrix, (x,y,z) triplets, or a file name as input and plots+        lines, polygons, or symbols at those locations in 3-D.++        Must provide either *data* or *x*, *y* and *z*.++        If providing data through *x*, *y* and *z*, *color* can be a 1d array+        that will be mapped to a colormap.++        If a symbol is selected and no symbol size given, then plot3d will+        interpret the fourth column of the input data as symbol size. Symbols+        whose size is <= 0 are skipped. If no symbols are specified then the+        symbol code (see *style* below) must be present as last column in the+        input. If *style* is not used, a line connecting the data points will+        be drawn instead. To explicitly close polygons, use *close*. Select a+        fill with *color*. If *color* is set, *pen* will control whether the+        polygon outline is drawn or not. If a symbol is selected, *color* and+        *pen* determines the fill and outline/no outline, respectively.++        Full option list at :gmt-docs:`plot3d.html`++        {aliases}++        Parameters+        ----------+        x/y/z : float or 1d arrays+            The x, y, and z coordinates, or arrays of x, y and z coordinates of+            the data points+        data : str or 2d array+            Either a data file name or a 2d numpy array with the tabular data.+            Use option *columns* (i) to choose which columns are x, y, z,+            color, and size, respectively.+        sizes : 1d array+            The sizes of the data points in units specified in *style* (S).+            Only valid if using *x*, *y* and *z*.+        direction : list of two 1d arrays+            If plotting vectors (using ``style='V'`` or ``style='v'``), then+            should be a list of two 1d arrays with the vector directions. These+            can be angle and length, azimuth and length, or x and y components,+            depending on the style options chosen.+        {J}+        zscale/zsize : float or str+            Set z-axis scaling or z-axis size.+        {R}+        straight_line : bool or str+            ``[m|p|x|y]``.+            By default, geographic line segments are drawn as great circle+            arcs. To draw them as straight lines, use *straight_line*.+            Alternatively, add **m** to draw the line by first following a+            meridian, then a parallel. Or append **p** to start following a+            parallel, then a meridian. (This can be practical to draw a line+            along parallels, for example). For Cartesian data, points are+            simply connected, unless you append **x** or **y** to draw+            stair-case curves that whose first move is along *x* or *y*,+            respectively. **Note**: The **straight_line** option requires+            constant *z*-coordinates.+        {B}+        {CPT}+        offset : str+            ``dx/dy[/dz]``.+            Offset the plot symbol or line locations by the given amounts+            *dx/dy*[*dz*] [Default is no offset].+        {G}+        intensity : float or bool+            Provide an *intens* value (nominally in the -1 to +1 range) to+            modulate the fill color by simulating illumination [None]. If+            using ``intensity=True``, we will instead read *intens* from the+            first data column after the symbol parameters (if given).+        close : str+            ``[+b|d|D][+xl|r|x0][+yl|r|y0][+ppen]``.+            Force closed polygons. Full documentation is at+            :gmt-docs:`plot3d.html#l`.+        no_clip : bool or str+            ``[c|r]``.+            Do NOT clip symbols that fall outside map border [Default plots+            points whose coordinates are strictly inside the map border only].+            The option does not apply to lines and polygons which are always+            clipped to the map region. For periodic (360-longitude) maps we+            must plot all symbols twice in case they are clipped by the+            repeating boundary. ``no_clip=True`` will turn off clipping and not+            plot repeating symbols. Use ``no_clip="r"`` to turn off clipping+            but retain the plotting of such repeating symbols, or use+            ``no_clip="c"`` to retain clipping but turn off plotting of+            repeating symbols.+        no_sort : bool+            Turn off the automatic sorting of items based on their distance+            from the viewer. The default is to sort the items so that items in+            the foreground are plotted after items in the background.+        style : str+            Plot symbols. Full documentation is at :gmt-docs:`plot3d.html#s`.+        {U}+        {V}+        {W}+        {XY}+        zvalue : str+            ``value|file``.+            Instead of specifying a symbol or polygon fill and outline color+            via **color** and **pen**, give both a *value* via **zvalue** and a+            color lookup table via **cmap**.  Alternatively, give the name of a+            *file* with one z-value (read from the last column) for each+            polygon in the input data. To apply it to the fill color, use+            ``color='+z'``. To apply it to the pen color, append **+z** to+            **pen**.+        label : str+            Add a legend entry for the symbol or line being plotted.+        {p}+        {t}+            *transparency* can also be a 1d array to set varying transparency+            for symbols.++        """+        kwargs = self._preprocess(**kwargs)++        kind = data_kind(data, x, y, z)++        extra_arrays = []+        if "S" in kwargs and kwargs["S"][0] in "vV" and direction is not None:+            extra_arrays.extend(direction)+        if "G" in kwargs and not isinstance(kwargs["G"], str):+            if kind != "vectors":+                raise GMTInvalidInput(+                    "Can't use arrays for color if data is matrix or file."+                )+            extra_arrays.append(kwargs["G"])+            del kwargs["G"]+        if sizes is not None:+            if kind != "vectors":+                raise GMTInvalidInput(+                    "Can't use arrays for sizes if data is matrix or file."+                )+            extra_arrays.append(sizes)+

Great!

weiji14

comment created time in 2 days

PullRequestReviewEvent

push eventGenericMappingTools/gmt

AzurePipelines

commit sha 965da37b726248341c8cdb921ce9e80779150491

Deploy documentation from Azure Pipelines

view details

push time in 2 days

push eventGenericMappingTools/gmt

AzurePipelines

commit sha 58725d46b254be64e113066a62a413d98389c380

Deploy documentation from Azure Pipelines

view details

push time in 2 days

push eventGenericMappingTools/gmt

AzurePipelines

commit sha 64a294468093e21da9523ef016dca65adede7b72

Deploy documentation from Azure Pipelines

view details

push time in 2 days

delete branch GenericMappingTools/gmt

delete branch : fix-sphinx

delete time in 3 days

push eventGenericMappingTools/gmt

Dongdong Tian

commit sha 097bd4edb0b36783e92f799988da8d2ff626afd3

CI: Improve the way to add Sphinx to PATH (#4383) The old way has the Python version hard-coded, thus it will break when new Python version is available. The new way is more flexible and works for any Python versions.

view details

push time in 3 days

PR merged GenericMappingTools/gmt

CI: Improve the way to add Sphinx to PATH on macOS

Description of proposed changes

The old way has the Python version hard-coded, thus it will break when new Python version is available.

The new way is more flexible and works for any Python versions.

Reminders

  • [ ] Make sure that your code follows our style. Use the other functions/files as a basis.
  • [ ] Add tests for new features or tests that would have caught the bug that you're fixing.
  • [ ] Describe changes to function behavior and arguments in a comment below the function declaration.
  • [ ] If adding new functionality, add a detailed description to the documentation and/or an example.
+1 -1

0 comment

1 changed file

seisman

pr closed time in 3 days

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

 def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):                 arg_str = " ".join([fname, build_arg_string(kwargs)])                 lib.call_module("plot", arg_str) +    @fmt_docstring+    @use_alias(+        A="straight_line",+        B="frame",+        C="cmap",+        D="offset",+        G="color",+        I="intensity",+        J="projection",+        Jz="zscale",+        JZ="zsize",+        L="close",+        N="no_clip",+        Q="no_sort",+        R="region",+        S="style",+        V="verbose",+        W="pen",+        X="xshift",+        Y="yshift",+        i="columns",

I just saw that you also used columns in the tests. Perhaps it's OK to add it, and then break the backward compatibility with plot().

weiji14

comment created time in 3 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

 def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):                 arg_str = " ".join([fname, build_arg_string(kwargs)])                 lib.call_module("plot", arg_str) +    @fmt_docstring+    @use_alias(+        A="straight_line",+        B="frame",+        C="cmap",+        D="offset",+        G="color",+        I="intensity",+        J="projection",+        Jz="zscale",+        JZ="zsize",+        L="close",+        N="no_clip",+        Q="no_sort",+        R="region",+        S="style",+        V="verbose",+        W="pen",+        X="xshift",+        Y="yshift",+        i="columns",

Let's not add it the plot3d.

weiji14

comment created time in 3 days

Pull request review commentGenericMappingTools/pygmt

Wrap plot3d

 def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):                 arg_str = " ".join([fname, build_arg_string(kwargs)])                 lib.call_module("plot", arg_str) +    @fmt_docstring+    @use_alias(+        A="straight_line",+        B="frame",+        C="cmap",+        D="offset",+        G="color",+        I="intensity",+        J="projection",+        Jz="zscale",+        JZ="zsize",+        L="close",+        N="no_clip",+        Q="no_sort",+        R="region",+        S="style",+        V="verbose",+        W="pen",+        X="xshift",+        Y="yshift",+        Z="zvalue",+        i="columns",+        l="label",+        p="perspective",+        t="transparency",+    )+    @kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")+    def plot3d(+        self, x=None, y=None, z=None, data=None, sizes=None, direction=None, **kwargs+    ):+        """+        Plot lines, polygons, and symbols in 3-D++        Takes a matrix, (x,y,z) triplets, or a file name as input and plots+        lines, polygons, or symbols at those locations in 3-D.++        Must provide either *data* or *x*, *y* and *z*.++        If providing data through *x*, *y* and *z*, *color* can be a 1d array+        that will be mapped to a colormap.++        If a symbol is selected and no symbol size given, then plot3d will+        interpret the fourth column of the input data as symbol size. Symbols+        whose size is <= 0 are skipped. If no symbols are specified then the+        symbol code (see *style* below) must be present as last column in the+        input. If *style* is not used, a line connecting the data points will+        be drawn instead. To explicitly close polygons, use *close*. Select a+        fill with *color*. If *color* is set, *pen* will control whether the+        polygon outline is drawn or not. If a symbol is selected, *color* and+        *pen* determines the fill and outline/no outline, respectively.++        Full option list at :gmt-docs:`plot3d.html`++        {aliases}++        Parameters+        ----------+        x/y/z : float or 1d arrays+            The x, y, and z coordinates, or arrays of x, y and z coordinates of+            the data points+        data : str or 2d array+            Either a data file name or a 2d numpy array with the tabular data.+            Use option *columns* (i) to choose which columns are x, y, z,+            color, and size, respectively.+        sizes : 1d array+            The sizes of the data points in units specified in *style* (S).+            Only valid if using *x*, *y* and *z*.+        direction : list of two 1d arrays+            If plotting vectors (using ``style='V'`` or ``style='v'``), then+            should be a list of two 1d arrays with the vector directions. These+            can be angle and length, azimuth and length, or x and y components,+            depending on the style options chosen.+        {J}+        zscale/zsize : float or str+            Set z-axis scaling or z-axis size.+        {R}+        straight_line : bool or str+            ``[m|p|x|y]``.+            By default, geographic line segments are drawn as great circle+            arcs. To draw them as straight lines, use *straight_line*.+            Alternatively, add **m** to draw the line by first following a+            meridian, then a parallel. Or append **p** to start following a+            parallel, then a meridian. (This can be practical to draw a line+            along parallels, for example). For Cartesian data, points are+            simply connected, unless you append **x** or **y** to draw+            stair-case curves that whose first move is along *x* or *y*,+            respectively. **Note**: The **straight_line** option requires+            constant *z*-coordinates.+        {B}+        {CPT}+        offset : str+            ``dx/dy[/dz]``.+            Offset the plot symbol or line locations by the given amounts+            *dx/dy*[*dz*] [Default is no offset].+        {G}+        intensity : float or bool+            Provide an *intens* value (nominally in the -1 to +1 range) to+            modulate the fill color by simulating illumination [None]. If+            using ``intensity=True``, we will instead read *intens* from the+            first data column after the symbol parameters (if given).+        close : str+            ``[+b|d|D][+xl|r|x0][+yl|r|y0][+ppen]``.+            Force closed polygons. Full documentation is at+            :gmt-docs:`plot3d.html#l`.+        no_clip : bool or str+            ``[c|r]``.+            Do NOT clip symbols that fall outside map border [Default plots+            points whose coordinates are strictly inside the map border only].+            The option does not apply to lines and polygons which are always+            clipped to the map region. For periodic (360-longitude) maps we+            must plot all symbols twice in case they are clipped by the+            repeating boundary. ``no_clip=True`` will turn off clipping and not+            plot repeating symbols. Use ``no_clip="r"`` to turn off clipping+            but retain the plotting of such repeating symbols, or use+            ``no_clip="c"`` to retain clipping but turn off plotting of+            repeating symbols.+        no_sort : bool+            Turn off the automatic sorting of items based on their distance+            from the viewer. The default is to sort the items so that items in+            the foreground are plotted after items in the background.+        style : str+            Plot symbols. Full documentation is at :gmt-docs:`plot3d.html#s`.+        {U}+        {V}+        {W}+        {XY}+        zvalue : str+            ``value|file``.+            Instead of specifying a symbol or polygon fill and outline color+            via **color** and **pen**, give both a *value* via **zvalue** and a+            color lookup table via **cmap**.  Alternatively, give the name of a+            *file* with one z-value (read from the last column) for each+            polygon in the input data. To apply it to the fill color, use+            ``color='+z'``. To apply it to the pen color, append **+z** to+            **pen**.+        label : str+            Add a legend entry for the symbol or line being plotted.+        {p}+        {t}+            *transparency* can also be a 1d array to set varying transparency+            for symbols.++        """+        kwargs = self._preprocess(**kwargs)++        kind = data_kind(data, x, y, z)++        extra_arrays = []+        if "S" in kwargs and kwargs["S"][0] in "vV" and direction is not None:+            extra_arrays.extend(direction)+        if "G" in kwargs and not isinstance(kwargs["G"], str):+            if kind != "vectors":+                raise GMTInvalidInput(+                    "Can't use arrays for color if data is matrix or file."+                )+            extra_arrays.append(kwargs["G"])+            del kwargs["G"]+        if sizes is not None:+            if kind != "vectors":+                raise GMTInvalidInput(+                    "Can't use arrays for sizes if data is matrix or file."+                )+            extra_arrays.append(sizes)+

Do you want to add the record-by-record transparency feature (#615) following #626? It's OK if you want to do it in a separate PR.

weiji14

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

push eventGenericMappingTools/gmt

Dongdong Tian

commit sha a94a5e81f2e291ccb601749a5accc30ceb794199

CI: Improve the way to add Sphinx to PATH The old way has the Python version hard-coded, thus it will break when new Python version is available. The new way is more flexible and works for any Python versions.

view details

push time in 3 days

push eventGenericMappingTools/gmt

Dongdong Tian

commit sha 35638327fbbfee8f25cd2a6cb06cea6e43b3fae1

Better way to add sphinx to bin

view details

push time in 3 days

push eventGenericMappingTools/gmt

Dongdong Tian

commit sha cc7d5aa76cbb204ea857098c0fe4bcd1752d7aa6

Try Python 3

view details

push time in 3 days

PR opened GenericMappingTools/gmt

WIP: Fix Sphinx PATH on macOS

Description of proposed changes

<!-- Please describe changes proposed and why you made them. If unsure, open an issue first so we can discuss.-->

<!-- If fixing an issue, put the issue number after the # below (no spaces). Github will automatically close it when this gets merged. --> Fixes #

Reminders

  • [ ] Make sure that your code follows our style. Use the other functions/files as a basis.
  • [ ] Add tests for new features or tests that would have caught the bug that you're fixing.
  • [ ] Describe changes to function behavior and arguments in a comment below the function declaration.
  • [ ] If adding new functionality, add a detailed description to the documentation and/or an example.
+4 -2

0 comment

2 changed files

pr created time in 3 days

create barnchGenericMappingTools/gmt

branch : fix-sphinx

created branch time in 3 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`+"""++import pygmt++########################################################################################+# Configuring default GMT parameters+# ----------------------------------+#+# The user can override default parameters either temporarily (locally) or permanently+# (globally) using :meth:`pygmt.config`. The full list of default parameters that can be+# changed can be at :gmt-docs:`gmt.conf.html`.+#+# We demonstrate the usage of :meth:`pygmt.config` by configuring a map plot.++# Start with a basic figure+fig = pygmt.Figure()+fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Globally overriding defaults+# ----------------------------+#+# The ``MAP_FRAME_TYPE`` parameter specifies the style of map frame to use, of which there+# are 5 options: ``fancy`` (default, seen above), ``fancy+``, ``plain``, ``graph``+# (which does not apply to geographical maps) and ``inside``.+#+# The ``FORMAT_GEO_MAP`` parameter controls the format of geographical tick annotations.+# The default uses degrees and minutes. Here we specify the ticks to be a decimal number+# of degrees.++fig = pygmt.Figure()++# Configuration for the 'current figure'.+pygmt.config(MAP_FRAME_TYPE="plain")+pygmt.config(FORMAT_GEO_MAP="ddd.xx")++fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Locally overriding defaults+# ---------------------------+#+# It is also possible to temporarily override the default parameters, which is a very+# useful for limiting the scope of changes to a particular plot. :class:`pygmt.config` is+# implemented as a context manager, which handles the setup and teardown of a GMT+# session. Python users are likely familiar with the `with open(...) as file:` snippet,+# which returns a `file` context manager. In this way, it can be used to override a parameter+# for a single command, or a sequence of commands. An application of `pygmt.config` as a context
# for a single command, or a sequence of commands. An application of ``pygmt.config`` as a context
hemmelig

comment created time in 3 days

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`+"""++import pygmt++########################################################################################+# Configuring default GMT parameters+# ----------------------------------+#+# The user can override default parameters either temporarily (locally) or permanently+# (globally) using :meth:`pygmt.config`. The full list of default parameters that can be+# changed can be at :gmt-docs:`gmt.conf.html`.+#+# We demonstrate the usage of :meth:`pygmt.config` by configuring a map plot.++# Start with a basic figure+fig = pygmt.Figure()+fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Globally overriding defaults+# ----------------------------+#+# The ``MAP_FRAME_TYPE`` parameter specifies the style of map frame to use, of which there+# are 5 options: ``fancy`` (default, seen above), ``fancy+``, ``plain``, ``graph``+# (which does not apply to geographical maps) and ``inside``.+#+# The ``FORMAT_GEO_MAP`` parameter controls the format of geographical tick annotations.+# The default uses degrees and minutes. Here we specify the ticks to be a decimal number+# of degrees.++fig = pygmt.Figure()++# Configuration for the 'current figure'.+pygmt.config(MAP_FRAME_TYPE="plain")+pygmt.config(FORMAT_GEO_MAP="ddd.xx")++fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Locally overriding defaults+# ---------------------------+#+# It is also possible to temporarily override the default parameters, which is a very+# useful for limiting the scope of changes to a particular plot. :class:`pygmt.config` is+# implemented as a context manager, which handles the setup and teardown of a GMT+# session. Python users are likely familiar with the `with open(...) as file:` snippet,+# which returns a `file` context manager. In this way, it can be used to override a parameter
# which returns a ``file`` context manager. In this way, it can be used to override a parameter
hemmelig

comment created time in 3 days

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`+"""++import pygmt++########################################################################################+# Configuring default GMT parameters+# ----------------------------------+#+# The user can override default parameters either temporarily (locally) or permanently+# (globally) using :meth:`pygmt.config`. The full list of default parameters that can be+# changed can be at :gmt-docs:`gmt.conf.html`.+#+# We demonstrate the usage of :meth:`pygmt.config` by configuring a map plot.++# Start with a basic figure+fig = pygmt.Figure()+fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Globally overriding defaults+# ----------------------------+#+# The ``MAP_FRAME_TYPE`` parameter specifies the style of map frame to use, of which there+# are 5 options: ``fancy`` (default, seen above), ``fancy+``, ``plain``, ``graph``+# (which does not apply to geographical maps) and ``inside``.+#+# The ``FORMAT_GEO_MAP`` parameter controls the format of geographical tick annotations.+# The default uses degrees and minutes. Here we specify the ticks to be a decimal number+# of degrees.++fig = pygmt.Figure()++# Configuration for the 'current figure'.+pygmt.config(MAP_FRAME_TYPE="plain")+pygmt.config(FORMAT_GEO_MAP="ddd.xx")++fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Locally overriding defaults+# ---------------------------+#+# It is also possible to temporarily override the default parameters, which is a very+# useful for limiting the scope of changes to a particular plot. :class:`pygmt.config` is+# implemented as a context manager, which handles the setup and teardown of a GMT+# session. Python users are likely familiar with the `with open(...) as file:` snippet,+# which returns a `file` context manager. In this way, it can be used to override a parameter+# for a single command, or a sequence of commands. An application of `pygmt.config` as a context+# manager is shown below:++fig = pygmt.Figure()++# This will have a fancy+ frame+with pygmt.config(MAP_FRAME_TYPE="fancy+"):+    fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++# This figure retains the default "fancy" frame+fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", Y="-10c", frame=True)+fig.coast(land="black", water="skyblue")
# shift plot origin to plot another map
fig.shift_origin(yshift="-10c")  

# This figure retains the default "fancy" frame
fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)
fig.coast(land="black", water="skyblue")

I feel that using Figure.shift_origin() is easier to understand.

hemmelig

comment created time in 3 days

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`+"""++import pygmt++########################################################################################+# Configuring default GMT parameters+# ----------------------------------+#+# The user can override default parameters either temporarily (locally) or permanently+# (globally) using :meth:`pygmt.config`. The full list of default parameters that can be+# changed can be at :gmt-docs:`gmt.conf.html`.+#+# We demonstrate the usage of :meth:`pygmt.config` by configuring a map plot.++# Start with a basic figure+fig = pygmt.Figure()+fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Globally overriding defaults+# ----------------------------+#+# The ``MAP_FRAME_TYPE`` parameter specifies the style of map frame to use, of which there+# are 5 options: ``fancy`` (default, seen above), ``fancy+``, ``plain``, ``graph``+# (which does not apply to geographical maps) and ``inside``.+#+# The ``FORMAT_GEO_MAP`` parameter controls the format of geographical tick annotations.+# The default uses degrees and minutes. Here we specify the ticks to be a decimal number+# of degrees.++fig = pygmt.Figure()++# Configuration for the 'current figure'.+pygmt.config(MAP_FRAME_TYPE="plain")+pygmt.config(FORMAT_GEO_MAP="ddd.xx")++fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Locally overriding defaults+# ---------------------------+#+# It is also possible to temporarily override the default parameters, which is a very+# useful for limiting the scope of changes to a particular plot. :class:`pygmt.config` is+# implemented as a context manager, which handles the setup and teardown of a GMT+# session. Python users are likely familiar with the `with open(...) as file:` snippet,

It's reST syntax, not markdown. So we should use double backticks for inline codes:

# session. Python users are likely familiar with the ``with open(...) as file:`` snippet,
hemmelig

comment created time in 3 days

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`+"""++import pygmt++########################################################################################+# Configuring default GMT parameters+# ----------------------------------+#+# The user can override default parameters either temporarily (locally) or permanently+# (globally) using :meth:`pygmt.config`. The full list of default parameters that can be+# changed can be at :gmt-docs:`gmt.conf.html`.+#+# We demonstrate the usage of :meth:`pygmt.config` by configuring a map plot.++# Start with a basic figure+fig = pygmt.Figure()+fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Globally overriding defaults+# ----------------------------+#+# The ``MAP_FRAME_TYPE`` parameter specifies the style of map frame to use, of which there+# are 5 options: ``fancy`` (default, seen above), ``fancy+``, ``plain``, ``graph``+# (which does not apply to geographical maps) and ``inside``.+#+# The ``FORMAT_GEO_MAP`` parameter controls the format of geographical tick annotations.+# The default uses degrees and minutes. Here we specify the ticks to be a decimal number+# of degrees.++fig = pygmt.Figure()++# Configuration for the 'current figure'.+pygmt.config(MAP_FRAME_TYPE="plain")+pygmt.config(FORMAT_GEO_MAP="ddd.xx")++fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Locally overriding defaults+# ---------------------------+#+# It is also possible to temporarily override the default parameters, which is a very
# It is also possible to temporarily override the default parameters, which is very
hemmelig

comment created time in 3 days

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`+"""++import pygmt++########################################################################################+# Configuring default GMT parameters+# ----------------------------------+#+# The user can override default parameters either temporarily (locally) or permanently+# (globally) using :meth:`pygmt.config`. The full list of default parameters that can be+# changed can be at :gmt-docs:`gmt.conf.html`.
# changed can be found at :gmt-docs:`gmt.conf.html`.
hemmelig

comment created time in 3 days

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`+"""++import pygmt++########################################################################################+# Configuring default GMT parameters+# ----------------------------------+#+# The user can override default parameters either temporarily (locally) or permanently
# Users can override default parameters either temporarily (locally) or permanently
hemmelig

comment created time in 3 days

PullRequestReviewEvent

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`
Default GMT parameters can be set globally or locally using :class:`pygmt.config`.
hemmelig

comment created time in 3 days

PullRequestReviewEvent

issue commentGenericMappingTools/gmt

Add figures to examples of the docs

I'm guessing that @PaulWessel and @joa-quim may be unaware of the sphinx_gmt extension.

Should I proceed to add the figures in the docs?

Of course, you can. I just want to take the opportunity to have more discussions about how to add example images into the documentation. Apparently, there are two different ways to do that:

  1. the classic way: add the scripts and images to the doc/scripts directory
  2. the "modern" way: use the sphinx_gmt extension.

Each way has its pros and cons (see my previous comment). I prefer the "modern" way, but let's hear what @PaulWessel, @joa-quim, and other contributors think.

Esteban82

comment created time in 3 days

push eventseisman/HinetPy

Dongdong Tian

commit sha 93e4343305016130eddd0254e4569256a63bb8be

fix: include_unknown_mag does not work in get_event_waveform()

view details

push time in 3 days

Pull request review commentGenericMappingTools/pygmt

Tutorial covering pygmt.config

+"""+Configuring PyGMT defaults+==========================++Default GMT parameters can be set globally or locally using :class:`pygmt.config`+"""++import pygmt++########################################################################################+# Configuring default GMT parameters+# ----------------------------------+#+# The user can override default parameters either temporarily (locally) or permanently+# (globally) using :meth:`pygmt.config`. The full list of default parameters that can be+# changed can be at :gmt-docs:`gmt.conf.html`.+#+# We demonstrate the usage of :meth:`pygmt.config` by configuring a map plot.++# Start with a basic figure+fig = pygmt.Figure()+fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Globally overriding defaults+# ----------------------------+#+# The ``MAP_FRAME_TYPE`` parameter specifies the style of map frame to use, of which there+# are 3 options: ``fancy`` (default, seen above), ``plain``, and ``inside``.+#+# The ``FORMAT_GEO_MAP`` parameter controls the format of geographical tick annotations.+# The default uses degrees and minutes. Here we specify the ticks to be a decimal number+# of degrees.++fig = pygmt.Figure()++# Configuration for the 'current figure'.+pygmt.config(MAP_FRAME_TYPE="plain")+pygmt.config(FORMAT_GEO_MAP="ddd.xx")++fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++fig.show()++########################################################################################+# Locally overriding defaults+# ---------------------------+#+# It is also possible to temporarily override the default parameters, which is a very+# useful for limiting the scope of changes to a particular plot. :class:`pygmt.config` is+# implemented as a context manager, which handles the setup and teardown of a GMT+# session. Python users are likely familiar with the `with open(...) as file:` snippet,+# which returns a `file` context manager. In this way, it can be used to override a parameter+# for a single command, or a sequence of commands. An application of `pygmt.config` as a context+# manager is shown below:++fig = pygmt.Figure()++# This will have a fancy frame+with pygmt.config(MAP_FRAME_TYPE="fancy"):+    fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)+fig.coast(land="black", water="skyblue")++# This figure retains the globally set plain frame+fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", Y="-10c", frame=True)+fig.coast(land="black", water="skyblue")++# Set font for a sequence of commands+with pygmt.config(FONT="14p,Helvetica-Bold,white"):+    fig.text(text="Mt Kinabalu", x=116.549, y=6.058)+    fig.text(text="Maliau Basin", x=116.913, y=4.787)+    fig.text(text="Danum Valley", x=117.743, y=4.912)

I was searching for a reasonable example to show multi-line changes

That's a good point, but as far as I can see most simple examples won't need "multi-line changes". I think it's OK to drop it now.

hemmelig

comment created time in 3 days

PullRequestReviewEvent

push eventseisman/HinetPy

Dongdong Tian

commit sha c2dfbcb911eaee27d60c34e77a965666b062eabf

Fix some lint issues

view details

push time in 3 days

push eventGenericMappingTools/gmt

AzurePipelines

commit sha 11e3a7dacd6675d78d40e5e007adfffaadb4487a

Deploy documentation from Azure Pipelines

view details

push time in 3 days

issue commentGenericMappingTools/gmt

Add figures to examples of the docs

To add one example image to the documentation, we need to add the script and the PS file in the doc/scripts directory. See that directory for other examples.


Besides that, I'd like to draw your attention to the sphinx extension sphinx_gmt developed by @leouieda and me a few years ago. With this extension, we can write GMT commands/scripts in the reST source files. When building the documentation, sphinx will run the scripts, generate the images, and insert the codes and images into the HTML documentation.

Here is an example. We can write the following script in the reST source file (gmtplot is the reST directive provided by sphinx_gmt):

image

and the HTML documentation will look like:

image

The sphinx_gmt extension supports any GMT versions, both classic and modern modes, and both bash and PyGMT scripts. Its full documentation is available at https://www.generic-mapping-tools.org/sphinx_gmt/latest/. FYI, this extension is being used in the Chinese GMT documentation (https://docs.gmt-china.org/latest/), and all images you see on that site are generated by sphinx_gmt.

Here are some pros and cons of using sphinx_gmt in the GMT documentation:

Pros:

  1. Easier to insert images into documentation
  2. No need to add the scripts and PS files into the repository, thus keep the repository size small
  3. Does not add the scripts as GMT tests, thus keep the number of GMT's tests small

Cons:

  1. Building the documentation will be slower than before, because all the images are generated during the documentation building. [For your reference, the Chinese GMT documentation has ~200 simple images, and building the documentation takes ~3 minutes. So not bad to me.].
  2. These scripts are not added into the GMT's tests so they are not tested. Thus, the images may be incorrect if the commands are wrong.
Esteban82

comment created time in 3 days

more