@@ -1648,29 +1648,37 @@ def read_virtualfile(self, vfname):
1648
1648
return c_read_virtualfile (self .session_pointer , vfname .encode ())
1649
1649
1650
1650
@contextmanager
1651
- def virtualfile_from_gmtgrid (self , grid_pointer ):
1651
+ def virtualfile_to_data (self , kind ):
1652
1652
"""
1653
- Create a virtual file for reading a GMT_GRID object .
1653
+ Create a virtual file for writing a GMT data container .
1654
1654
1655
- Parameter
1656
- ---------
1657
- grid_pointer : ctp.POINTER(GMT_GRID)
1658
- Pointer to a GMT_GRID object.
1655
+ Parameters
1656
+ ----------
1657
+ kind : str
1658
+ The kind of data container to create. Choose from "grid" or
1659
+ "dataset".
1659
1660
1660
1661
Yields
1661
1662
------
1662
1663
vfile : str
1663
1664
Name of the virtual file.
1664
1665
"""
1665
- family = "GMT_IS_GRID"
1666
- geometry = "GMT_IS_SURFACE"
1667
- with self .open_virtual_file (family , geometry , "GMT_IN" , grid_pointer ) as vfile :
1666
+ family , geometry = {
1667
+ "grid" : ("GMT_IS_GRID" , "GMT_IS_SURFACE" ),
1668
+ "dataset" : ("GMT_IS_DATASET" , "GMT_IS_PLP" ),
1669
+ }[kind ]
1670
+ with self .open_virtual_file (family , geometry , "GMT_OUT" , None ) as vfile :
1668
1671
yield vfile
1669
1672
1670
1673
@contextmanager
1671
- def virtualfile_to_gmtgrid (self ):
1674
+ def virtualfile_from_gmtgrid (self , grid_pointer ):
1672
1675
"""
1673
- Create a virtual file for writing a GMT_GRID object.
1676
+ Create a virtual file for reading a GMT_GRID object.
1677
+
1678
+ Parameter
1679
+ ---------
1680
+ grid_pointer : ctp.POINTER(GMT_GRID)
1681
+ Pointer to a GMT_GRID object.
1674
1682
1675
1683
Yields
1676
1684
------
@@ -1679,7 +1687,7 @@ def virtualfile_to_gmtgrid(self):
1679
1687
"""
1680
1688
family = "GMT_IS_GRID"
1681
1689
geometry = "GMT_IS_SURFACE"
1682
- with self .open_virtual_file (family , geometry , "GMT_OUT " , None ) as vfile :
1690
+ with self .open_virtual_file (family , geometry , "GMT_IN " , grid_pointer ) as vfile :
1683
1691
yield vfile
1684
1692
1685
1693
@contextmanager
0 commit comments