@@ -1708,7 +1708,7 @@ def read_virtualfile(self, vfname):
1708
1708
@contextmanager
1709
1709
def virtualfile_to_gmtdataset (self ):
1710
1710
"""
1711
- Create a virtual file for writing a GMT_GRID object.
1711
+ Create a virtual file for writing a GMT_DATASET object.
1712
1712
1713
1713
Yields
1714
1714
------
@@ -1721,12 +1721,26 @@ def virtualfile_to_gmtdataset(self):
1721
1721
yield vfile
1722
1722
1723
1723
def gmtdataset_to_vectors (self , vfile ):
1724
- data = ctp .cast (self .read_virtualfile (f"{ vfile } " ), ctp .POINTER (GMT_DATASET ))
1725
- ds = data .contents
1724
+ """
1725
+ Read GMT_DATASET object from a virtual file and convert to vectors.
1726
+
1727
+ Parameters
1728
+ ----------
1729
+ vfile : str
1730
+ Name of the virtual file.
1731
+
1732
+ Returns
1733
+ -------
1734
+ vectors : list of 1-D arrays
1735
+ List of vectors containing the data from the GMT_DATASET object.
1736
+ """
1737
+ # Read the virtual file and cast it to a pointer to a GMT_DATASET
1738
+ ds = ctp .cast (self .read_virtualfile (vfile ), ctp .POINTER (GMT_DATASET )).contents
1726
1739
1740
+ # Loop over the tables, segments, and columns to get the data as vectors
1727
1741
vectors = []
1728
- for itble in range (ds .n_tables ):
1729
- dtbl = ds .table [itble ].contents
1742
+ for itbl in range (ds .n_tables ):
1743
+ dtbl = ds .table [itbl ].contents
1730
1744
for iseg in range (dtbl .n_segments ):
1731
1745
dseg = dtbl .segment [iseg ].contents
1732
1746
for icol in range (dseg .n_columns ):
0 commit comments