Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use complete and consistent descriptions for grid and outgrid #2695

Closed
seisman opened this issue Sep 19, 2023 · 0 comments · Fixed by #2874
Closed

Use complete and consistent descriptions for grid and outgrid #2695

seisman opened this issue Sep 19, 2023 · 0 comments · Fixed by #2874
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@seisman
Copy link
Member

seisman commented Sep 19, 2023

I'll take the current grdcut documentation (https://www.pygmt.org/v0.10.0/api/generated/pygmt.grdcut.html) as an example.

Currently, the docstring says:

grid : str or xarray.DataArray

The file name of the input grid or the grid loaded as a DataArray.

outgrid : str or None

The name of the output netCDF file with extension .nc to store the grid in.

When grid or outgrid is a netCDF file, it can actually have more modifiers (http:https://docs.generic-mapping-tools.org/latest/grdcut.html):

ingrid[=ID|?varname][+bband][+ddivisor][+ninvalid][+ooffset][+sscale]

Input grid file. Optionally, append =ID for reading a specific file format [Default is =nf] or ?varname for a specific netCDF variable [Default is the first 2-D grid found by GMT] (See full description). The following modifiers are supported:

+b - Select a band (for images only) [Default is 0].

+d - Divide data values by the given divisor [Default is 1].

+n - Replace data values matching invalid with NaN.

+o - Offset data values by the given offset [Default is 0].

+s - Scale data values by the given scale [Default is 1].

Note: Any offset is added after any scaling.

-Goutgrid[=ID][+ddivisor][+ninvalid][+ooffset|a][+sscale|a][:driver[dataType][+coptions]]

Give the name of the output grid file. Optionally, append =ID for writing a specific file format (See full description). The following modifiers are supported:

+d - Divide data values by given divisor [Default is 1].

+n - Replace data values matching invalid with a NaN.

+o - Offset data values by the given offset, or append a for automatic range offset to preserve precision for integer grids [Default is 0].

+s - Scale data values by the given scale, or append a for automatic scaling to preserve precision for integer grids [Default is 1].

Note: Any offset is added before any scaling. +sa also sets +oa (unless overridden). To write specific formats via GDAL, use =gd and supply driver (and optionally dataType) and/or one or more concatenated GDAL -co options using +c. See the “Writing grids and images” cookbook section for more details.

I think we should improve the docstrings to have a complete description about grids. Since the same description will be used in many different function docstrings, we can define new docstring placeholders in COMMON_DOCSTRINGS (https://github.com/GenericMappingTools/pygmt/blob/1e4845432cd3d0c575cc12c711c10735bbd5f289/pygmt/helpers/decorators.py#L17C1-L17C18).

@seisman seisman added the documentation Improvements or additions to documentation label Sep 19, 2023
@seisman seisman added this to the 0.11.0 milestone Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant