Skip to content

Commit ba879ea

Browse files
authored
Move x2sys.py to src folder and split it into x2sys_init and x2sys_cross (#951)
Move the x2sys modules originally wrapped in #546. The single x2sys.py has been separated into x2sys_init.py and x2sys_cross.py inside the src/ folder as per #807.
1 parent 5d2b34f commit ba879ea

File tree

4 files changed

+119
-111
lines changed

4 files changed

+119
-111
lines changed

pygmt/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
makecpt,
2929
surface,
3030
which,
31+
x2sys_cross,
32+
x2sys_init,
3133
)
32-
from pygmt.x2sys import x2sys_cross, x2sys_init
3334

3435
# Get semantic version through setuptools-scm
3536
__version__ = f'v{get_distribution("pygmt").version}' # e.g. v0.1.2.dev3+g0ab3cd78

pygmt/src/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@
2828
from pygmt.src.surface import surface
2929
from pygmt.src.text import text_ as text # "text" is an argument within "text_"
3030
from pygmt.src.which import which
31+
from pygmt.src.x2sys_cross import x2sys_cross
32+
from pygmt.src.x2sys_init import x2sys_init

pygmt/x2sys.py renamed to pygmt/src/x2sys_cross.py

+1-110
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
GMT supplementary X2SYS module for crossover analysis.
2+
x2sys_cross - Calculate crossovers between track data files.
33
"""
44
import contextlib
55
import os
@@ -54,115 +54,6 @@ def tempfile_from_dftrack(track, suffix):
5454
os.remove(tmpfilename)
5555

5656

57-
@fmt_docstring
58-
@use_alias(
59-
D="fmtfile",
60-
E="suffix",
61-
F="force",
62-
G="discontinuity",
63-
I="spacing",
64-
N="units",
65-
R="region",
66-
V="verbose",
67-
W="gap",
68-
j="distcalc",
69-
)
70-
@kwargs_to_strings(I="sequence", R="sequence")
71-
def x2sys_init(tag, **kwargs):
72-
r"""
73-
Initialize a new x2sys track database.
74-
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.
80-
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.
84-
85-
Full option list at :gmt-docs:`supplements/x2sys/x2sys_init.html`
86-
87-
{aliases}
88-
89-
Parameters
90-
----------
91-
tag : str
92-
The unique name of this data type x2sys TAG.
93-
94-
fmtfile : str
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.
100-
101-
Some file formats already have definition files premade. These include:
102-
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).
110-
111-
suffix : str
112-
Specifies the file extension (suffix) for these data files. If not
113-
given we use the format definition file prefix as the suffix (see
114-
``fmtfile``).
115-
116-
discontinuity : str
117-
**d**\|\ **g**.
118-
Selects geographical coordinates. Append **d** for discontinuity at the
119-
Dateline (makes longitude go from -180 to +180) or **g** for
120-
discontinuity at Greenwich (makes longitude go from 0 to 360
121-
[Default]). If not given we assume the data are Cartesian.
122-
123-
spacing : str or list
124-
*dx*\[/*dy*].
125-
*dx* and optionally *dy* is the grid spacing. Append **m** to
126-
indicate minutes or **s** to indicate seconds for geographic data.
127-
These spacings refer to the binning used in the track bin-index data
128-
base.
129-
130-
units : str or list
131-
**d**\|\ **s**\ *unit*.
132-
Sets the units used for distance and speed when requested by other
133-
programs. Append **d** for distance or **s** for speed, then give the
134-
desired *unit* as:
135-
136-
- **c** - Cartesian userdist or userdist/usertime
137-
- **e** - meters or m/s
138-
- **f** - feet or feet/s
139-
- **k** - km or km/hr
140-
- **m** - miles or miles/hr
141-
- **n** - nautical miles or knots
142-
- **u** - survey feet or survey feet/s
143-
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)].
146-
147-
{R}
148-
{V}
149-
150-
gap : str or list
151-
**t**\|\ **d**\ *gap*.
152-
Give **t** or **d** and append the corresponding maximum time gap (in
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.
158-
159-
{j}
160-
"""
161-
with Session() as lib:
162-
arg_str = " ".join([tag, build_arg_string(kwargs)])
163-
lib.call_module(module="x2sys_init", args=arg_str)
164-
165-
16657
@fmt_docstring
16758
@use_alias(
16859
A="combitable",

pygmt/src/x2sys_init.py

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
"""
2+
x2sys_init - Initialize a new x2sys track database
3+
"""
4+
from pygmt.clib import Session
5+
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias
6+
7+
8+
@fmt_docstring
9+
@use_alias(
10+
D="fmtfile",
11+
E="suffix",
12+
F="force",
13+
G="discontinuity",
14+
I="spacing",
15+
N="units",
16+
R="region",
17+
V="verbose",
18+
W="gap",
19+
j="distcalc",
20+
)
21+
@kwargs_to_strings(I="sequence", R="sequence")
22+
def x2sys_init(tag, **kwargs):
23+
r"""
24+
Initialize a new x2sys track database.
25+
26+
Serves as the starting point for x2sys and initializes a set of data bases
27+
that are particular to one kind of track data. These data, their associated
28+
data bases, and key parameters are given a short-hand notation called an
29+
x2sys TAG. The TAG keeps track of settings such as file format, whether the
30+
data are geographic or not, and the binning resolution for track indices.
31+
32+
Before you can run :meth:`pygmt.x2sys_init` you must set the environmental
33+
parameter X2SYS_HOME to a directory where you have write permission, which
34+
is where x2sys can keep track of your settings.
35+
36+
Full option list at :gmt-docs:`supplements/x2sys/x2sys_init.html`
37+
38+
{aliases}
39+
40+
Parameters
41+
----------
42+
tag : str
43+
The unique name of this data type x2sys TAG.
44+
45+
fmtfile : str
46+
Format definition file prefix for this data set (see
47+
:gmt-docs:`GMT's Format Definition Files
48+
<supplements/x2sys/x2sys_init.html#format-definition-files>`
49+
for more information). Specify full path if the file is not in the
50+
current directory.
51+
52+
Some file formats already have definition files premade. These include:
53+
54+
- **mgd77** (for plain ASCII MGD77 data files)
55+
- **mgd77+** (for enhanced MGD77+ netCDF files)
56+
- **gmt** (for old mgg supplement binary files)
57+
- **xy** (for plain ASCII x, y tables)
58+
- **xyz** (same, with one z-column)
59+
- **geo** (for plain ASCII longitude, latitude files)
60+
- **geoz** (same, with one z-column).
61+
62+
suffix : str
63+
Specifies the file extension (suffix) for these data files. If not
64+
given we use the format definition file prefix as the suffix (see
65+
``fmtfile``).
66+
67+
discontinuity : str
68+
**d**\|\ **g**.
69+
Selects geographical coordinates. Append **d** for discontinuity at the
70+
Dateline (makes longitude go from -180 to +180) or **g** for
71+
discontinuity at Greenwich (makes longitude go from 0 to 360
72+
[Default]). If not given we assume the data are Cartesian.
73+
74+
spacing : str or list
75+
*dx*\[/*dy*].
76+
*dx* and optionally *dy* is the grid spacing. Append **m** to
77+
indicate minutes or **s** to indicate seconds for geographic data.
78+
These spacings refer to the binning used in the track bin-index data
79+
base.
80+
81+
units : str or list
82+
**d**\|\ **s**\ *unit*.
83+
Sets the units used for distance and speed when requested by other
84+
programs. Append **d** for distance or **s** for speed, then give the
85+
desired *unit* as:
86+
87+
- **c** - Cartesian userdist or userdist/usertime
88+
- **e** - meters or m/s
89+
- **f** - feet or feet/s
90+
- **k** - km or km/hr
91+
- **m** - miles or miles/hr
92+
- **n** - nautical miles or knots
93+
- **u** - survey feet or survey feet/s
94+
95+
[Default is ``units=["dk", "se"]`` (km and m/s) if ``discontinuity`` is
96+
set, and ``units=["dc", "sc"]`` otherwise (e.g., for Cartesian units)].
97+
98+
{R}
99+
{V}
100+
101+
gap : str or list
102+
**t**\|\ **d**\ *gap*.
103+
Give **t** or **d** and append the corresponding maximum time gap (in
104+
user units; this is typically seconds [Default is infinity]), or
105+
distance (for units, see ``units``) gap [Default is infinity]) allowed
106+
between the two data points immediately on either side of a crossover.
107+
If these limits are exceeded then a data gap is assumed and no COE will
108+
be determined.
109+
110+
{j}
111+
"""
112+
with Session() as lib:
113+
arg_str = " ".join([tag, build_arg_string(kwargs)])
114+
lib.call_module(module="x2sys_init", args=arg_str)

0 commit comments

Comments
 (0)