Skip to content

Commit 3095700

Browse files
authored
Document that a list of file names, pathlib.Path objects, URLs or remote files are supported (#3214)
1 parent a43a8c7 commit 3095700

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

examples/get_started/04_table_inputs.py

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@
44
55
Generally, PyGMT accepts two different types of data inputs: tables and grids.
66
7-
- A table is a 2-D array with rows and columns. Each column represents a
8-
different variable (e.g., *x*, *y* and *z*) and each row represents a
9-
different record.
10-
- A grid is a 2-D array of data that is regularly spaced in the x and y
11-
directions (or longitude and latitude).
12-
13-
In this tutorial, we'll focus on working with table inputs, and cover grid
14-
inputs in a separate tutorial.
15-
16-
PyGMT supports a variety of table input types that allow you to work with data
17-
in a format that suits your needs. In this tutorial, we'll explore the
18-
different table input types available in PyGMT and provide examples for each.
19-
By understanding the different table input types, you can choose the one that
20-
best fits your data and analysis needs, and work more efficiently with PyGMT.
7+
- A table is a 2-D array with rows and columns. Each column represents a different
8+
variable (e.g., *x*, *y* and *z*) and each row represents a different record.
9+
- A grid is a 2-D array of data that is regularly spaced in the x and y directions (or
10+
longitude and latitude).
11+
12+
In this tutorial, we'll focus on working with table inputs, and cover grid inputs in a
13+
separate tutorial.
14+
15+
PyGMT supports a variety of table input types that allow you to work with data in a
16+
format that suits your needs. In this tutorial, we'll explore the different table input
17+
types available in PyGMT and provide examples for each. By understanding the different
18+
table input types, you can choose the one that best fits your data and analysis needs,
19+
and work more efficiently with PyGMT.
2120
"""
2221

2322
# %%
@@ -32,10 +31,10 @@
3231
# ASCII table file
3332
# ----------------
3433
#
35-
# Most PyGMT functions/methods that accept table input data have a ``data``
36-
# parameter. The easiest way to provide table input data to PyGMT is by
37-
# specifying the file name of an ASCII table (e.g., ``data="input_data.dat"``).
38-
# This is useful when your data is stored in a separate text file.
34+
# Most PyGMT functions/methods that accept table input data have a ``data`` parameter.
35+
# The easiest way to provide table input data to PyGMT is by specifying the file name of
36+
# an ASCII table (e.g., ``data="input_data.dat"``). This is useful when your data is
37+
# stored in a separate text file.
3938

4039
# Create an example file with 3 rows and 2 columns
4140
data = np.array([[1.0, 2.0], [5.0, 4.0], [8.0, 3.0]])
@@ -51,14 +50,16 @@
5150
Path("input_data.dat").unlink()
5251

5352
# %%
54-
# Besides a plain string to a table file, the following variants are also
55-
# accepted:
53+
# Besides a plain string to a table file, the following variants are also accepted:
5654
#
5755
# - A :class:`pathlib.Path` object.
5856
# - A full URL. PyGMT will download the file to the current directory first.
59-
# - A file name prefixed with ``@`` (e.g., ``data="@input_data.dat"``), which
60-
# is a special syntax in GMT to indicate that the file is a remote file
61-
# hosted on the GMT data server.
57+
# - A file name prefixed with ``@`` (e.g., ``data="@input_data.dat"``), which is a
58+
# special syntax in GMT to indicate that the file is a remote file hosted on the GMT
59+
# data server.
60+
#
61+
# Additionally, PyGMT also supports a list of file names, :class:`pathlib.Path` objects,
62+
# URLs, or remote files, to provide more flexibility in specifying input files.
6263

6364
# %%
6465
# 2-D array: `list`, `numpy.ndarray`, and `pandas.DataFrame`
@@ -92,9 +93,9 @@
9293
# -------------------------------
9394
#
9495
# If you're working with geospatial data, you can read your data as a
95-
# :class:`geopandas.GeoDataFrame` object and pass it to the ``data``
96-
# parameter. This is useful if your data is stored in a geospatial data format
97-
# (e.g., GeoJSON, etc.) that GMT and PyGMT do not support natively.
96+
# :class:`geopandas.GeoDataFrame` object and pass it to the ``data`` parameter. This is
97+
# useful if your data is stored in a geospatial data format (e.g., GeoJSON, etc.) that
98+
# GMT and PyGMT do not support natively.
9899

99100
# Example GeoDataFrame
100101
gdf = gpd.GeoDataFrame(
@@ -114,10 +115,10 @@
114115
# Scalar values or 1-D arrays
115116
# ---------------------------
116117
#
117-
# In addition to the ``data`` parameter, some PyGMT functions/methods also
118-
# provide individual parameters (e.g., ``x`` and ``y`` for data coordinates)
119-
# which allow you to specify the data. These parameters accept individual
120-
# scalar values or 1-D arrays (lists or 1-D numpy arrays).
118+
# In addition to the ``data`` parameter, some PyGMT functions/methods also provide
119+
# individual parameters (e.g., ``x`` and ``y`` for data coordinates) which allow you to
120+
# specify the data. These parameters accept individual scalar values or 1-D arrays
121+
# (lists or 1-D numpy arrays).
121122

122123
fig = pygmt.Figure()
123124
fig.basemap(region=[0, 10, 0, 5], projection="X10c/5c", frame=True)
@@ -139,8 +140,8 @@
139140
# Conclusion
140141
# ----------
141142
#
142-
# In PyGMT, you have the flexibility to provide data in various table input
143-
# types, including file names, 2-D arrays (2-D :class:`list`,
144-
# :class:`numpy.ndarray`, :class:`pandas.DataFrames`), scalar values or a
145-
# series of 1-D arrays, and :class:`geopandas.GeoDataFrame`. Choose the input
146-
# type that best suits your data source and analysis requirements.
143+
# In PyGMT, you have the flexibility to provide data in various table input types,
144+
# including file names, 2-D arrays (2-D :class:`list`, :class:`numpy.ndarray`,
145+
# :class:`pandas.DataFrames`), scalar values or a series of 1-D arrays, and
146+
# :class:`geopandas.GeoDataFrame`. Choose the input type that best suits your data
147+
# source and analysis requirements.

0 commit comments

Comments
 (0)