Skip to content

Commit 5a4731f

Browse files
Meghan Jonesseismanweiji14
authored
Improve docstring of x2sys_init and x2sys_cross (#930)
Co-authored-by: Dongdong Tian <[email protected]> Co-authored-by: Wei Ji <[email protected]>
1 parent 1e451cc commit 5a4731f

File tree

1 file changed

+56
-52
lines changed

1 file changed

+56
-52
lines changed

pygmt/x2sys.py

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,15 @@ def x2sys_init(tag, **kwargs):
7272
r"""
7373
Initialize a new x2sys track database.
7474
75-
x2sys_init is the starting point for anyone wishing to use x2sys; it
76-
initializes a set of data bases that are particular to one kind of track
77-
data. These data, their associated data bases, and key parameters are given
78-
a short-hand notation called an x2sys TAG. The TAG keeps track of settings
79-
such as file format, whether the data are geographic or not, and the
80-
binning resolution for track indices.
75+
Serves as the starting point for x2sys and initializes a set of data bases
76+
that are particular to one kind of track data. These data, their associated
77+
data bases, and key parameters are given a short-hand notation called an
78+
x2sys TAG. The TAG keeps track of settings such as file format, whether the
79+
data are geographic or not, and the binning resolution for track indices.
8180
82-
Before you can run x2sys_init you must set the environmental parameter
83-
X2SYS_HOME to a directory where you have write permission, which is where
84-
x2sys can keep track of your settings.
81+
Before you can run :meth:`pygmt.x2sys_init` you must set the environmental
82+
parameter X2SYS_HOME to a directory where you have write permission, which
83+
is where x2sys can keep track of your settings.
8584
8685
Full option list at :gmt-docs:`supplements/x2sys/x2sys_init.html`
8786
@@ -93,68 +92,69 @@ def x2sys_init(tag, **kwargs):
9392
The unique name of this data type x2sys TAG.
9493
9594
fmtfile : str
96-
Format definition file prefix for this data set [See Format Definition
97-
Files for more information]. Specify full path if the file is not in
98-
the current directory.
95+
Format definition file prefix for this data set (see
96+
:gmt-docs:`GMT's Format Definition Files
97+
<supplements/x2sys/x2sys_init.html#format-definition-files>`
98+
for more information). Specify full path if the file is not in the
99+
current directory.
99100
100101
Some file formats already have definition files premade. These include:
101102
102-
- mgd77 (for plain ASCII MGD77 data files)
103-
- mgd77+ (for enhanced MGD77+ netCDF files)
104-
- gmt (for old mgg supplement binary files)
105-
- xy (for plain ASCII x, y tables)
106-
- xyz (same, with one z-column)
107-
- geo (for plain ASCII longitude, latitude files)
108-
- geoz (same, with one z-column).
103+
- **mgd77** (for plain ASCII MGD77 data files)
104+
- **mgd77+** (for enhanced MGD77+ netCDF files)
105+
- **gmt** (for old mgg supplement binary files)
106+
- **xy** (for plain ASCII x, y tables)
107+
- **xyz** (same, with one z-column)
108+
- **geo** (for plain ASCII longitude, latitude files)
109+
- **geoz** (same, with one z-column).
109110
110111
suffix : str
111112
Specifies the file extension (suffix) for these data files. If not
112113
given we use the format definition file prefix as the suffix (see
113-
*fmtfile*).
114+
``fmtfile``).
114115
115116
discontinuity : str
116117
**d**\|\ **g**.
117118
Selects geographical coordinates. Append **d** for discontinuity at the
118-
Dateline (makes longitude go from -180 to + 180) or **g** for
119+
Dateline (makes longitude go from -180 to +180) or **g** for
119120
discontinuity at Greenwich (makes longitude go from 0 to 360
120121
[Default]). If not given we assume the data are Cartesian.
121122
122123
spacing : str or list
123124
*dx*\[/*dy*].
124-
*dx* [and optionally *dy*] is the grid spacing. Append **m** to
125+
*dx* and optionally *dy* is the grid spacing. Append **m** to
125126
indicate minutes or **s** to indicate seconds for geographic data.
126127
These spacings refer to the binning used in the track bin-index data
127128
base.
128129
129130
units : str or list
130-
**d**\|\ **s**\
131-
**c**\|\ **e**\|\ **f**\|\ **k**\|\ **m**\|\ **n**\|\ **u** .
131+
**d**\|\ **s**\ *unit*.
132132
Sets the units used for distance and speed when requested by other
133133
programs. Append **d** for distance or **s** for speed, then give the
134-
desired unit as:
134+
desired *unit* as:
135135
136136
- **c** - Cartesian userdist or userdist/usertime
137137
- **e** - meters or m/s
138138
- **f** - feet or feet/s
139-
- **k** - km or kms/hr
139+
- **k** - km or km/hr
140140
- **m** - miles or miles/hr
141141
- **n** - nautical miles or knots
142142
- **u** - survey feet or survey feet/s
143143
144-
Default is ``units=["dk", "se"]`` (km and m/s) if *discontinuity* is
145-
set, and ``units=["dc", "sc"]`` otherwise (Cartesian units).
144+
[Default is ``units=["dk", "se"]`` (km and m/s) if ``discontinuity`` is
145+
set, and ``units=["dc", "sc"]`` otherwise (e.g., for Cartesian units)].
146146
147147
{R}
148148
{V}
149149
150150
gap : str or list
151151
**t**\|\ **d**\ *gap*.
152152
Give **t** or **d** and append the corresponding maximum time gap (in
153-
user units; this is typically seconds [Infinity]), or distance (for
154-
units, see ``units``) gap [Default is infinity]) allowed between the
155-
two data points immediately on either side of a crossover. If these
156-
limits are exceeded then a data gap is assumed and no COE will be
157-
determined.
153+
user units; this is typically seconds [Default is infinity]), or
154+
distance (for units, see ``units``) gap [Default is infinity]) allowed
155+
between the two data points immediately on either side of a crossover.
156+
If these limits are exceeded then a data gap is assumed and no COE will
157+
be determined.
158158
159159
{j}
160160
"""
@@ -182,13 +182,13 @@ def x2sys_cross(tracks=None, outfile=None, **kwargs):
182182
r"""
183183
Calculate crossovers between track data files.
184184
185-
x2sys_cross is used to determine all intersections between ("external
186-
cross-overs") or within ("internal cross-overs") tracks (Cartesian or
187-
geographic), and report the time, position, distance along track, heading
188-
and speed along each track segment, and the crossover error (COE) and mean
189-
values for all observables. By default, x2sys_cross will look for both
190-
external and internal COEs. As an option, you may choose to project all
191-
data using one of the map-projections prior to calculating the COE.
185+
Determines all intersections between ("external cross-overs") or within
186+
("internal cross-overs") tracks (Cartesian or geographic), and report the
187+
time, position, distance along track, heading and speed along each track
188+
segment, and the crossover error (COE) and mean values for all observables.
189+
By default, :meth:`pygmt.x2sys_cross` will look for both external and
190+
internal COEs. As an option, you may choose to project all data using one
191+
of the map projections prior to calculating the COE.
192192
193193
Full option list at :gmt-docs:`supplements/x2sys/x2sys_cross.html`
194194
@@ -207,7 +207,7 @@ def x2sys_cross(tracks=None, outfile=None, **kwargs):
207207
in the current directory and second in all directories listed in
208208
$X2SYS_HOME/TAG/TAG_paths.txt (if it exists). [If $X2SYS_HOME is not
209209
set it will default to $GMT_SHAREDIR/x2sys]. (Note: MGD77 files will
210-
also be looked for via $MGD77_HOME/mgd77_paths.txt and \\*.gmt files
210+
also be looked for via $MGD77_HOME/mgd77_paths.txt and .gmt files
211211
will be searched for via $GMT_SHAREDIR/mgg/gmtfile_paths).
212212
213213
outfile : str
@@ -221,7 +221,8 @@ def x2sys_cross(tracks=None, outfile=None, **kwargs):
221221
combitable : str
222222
Only process the pair-combinations found in the file *combitable*
223223
[Default process all possible combinations among the specified files].
224-
The file *combitable* is created by *x2sys_get*'s -L option
224+
The file *combitable* is created by :gmt-docs:`x2sys_get's -L option
225+
<supplements/x2sys/x2sys_get.html#l>`.
225226
226227
runtimes : bool or str
227228
Compute and append the processing run-time for each pair to the
@@ -230,15 +231,16 @@ def x2sys_cross(tracks=None, outfile=None, **kwargs):
230231
is to use the knowledge of run-times to split the main process in a
231232
number of sub-processes that can each be launched in a different
232233
processor of your multi-core machine. See the MATLAB function
233-
split_file4coes.m that lives in the x2sys supplement source code.
234+
`split_file4coes.m
235+
<https://github.com/GenericMappingTools/gmt/blob/master/src/x2sys/>`_.
234236
235237
override : bool or str
236238
**S**\|\ **N**.
237239
Control how geographic coordinates are handled (Cartesian data are
238240
unaffected). By default, we determine if the data are closer to one
239241
pole than the other, and then we use a cylindrical polar conversion to
240242
avoid problems with longitude jumps. You can turn this off entirely
241-
with *override* and then the calculations uses the original data (we
243+
with ``override`` and then the calculations uses the original data (we
242244
have protections against longitude jumps). However, you can force the
243245
selection of the pole for the projection by appending **S** or **N**
244246
for the south or north pole, respectively. The conversion is used
@@ -267,10 +269,10 @@ def x2sys_cross(tracks=None, outfile=None, **kwargs):
267269
not calculate a COE. Specify:
268270
269271
- **l** sets lower speed [Default is 0].
270-
- **u** sets upper speed [Default is Infinity].
271-
- **h** does not limit the speed but sets a lower speed below which \
272-
headings will not be computed (i.e., set to NaN) [Default calculates \
273-
headings regardless of speed].
272+
- **u** sets upper speed [Default is infinity].
273+
- **h** does not limit the speed but sets a lower speed below which
274+
headings will not be computed (i.e., set to NaN) [Default
275+
calculates headings regardless of speed].
274276
275277
For example, you can use ``speed=["l0", "u10", "h5"]`` to set a lower
276278
speed of 0, upper speed of 10, and disable heading calculations for
@@ -288,12 +290,14 @@ def x2sys_cross(tracks=None, outfile=None, **kwargs):
288290
289291
Returns
290292
-------
291-
crossover_errors : pandas.DataFrame or None
293+
crossover_errors : :class:`pandas.DataFrame` or None
292294
Table containing crossover error information.
293-
Return type depends on whether the outfile parameter is set:
295+
Return type depends on whether the ``outfile`` parameter is set:
294296
295-
- pandas.DataFrame table with (x, y, ..., etc) if outfile is not set
296-
- None if outfile is set (track output will be stored in outfile)
297+
- :class:`pandas.DataFrame` with (x, y, ..., etc) if ``outfile`` is not
298+
set
299+
- None if ``outfile`` is set (track output will be stored in the set in
300+
``outfile``)
297301
"""
298302
with Session() as lib:
299303
file_contexts = []

0 commit comments

Comments
 (0)