Skip to content

Commit dfdd3ed

Browse files
committed
Rename virtualfile_from_data to virtualfile_in
1 parent a633abf commit dfdd3ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+59
-60
lines changed

doc/api/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,11 @@ conversion of Python variables to GMT virtual files:
288288

289289
.. autosummary::
290290
:toctree: generated
291-
292-
clib.Session.virtualfile_from_data
291+
293292
clib.Session.virtualfile_from_matrix
294293
clib.Session.virtualfile_from_vectors
295294
clib.Session.virtualfile_from_grid
295+
clib.Session.virtualfile_in
296296
clib.Session.virtualfile_out
297297

298298

pygmt/clib/session.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ def virtualfile_from_grid(self, grid):
14781478
yield vfile
14791479

14801480
@fmt_docstring
1481-
def virtualfile_from_data( # noqa: PLR0912
1481+
def virtualfile_in( # noqa: PLR0912
14821482
self,
14831483
check_kind=None,
14841484
data=None,
@@ -1535,7 +1535,7 @@ def virtualfile_from_data( # noqa: PLR0912
15351535
... ),
15361536
... )
15371537
>>> with Session() as ses:
1538-
... with ses.virtualfile_from_data(check_kind="vector", data=data) as fin:
1538+
... with ses.virtualfile_in(check_kind="vector", data=data) as fin:
15391539
... # Send the output to a file so that we can read it
15401540
... with GMTTempFile() as fout:
15411541
... ses.call_module("info", fin + " ->" + fout.name)
@@ -1609,6 +1609,9 @@ def virtualfile_from_data( # noqa: PLR0912
16091609

16101610
return file_context
16111611

1612+
# virtualfile_from_data is the old name for virtualfile_in
1613+
virtualfile_from_data = virtualfile_in
1614+
16121615
@contextlib.contextmanager
16131616
def virtualfile_out(
16141617
self, kind: Literal["dataset", "grid"] = "dataset", fname: str | None = None

pygmt/src/binstats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def binstats(data, **kwargs):
111111
"""
112112
with GMTTempFile(suffix=".nc") as tmpfile:
113113
with Session() as lib:
114-
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
114+
file_context = lib.virtualfile_in(check_kind="vector", data=data)
115115
with file_context as infile:
116116
if (outgrid := kwargs.get("G")) is None:
117117
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/blockm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _blockm(block_method, data, x, y, z, outfile, **kwargs):
4343
"""
4444
with GMTTempFile(suffix=".csv") as tmpfile:
4545
with Session() as lib:
46-
table_context = lib.virtualfile_from_data(
46+
table_context = lib.virtualfile_in(
4747
check_kind="vector", data=data, x=x, y=y, z=z, required_z=True
4848
)
4949
# Run blockm* on data table

pygmt/src/contour.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def contour(self, data=None, x=None, y=None, z=None, **kwargs):
115115
kwargs = self._preprocess(**kwargs)
116116

117117
with Session() as lib:
118-
file_context = lib.virtualfile_from_data(
118+
file_context = lib.virtualfile_in(
119119
check_kind="vector", data=data, x=x, y=y, z=z, required_z=True
120120
)
121121
with file_context as fname:

pygmt/src/dimfilter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def dimfilter(grid, **kwargs):
151151

152152
with GMTTempFile(suffix=".nc") as tmpfile:
153153
with Session() as lib:
154-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
154+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
155155
with file_context as infile:
156156
if (outgrid := kwargs.get("G")) is None:
157157
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/filter1d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def filter1d(data, output_type="pandas", outfile=None, **kwargs):
119119

120120
with GMTTempFile() as tmpfile:
121121
with Session() as lib:
122-
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
122+
file_context = lib.virtualfile_in(check_kind="vector", data=data)
123123
with file_context as infile:
124124
if outfile is None:
125125
outfile = tmpfile.name

pygmt/src/grd2cpt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def grd2cpt(grid, **kwargs):
184184
if kwargs.get("W") is not None and kwargs.get("Ww") is not None:
185185
raise GMTInvalidInput("Set only categorical or cyclic to True, not both.")
186186
with Session() as lib:
187-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
187+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
188188
with file_context as infile:
189189
if kwargs.get("H") is None: # if no output is set
190190
arg_str = build_arg_string(kwargs, infile=infile)

pygmt/src/grd2xyz.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs):
158158

159159
with GMTTempFile() as tmpfile:
160160
with Session() as lib:
161-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
161+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
162162
with file_context as infile:
163163
if outfile is None:
164164
outfile = tmpfile.name

pygmt/src/grdclip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def grdclip(grid, **kwargs):
9797
"""
9898
with GMTTempFile(suffix=".nc") as tmpfile:
9999
with Session() as lib:
100-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
100+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
101101
with file_context as infile:
102102
if (outgrid := kwargs.get("G")) is None:
103103
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/grdcontour.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def grdcontour(self, grid, **kwargs):
122122
"""
123123
kwargs = self._preprocess(**kwargs)
124124
with Session() as lib:
125-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
125+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
126126
with file_context as fname:
127127
lib.call_module(
128128
module="grdcontour", args=build_arg_string(kwargs, infile=fname)

pygmt/src/grdcut.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def grdcut(grid, **kwargs):
101101
"""
102102
with GMTTempFile(suffix=".nc") as tmpfile:
103103
with Session() as lib:
104-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
104+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
105105
with file_context as infile:
106106
if (outgrid := kwargs.get("G")) is None:
107107
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/grdfill.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def grdfill(grid, **kwargs):
7979
raise GMTInvalidInput("At least parameter 'mode' or 'L' must be specified.")
8080
with GMTTempFile(suffix=".nc") as tmpfile:
8181
with Session() as lib:
82-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
82+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
8383
with file_context as infile:
8484
if (outgrid := kwargs.get("G")) is None:
8585
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/grdfilter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def grdfilter(grid, **kwargs):
134134
"""
135135
with GMTTempFile(suffix=".nc") as tmpfile:
136136
with Session() as lib:
137-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
137+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
138138
with file_context as infile:
139139
if (outgrid := kwargs.get("G")) is None:
140140
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/grdgradient.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def grdgradient(grid, **kwargs):
169169
azimuth, direction, or radiance"""
170170
)
171171
with Session() as lib:
172-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
172+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
173173
with file_context as infile:
174174
if (outgrid := kwargs.get("G")) is None:
175175
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/grdhisteq.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _grdhisteq(grid, output_type, **kwargs):
107107
"""
108108

109109
with Session() as lib:
110-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
110+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
111111
with file_context as infile:
112112
lib.call_module(
113113
module="grdhisteq", args=build_arg_string(kwargs, infile=infile)

pygmt/src/grdimage.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ def grdimage(self, grid, **kwargs):
163163
)
164164

165165
with Session() as lib:
166-
with lib.virtualfile_from_data(
166+
with lib.virtualfile_in(
167167
check_kind="raster", data=grid
168-
) as fname, lib.virtualfile_from_data(
168+
) as fname, lib.virtualfile_in(
169169
check_kind="raster", data=kwargs.get("I"), required_data=False
170170
) as shadegrid:
171171
kwargs["I"] = shadegrid

pygmt/src/grdinfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def grdinfo(grid, **kwargs):
111111
"""
112112
with GMTTempFile() as outfile:
113113
with Session() as lib:
114-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
114+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
115115
with file_context as infile:
116116
lib.call_module(
117117
module="grdinfo",

pygmt/src/grdproject.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def grdproject(grid, **kwargs):
112112
raise GMTInvalidInput("The projection must be specified.")
113113
with GMTTempFile(suffix=".nc") as tmpfile:
114114
with Session() as lib:
115-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
115+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
116116
with file_context as infile:
117117
if (outgrid := kwargs.get("G")) is None:
118118
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/grdsample.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def grdsample(grid, **kwargs):
8989
"""
9090
with GMTTempFile(suffix=".nc") as tmpfile:
9191
with Session() as lib:
92-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
92+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
9393
with file_context as infile:
9494
if (outgrid := kwargs.get("G")) is None:
9595
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/grdtrack.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ def grdtrack(grid, points=None, newcolname=None, outfile=None, **kwargs):
292292

293293
with GMTTempFile(suffix=".csv") as tmpfile:
294294
with Session() as lib:
295-
with lib.virtualfile_from_data(
295+
with lib.virtualfile_in(
296296
check_kind="raster", data=grid
297-
) as grdfile, lib.virtualfile_from_data(
297+
) as grdfile, lib.virtualfile_in(
298298
check_kind="vector", data=points, required_data=False
299299
) as csvfile:
300300
kwargs["G"] = grdfile

pygmt/src/grdview.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def grdview(self, grid, **kwargs):
144144
"""
145145
kwargs = self._preprocess(**kwargs)
146146
with Session() as lib:
147-
with lib.virtualfile_from_data(
147+
with lib.virtualfile_in(
148148
check_kind="raster", data=grid
149-
) as fname, lib.virtualfile_from_data(
149+
) as fname, lib.virtualfile_in(
150150
check_kind="raster", data=kwargs.get("G"), required_data=False
151151
) as drapegrid:
152152
kwargs["G"] = drapegrid

pygmt/src/grdvolume.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def grdvolume(grid, output_type="pandas", outfile=None, **kwargs):
104104

105105
with GMTTempFile() as tmpfile:
106106
with Session() as lib:
107-
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)
107+
file_context = lib.virtualfile_in(check_kind="raster", data=grid)
108108
with file_context as infile:
109109
if outfile is None:
110110
outfile = tmpfile.name

pygmt/src/histogram.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def histogram(self, data, **kwargs):
134134
"""
135135
kwargs = self._preprocess(**kwargs)
136136
with Session() as lib:
137-
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
137+
file_context = lib.virtualfile_in(check_kind="vector", data=data)
138138
with file_context as infile:
139139
lib.call_module(
140140
module="histogram", args=build_arg_string(kwargs, infile=infile)

pygmt/src/info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def info(data, **kwargs):
8080
- str if none of the above parameters are used.
8181
"""
8282
with Session() as lib:
83-
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
83+
file_context = lib.virtualfile_in(check_kind="vector", data=data)
8484
with GMTTempFile() as tmpfile:
8585
with file_context as fname:
8686
lib.call_module(

pygmt/src/meca.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,6 @@ def meca( # noqa: PLR0912, PLR0913, PLR0915
488488
# Assemble -S flag
489489
kwargs["S"] = f"{data_format}{scale}"
490490
with Session() as lib:
491-
file_context = lib.virtualfile_from_data(check_kind="vector", data=spec)
491+
file_context = lib.virtualfile_in(check_kind="vector", data=spec)
492492
with file_context as fname:
493493
lib.call_module(module="meca", args=build_arg_string(kwargs, infile=fname))

pygmt/src/nearneighbor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def nearneighbor(data=None, x=None, y=None, z=None, **kwargs):
145145
"""
146146
with GMTTempFile(suffix=".nc") as tmpfile:
147147
with Session() as lib:
148-
table_context = lib.virtualfile_from_data(
148+
table_context = lib.virtualfile_in(
149149
check_kind="vector", data=data, x=x, y=y, z=z, required_z=True
150150
)
151151
with table_context as infile:

pygmt/src/plot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def plot( # noqa: PLR0912
250250
kwargs[flag] = ""
251251

252252
with Session() as lib:
253-
file_context = lib.virtualfile_from_data(
253+
file_context = lib.virtualfile_in(
254254
check_kind="vector", data=data, x=x, y=y, extra_arrays=extra_arrays
255255
)
256256

pygmt/src/plot3d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def plot3d( # noqa: PLR0912
225225
kwargs[flag] = ""
226226

227227
with Session() as lib:
228-
file_context = lib.virtualfile_from_data(
228+
file_context = lib.virtualfile_in(
229229
check_kind="vector",
230230
data=data,
231231
x=x,

pygmt/src/project.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def project(data=None, x=None, y=None, z=None, outfile=None, **kwargs):
227227
outfile = tmpfile.name
228228
with Session() as lib:
229229
if kwargs.get("G") is None:
230-
table_context = lib.virtualfile_from_data(
230+
table_context = lib.virtualfile_in(
231231
check_kind="vector", data=data, x=x, y=y, z=z, required_z=False
232232
)
233233

pygmt/src/rose.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def rose(self, data=None, length=None, azimuth=None, **kwargs):
200200
kwargs = self._preprocess(**kwargs)
201201

202202
with Session() as lib:
203-
file_context = lib.virtualfile_from_data(
203+
file_context = lib.virtualfile_in(
204204
check_kind="vector", data=data, x=length, y=azimuth
205205
)
206206

pygmt/src/select.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def select(data=None, outfile=None, **kwargs):
198198

199199
with GMTTempFile(suffix=".csv") as tmpfile:
200200
with Session() as lib:
201-
table_context = lib.virtualfile_from_data(check_kind="vector", data=data)
201+
table_context = lib.virtualfile_in(check_kind="vector", data=data)
202202
with table_context as infile:
203203
if outfile is None:
204204
outfile = tmpfile.name

pygmt/src/sph2grd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def sph2grd(data, **kwargs):
7373
"""
7474
with GMTTempFile(suffix=".nc") as tmpfile:
7575
with Session() as lib:
76-
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
76+
file_context = lib.virtualfile_in(check_kind="vector", data=data)
7777
with file_context as infile:
7878
if (outgrid := kwargs.get("G")) is None:
7979
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/sphdistance.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ def sphdistance(data=None, x=None, y=None, **kwargs):
117117
raise GMTInvalidInput("Both 'region' and 'spacing' must be specified.")
118118
with GMTTempFile(suffix=".nc") as tmpfile:
119119
with Session() as lib:
120-
file_context = lib.virtualfile_from_data(
121-
check_kind="vector", data=data, x=x, y=y
122-
)
120+
file_context = lib.virtualfile_in(check_kind="vector", data=data, x=x, y=y)
123121
with file_context as infile:
124122
if (outgrid := kwargs.get("G")) is None:
125123
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/sphinterpolate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def sphinterpolate(data, **kwargs):
6767
"""
6868
with GMTTempFile(suffix=".nc") as tmpfile:
6969
with Session() as lib:
70-
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
70+
file_context = lib.virtualfile_in(check_kind="vector", data=data)
7171
with file_context as infile:
7272
if (outgrid := kwargs.get("G")) is None:
7373
kwargs["G"] = outgrid = tmpfile.name # output to tmpfile

pygmt/src/surface.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def surface(data=None, x=None, y=None, z=None, **kwargs):
159159
"""
160160
with GMTTempFile(suffix=".nc") as tmpfile:
161161
with Session() as lib:
162-
file_context = lib.virtualfile_from_data(
162+
file_context = lib.virtualfile_in(
163163
check_kind="vector", data=data, x=x, y=y, z=z, required_z=True
164164
)
165165
with file_context as infile:

pygmt/src/ternary.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def ternary(self, data, alabel=None, blabel=None, clabel=None, **kwargs):
8686
data = data.to_numpy()
8787

8888
with Session() as lib:
89-
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
89+
file_context = lib.virtualfile_in(check_kind="vector", data=data)
9090
with file_context as infile:
9191
lib.call_module(
9292
module="ternary",

pygmt/src/text.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def text_( # noqa: PLR0912
236236
)
237237

238238
with Session() as lib:
239-
file_context = lib.virtualfile_from_data(
239+
file_context = lib.virtualfile_in(
240240
check_kind="vector", data=textfiles, x=x, y=y, extra_arrays=extra_arrays
241241
)
242242
with file_context as fname:

pygmt/src/tilemap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def tilemap(
163163
kwargs["R"] = "/".join(str(coordinate) for coordinate in region)
164164

165165
with Session() as lib:
166-
file_context = lib.virtualfile_from_data(check_kind="raster", data=raster)
166+
file_context = lib.virtualfile_in(check_kind="raster", data=raster)
167167
with file_context as infile:
168168
lib.call_module(
169169
module="grdimage", args=build_arg_string(kwargs, infile=infile)

pygmt/src/triangulate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def _triangulate(
123123
``outgrid`` or ``outfile``)
124124
"""
125125
with Session() as lib:
126-
table_context = lib.virtualfile_from_data(
126+
table_context = lib.virtualfile_in(
127127
check_kind="vector", data=data, x=x, y=y, z=z, required_z=False
128128
)
129129
with table_context as infile:

0 commit comments

Comments
 (0)