Hi, I would like to know how can I save and export a grid I just created with pyGMT? in .grd or .nc. For example I created this mask grid and I want to export it from pyGMT and load in pyGMT and GMT.
Those are just convention extensions. They are not formats specifiers. The tradition in GMT is to use .grd (emphasizing that it is a grid) when saving a single layer and .nc for cubes (multi-layered). But even that is just a mild convention.
You can utilize it in any GMT script, and if desired, manipulate this GRD file later with Python and Xarray to add attributes or change variable names. Occasionally, I harness the capabilities of GMT/PyGMT’s “surface” function to interpolate within a GRD file, subsequently treating it as a NetCDF file. This process poses no issue whatsoever.