19
19
array_to_datetime ,
20
20
as_c_contiguous ,
21
21
dataarray_to_matrix ,
22
- kwargs_to_ctypes_array ,
22
+ sequence_to_ctypes_array ,
23
23
vectors_to_arrays ,
24
24
)
25
25
from pygmt .clib .loading import load_libgmt
@@ -628,7 +628,17 @@ def call_module(self, module, args):
628
628
f"Module '{ module } ' failed with status code { status } :\n { self ._error_message } "
629
629
)
630
630
631
- def create_data (self , family , geometry , mode , ** kwargs ):
631
+ def create_data (
632
+ self ,
633
+ family ,
634
+ geometry ,
635
+ mode ,
636
+ dim = None ,
637
+ ranges = None ,
638
+ inc = None ,
639
+ registration = "GMT_GRID_NODE_REG" ,
640
+ pad = None ,
641
+ ):
632
642
"""
633
643
Create an empty GMT data container.
634
644
@@ -692,15 +702,13 @@ def create_data(self, family, geometry, mode, **kwargs):
692
702
valid_modifiers = ["GMT_GRID_IS_CARTESIAN" , "GMT_GRID_IS_GEO" ],
693
703
)
694
704
geometry_int = self ._parse_constant (geometry , valid = GEOMETRIES )
695
- registration_int = self ._parse_constant (
696
- kwargs .get ("registration" , "GMT_GRID_NODE_REG" ), valid = REGISTRATIONS
697
- )
705
+ registration_int = self ._parse_constant (registration , valid = REGISTRATIONS )
698
706
699
707
# Convert dim, ranges, and inc to ctypes arrays if given (will be None
700
708
# if not given to represent NULL pointers)
701
- dim = kwargs_to_ctypes_array ( " dim" , kwargs , ctp .c_uint64 * 4 )
702
- ranges = kwargs_to_ctypes_array ( " ranges" , kwargs , ctp .c_double * 4 )
703
- inc = kwargs_to_ctypes_array ( " inc" , kwargs , ctp .c_double * 2 )
709
+ dim = sequence_to_ctypes_array ( dim , ctp .c_uint64 , 4 )
710
+ ranges = sequence_to_ctypes_array ( ranges , ctp .c_double , 4 )
711
+ inc = sequence_to_ctypes_array ( inc , ctp .c_double , 2 )
704
712
705
713
# Use a NULL pointer (None) for existing data to indicate that the
706
714
# container should be created empty. Fill it in later using put_vector
@@ -714,7 +722,7 @@ def create_data(self, family, geometry, mode, **kwargs):
714
722
ranges ,
715
723
inc ,
716
724
registration_int ,
717
- self ._parse_pad (family , kwargs ),
725
+ self ._parse_pad (family , pad ),
718
726
None ,
719
727
)
720
728
@@ -723,15 +731,14 @@ def create_data(self, family, geometry, mode, **kwargs):
723
731
724
732
return data_ptr
725
733
726
- def _parse_pad (self , family , kwargs ):
734
+ def _parse_pad (self , family , pad ):
727
735
"""
728
736
Parse and return an appropriate value for pad if none is given.
729
737
730
738
Pad is a bit tricky because, for matrix types, pad control the matrix ordering
731
739
(row or column major). Using the default pad will set it to column major and
732
740
mess things up with the numpy arrays.
733
741
"""
734
- pad = kwargs .get ("pad" , None )
735
742
if pad is None :
736
743
pad = 0 if "MATRIX" in family else self ["GMT_PAD_DEFAULT" ]
737
744
return pad
@@ -1080,7 +1087,7 @@ def write_data(self, family, geometry, mode, wesn, output, data):
1080
1087
self ["GMT_IS_FILE" ],
1081
1088
geometry_int ,
1082
1089
self [mode ],
1083
- ( ctp .c_double * 6 )( * wesn ),
1090
+ sequence_to_ctypes_array ( wesn , ctp .c_double , 6 ),
1084
1091
output .encode (),
1085
1092
data ,
1086
1093
)
0 commit comments