@@ -270,8 +270,9 @@ def get_libgmt_func(self, name, argtypes=None, restype=None):
270
270
271
271
>>> from ctypes import c_void_p, c_int
272
272
>>> with Session() as lib:
273
- ... func = lib.get_libgmt_func('GMT_Destroy_Session',
274
- ... argtypes=[c_void_p], restype=c_int)
273
+ ... func = lib.get_libgmt_func(
274
+ ... "GMT_Destroy_Session", argtypes=[c_void_p], restype=c_int
275
+ ... )
275
276
>>> type(func)
276
277
<class 'ctypes.CDLL.__init__.<locals>._FuncPtr'>
277
278
@@ -702,15 +703,15 @@ def _check_dtype_and_dim(self, array, ndim):
702
703
--------
703
704
704
705
>>> import numpy as np
705
- >>> data = np.array([1, 2, 3], dtype=' float64' )
706
+ >>> data = np.array([1, 2, 3], dtype=" float64" )
706
707
>>> with Session() as ses:
707
708
... gmttype = ses._check_dtype_and_dim(data, ndim=1)
708
709
... gmttype == ses["GMT_DOUBLE"]
709
710
True
710
- >>> data = np.ones((5, 2), dtype=' float32' )
711
+ >>> data = np.ones((5, 2), dtype=" float32" )
711
712
>>> with Session() as ses:
712
713
... gmttype = ses._check_dtype_and_dim(data, ndim=2)
713
- ... gmttype == ses[' GMT_FLOAT' ]
714
+ ... gmttype == ses[" GMT_FLOAT" ]
714
715
True
715
716
716
717
"""
@@ -1022,23 +1023,23 @@ def open_virtual_file(self, family, geometry, direction, data):
1022
1023
>>> x = np.array([0, 1, 2, 3, 4])
1023
1024
>>> y = np.array([5, 6, 7, 8, 9])
1024
1025
>>> with Session() as lib:
1025
- ... family = ' GMT_IS_DATASET|GMT_VIA_VECTOR'
1026
- ... geometry = ' GMT_IS_POINT'
1026
+ ... family = " GMT_IS_DATASET|GMT_VIA_VECTOR"
1027
+ ... geometry = " GMT_IS_POINT"
1027
1028
... dataset = lib.create_data(
1028
1029
... family=family,
1029
1030
... geometry=geometry,
1030
- ... mode=' GMT_CONTAINER_ONLY' ,
1031
+ ... mode=" GMT_CONTAINER_ONLY" ,
1031
1032
... dim=[2, 5, 1, 0], # columns, lines, segments, type
1032
1033
... )
1033
1034
... lib.put_vector(dataset, column=0, vector=x)
1034
1035
... lib.put_vector(dataset, column=1, vector=y)
1035
1036
... # Add the dataset to a virtual file
1036
- ... vfargs = (family, geometry, ' GMT_IN|GMT_IS_REFERENCE' , dataset)
1037
+ ... vfargs = (family, geometry, " GMT_IN|GMT_IS_REFERENCE" , dataset)
1037
1038
... with lib.open_virtual_file(*vfargs) as vfile:
1038
1039
... # Send the output to a temp file so that we can read it
1039
1040
... with GMTTempFile() as ofile:
1040
- ... args = ' {} ->{}' .format(vfile, ofile.name)
1041
- ... lib.call_module(' info' , args)
1041
+ ... args = " {} ->{}" .format(vfile, ofile.name)
1042
+ ... lib.call_module(" info" , args)
1042
1043
... print(ofile.read().strip())
1043
1044
<vector memory>: N = 5 <0/4> <5/9>
1044
1045
@@ -1133,7 +1134,7 @@ def virtualfile_from_vectors(self, *vectors):
1133
1134
... # Send the output to a file so that we can read it
1134
1135
... with GMTTempFile() as fout:
1135
1136
... ses.call_module(
1136
- ... ' info', ' {} ->{}' .format(fin, fout.name)
1137
+ ... " info", " {} ->{}" .format(fin, fout.name)
1137
1138
... )
1138
1139
... print(fout.read().strip())
1139
1140
<vector memory>: N = 3 <1/3> <4/6> <7/9>
@@ -1245,7 +1246,7 @@ def virtualfile_from_matrix(self, matrix):
1245
1246
... # Send the output to a file so that we can read it
1246
1247
... with GMTTempFile() as fout:
1247
1248
... ses.call_module(
1248
- ... ' info', ' {} ->{}' .format(fin, fout.name)
1249
+ ... " info", " {} ->{}" .format(fin, fout.name)
1249
1250
... )
1250
1251
... print(fout.read().strip())
1251
1252
<matrix memory>: N = 4 <0/9> <1/10> <2/11>
@@ -1314,7 +1315,7 @@ def virtualfile_from_grid(self, grid):
1314
1315
1315
1316
>>> from pygmt.datasets import load_earth_relief
1316
1317
>>> from pygmt.helpers import GMTTempFile
1317
- >>> data = load_earth_relief(resolution=' 01d' )
1318
+ >>> data = load_earth_relief(resolution=" 01d" )
1318
1319
>>> print(data.shape)
1319
1320
(180, 360)
1320
1321
>>> print(data.lon.values.min(), data.lon.values.max())
@@ -1327,8 +1328,8 @@ def virtualfile_from_grid(self, grid):
1327
1328
... with ses.virtualfile_from_grid(data) as fin:
1328
1329
... # Send the output to a file so that we can read it
1329
1330
... with GMTTempFile() as fout:
1330
- ... args = ' {} -L0 -Cn ->{}' .format(fin, fout.name)
1331
- ... ses.call_module(' grdinfo' , args)
1331
+ ... args = " {} -L0 -Cn ->{}" .format(fin, fout.name)
1332
+ ... ses.call_module(" grdinfo" , args)
1332
1333
... print(fout.read().strip())
1333
1334
-180 180 -90 90 -8182 5651.5 1 1 360 180 1 1
1334
1335
>>> # The output is: w e s n z0 z1 dx dy n_columns n_rows reg gtype
@@ -1378,34 +1379,40 @@ def extract_region(self):
1378
1379
1379
1380
>>> import pygmt
1380
1381
>>> fig = pygmt.Figure()
1381
- >>> fig.coast(region=[0, 10, -20, -10], projection="M6i", frame=True,
1382
- ... land='black')
1382
+ >>> fig.coast(
1383
+ ... region=[0, 10, -20, -10],
1384
+ ... projection="M6i",
1385
+ ... frame=True,
1386
+ ... land="black",
1387
+ ... )
1383
1388
>>> with Session() as lib:
1384
1389
... wesn = lib.extract_region()
1385
- >>> print(', ' .join([' {:.2f}' .format(x) for x in wesn]))
1390
+ >>> print(", " .join([" {:.2f}" .format(x) for x in wesn]))
1386
1391
0.00, 10.00, -20.00, -10.00
1387
1392
1388
1393
Using ISO country codes for the regions (for example ``'US.HI'`` for
1389
1394
Hawaii):
1390
1395
1391
1396
>>> fig = pygmt.Figure()
1392
- >>> fig.coast(region='US.HI', projection="M6i", frame=True,
1393
- ... land='black')
1397
+ >>> fig.coast(
1398
+ ... region="US.HI", projection="M6i", frame=True, land="black"
1399
+ ... )
1394
1400
>>> with Session() as lib:
1395
1401
... wesn = lib.extract_region()
1396
- >>> print(', ' .join([' {:.2f}' .format(x) for x in wesn]))
1402
+ >>> print(", " .join([" {:.2f}" .format(x) for x in wesn]))
1397
1403
-164.71, -154.81, 18.91, 23.58
1398
1404
1399
1405
The country codes can have an extra argument that rounds the region a
1400
1406
multiple of the argument (for example, ``'US.HI+r5'`` will round the
1401
1407
region to multiples of 5):
1402
1408
1403
1409
>>> fig = pygmt.Figure()
1404
- >>> fig.coast(region='US.HI+r5', projection="M6i", frame=True,
1405
- ... land='black')
1410
+ >>> fig.coast(
1411
+ ... region="US.HI+r5", projection="M6i", frame=True, land="black"
1412
+ ... )
1406
1413
>>> with Session() as lib:
1407
1414
... wesn = lib.extract_region()
1408
- >>> print(', ' .join([' {:.2f}' .format(x) for x in wesn]))
1415
+ >>> print(", " .join([" {:.2f}" .format(x) for x in wesn]))
1409
1416
-165.00, -150.00, 15.00, 25.00
1410
1417
1411
1418
"""
0 commit comments