GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Explore adding long-format GMT options by PaulWessel · Pull Request #230 · GenericMappingTools/gmt

Conversation

@PaulWessel

@PaulWessel PaulWessel commented Dec 21, 2018

Copy link
Copy Markdown
Contributor

This branch is work in progress on adding long-format option parsing to GMT. E.g., --region=w/e/s/n instead of -Rw/e/s/n, --registration=pixel instead of -r, and so on. At the moment only the common options and their most basic forms have been implemented, as well as local options for blockmean.
I will write more later about how this all works and what is required to be added to each module - blockmean.c static variable local_kw shows how. Basically, for each short-format option we need to supply the corresponding long-form names. Many GMT options support modifiers of the form +[ which in long form will be +[=]. Finally, many GMT options have a directive character immediately following the option key and these will become [:] in long form. Thus, what is parsed and converted to short-format options are optinos like

--longoption[=[:]][+<mod1[=]][+<mod2[=]]...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@PaulWessel
WIP Explore adding long-format GMT options
a0d6f1c
This branch is work in progress on adding long-format option parsing to GMT.  E.g., --region=w/e/s/n instead of -Rw/e/s/n, --registration=pixel instead of -r, and so on.  At the moment only the common options and their most basic forms have been implemented, as well as local options for blockmean.
I will write more later about how this all works and what is required to be added to each module - blockmean.c static variable local_kw shows how.
@PaulWessel PaulWessel self-assigned this Dec 21, 2018
@PaulWessel
Merge branch 'master' into longoptionsparsing
4f06191
@PaulWessel

PaulWessel commented Dec 21, 2018

Copy link
Copy Markdown
Contributor Author

Sorry, got formatted. The general thing I am parsing is of the form

--longoption[=[<directive>:]<arg>][+<mod1[=<arg1>]][+<mod2[=<arg2>]]...

which will represent the vast number of module options.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joa-quim
joa-quim approved these changes Dec 21, 2018
View reviewed changes
@PaulWessel PaulWessel mentioned this pull request Dec 21, 2018
Long-form command-line argument support #224
Closed
PaulWessel added 15 commits December 21, 2018 16:03
@PaulWessel
Merge branch 'master' into longoptionsparsing
10dcf50
@PaulWessel
More common option long-format words
2e6cd71
Update long-syntax for -U and -s.
@PaulWessel
Merge branch 'master' into longoptionsparsing
3e1a5e6
@PaulWessel
Merge branch 'master' into longoptionsparsing
64905f0
@PaulWessel
Update mgd77track.c
97907f7
Merge from master missed the new NULL argument..
@PaulWessel
Add separator variable to GMT_KW_DICT
958968e
Needed to split parsing of options that are given as a series of arguments separated by slashes (e.g., xinc/yinc) or commas (e.g., input columns).
@PaulWessel
Let -T option be a modifer under -C
225359c
The -T and -C are dealing with the same issue: The text bounding box atrributes.  I have combined these with -T now being a modifer +t<shape> under -C.  Tests pass, documentation has been updated.
@PaulWessel
Remove the ifdef USE_GMT_KWD
ce41093
No point having this since this is a separate branch for testing anyway.
@PaulWessel
Merge branch 'master' into longoptionsparsing
b795ed8
@PaulWessel
Merge branch 'master' into longoptionsparsing
cdd0229
@PaulWessel
Implement parsing of sections
fdcf1ed
Added code to handle multi-section arguments such as --increments=30+e/50+n
@PaulWessel
Merge branch 'master' into longoptionsparsing
404438b
@PaulWessel
Documentation
60e44e2
Improve the documentation of the new gmtinit_kw_replace function that converts long-format GMT options to standard short-format options.
@PaulWessel
Merge branch 'pstextsimplify' into longoptionsparsing
af27567
@PaulWessel
Merge branch 'master' into longoptionsparsing
1f76192
@PaulWessel PaulWessel mentioned this pull request Dec 30, 2018
Discussion: Improve -B for GMT 6 via long-format options #254
Open
PaulWessel added 8 commits December 30, 2018 11:25
@PaulWessel
Merge branch 'master' into longoptionsparsing
b3bbc3f
@PaulWessel
Merge branch 'master' into longoptionsparsing
9868ffe
@PaulWessel
Merge branch 'master' into longoptionsparsing
f939ffe
@PaulWessel
Merge branch 'master' into longoptionsparsing
1680ae7
@PaulWessel
Merge branch 'master' into longoptionsparsing
193ad85
@PaulWessel
Merge branch 'master' into longoptionsparsing
e0efe84
@PaulWessel
Merge branch 'master' into longoptionsparsing
a99eb23
@PaulWessel
Merge branch 'master' into longoptionsparsing
a07d34e
@joa-quim

joa-quim commented Dec 18, 2019

Copy link
Copy Markdown
Member

I've suffered a lot with this in the Julia wrapper too, and still have issues. Basically, I find the axes and frame definitions confusing and never remember it clearly without revisiting the -B docs. -Bafg is a frame setting (but where afg is generically presented as a axes), but selecting selecting one of them, e.g. -Bx becomes a axis setting.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 18, 2019

Copy link
Copy Markdown
Contributor Author

No, -Bafg is an axes setting, not frame. The two are clearly separated and described in our long -B page.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 18, 2019

Copy link
Copy Markdown
Member

Right, but look at this. The first option in a frame is called axes

image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 18, 2019

Copy link
Copy Markdown
Contributor Author

Right, but that should actually say axis. i.e., either x, y, or z. The --frame option should specify which axes (--frame=west,south) while the --axes option should specify information about specific axes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 18, 2019

Copy link
Copy Markdown
Contributor Author

Sorry, I am wrong on that. Yes, the frame setting specifies which axes you want, then the axis setting deals with its settings. Perhaps we use --axis=x+ticks=afg or something.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 19, 2019

Copy link
Copy Markdown
Member

+ticks=afg makes no sense. +ticks can only be =yes or absent. Same for annot & grid.
And maybe now you understand why I created also the xaxis, yaxis, zaxis (instead of axis=x)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 19, 2019

Copy link
Copy Markdown
Contributor Author

Yep. Well, I will experiment with something that works for the command line. It does not have to be identical to your solution. Since -B is broken into frame plus one or more axes calls I need to match that with the long-options as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel
Adding axes as keyword
eaa3b61
Better docs for code, longer variables, fixing some bugs.
@PaulWessel

PaulWessel commented Dec 19, 2019

Copy link
Copy Markdown
Contributor Author

It will continue to be challenging to let people place "+x" strings as part of a longer title or string argument, such as the --timestamp="Time stamp +offset" example above. The quotes are not preserved inside C and I believe our options are as before:

  1. Escape such plus signs in free text so they are not a problem, e.g.,"+x"
  2. Place the entire string inside single quotes and then not split text based on modifier inside single quotes, i.e., --timestamp="'Time stamp +offset'"

I think using +p for those strings you do now want parsed as modifiers is the simplest. I have checked and the string inside C will have the + and hence we can simply (and temporarily) replace + with two non-text ascii codes, process things, and then if those two codes are present, adjust the text by removing the first and replacing the second with +.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel
Escape +? strings that should not be seen as modifiers
d96e725
@PaulWessel

PaulWessel commented Dec 19, 2019

Copy link
Copy Markdown
Contributor Author

Improved further. Added the --axes keyword to deal with axes and let --frame just deal with frame settings. ANy label/text that contains +? sequences that should not be seen as modifiers must be escaped with a backslash and the entire string must be quoted. WIth that, these work for me:

gmt basemap --region=0/40/0/50 --projection=M6i --frame=WSrt+title="Title"+fill=pink --axes=afg --timestamp="Time stamp" -pdf map
gmt basemap --region=0/40/0/50 --projection=M6i --frame=afg --timestamp="Time stamp \+offset" -pdf map
gmt basemap --region=0/40/0/50 --projection=M6i --frame=WSne --axes=x:afg --axes=y:af --timestamp="Time stamp"+command -pdf map

The --axes=x:agf follows the general longname=[directive[:arg]] general template since there are many GMT module options that requires this scheme, regardless if we decide to do --xaxis instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel
Move --increment to block_subs.c, update commons, use --axis
3c8e67f
--frame=axes sets which axes to draw, and --axis specifies the settings of an axis.
seisman
seisman approved these changes Dec 19, 2019
View reviewed changes

@seisman seisman left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Add one test before merging?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@PaulWessel

PaulWessel commented Dec 19, 2019

Copy link
Copy Markdown
Contributor Author

OK, will do that before committing. Wait, this requires a compilation switch so I dont think we easily can unless you want to add

add_definitions(-DUSE_COMMON_LONG_OPTIONS) 	# Turn on testing of upcoming long-option syntax for common GMT options
add_definitions(-DUSE_MODULE_LONG_OPTIONS) 	# Turn on testing of upcoming long-option syntax for module options

to the CI setup for master. Otherwise the long-parsing is deactivated.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel
Merge branch 'master' into longoptionsparsing
73af06c
@PaulWessel

PaulWessel commented Dec 19, 2019

Copy link
Copy Markdown
Contributor Author

Let me know if you can add those statements to the CI cmake config file and then we could add a test or two to the master branch, @seisman.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seisman
Enable CI testing for long options (#2305)
ea731fd
@seisman

seisman commented Dec 20, 2019

Copy link
Copy Markdown
Member

@PaulWessel Now you can add long-option tests to this branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

PaulWessel added 4 commits December 19, 2019 15:29
@PaulWessel
Add a long-format option test to test/modern
7b15d16
@PaulWessel
Improve coments only
e25bf8e
@PaulWessel
Merge branch 'master' into longoptionsparsing
90821af
@PaulWessel
Merge branch 'master' into longoptionsparsing
8143ea1
@PaulWessel
PaulWessel merged commit 0cc216c into master Dec 21, 2019
@PaulWessel
PaulWessel deleted the longoptionsparsing branch December 21, 2019 06:42
@seisman

seisman commented Dec 21, 2019

Copy link
Copy Markdown
Member

@PaulWessel The long-option test fails due to the timestamp of the -U option.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 21, 2019

Copy link
Copy Markdown
Contributor Author

I guess we cannot really have the time-step in these tests as it changes. I will remove it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weiji14 weiji14 mentioned this pull request Sep 12, 2020
List of GMT aliases GenericMappingTools/pygmt#48
Closed
@seisman seisman mentioned this pull request Oct 25, 2020
Complete documentation for plot GenericMappingTools/pygmt#666
Merged
24 of 28 tasks
@weiji14 weiji14 mentioned this pull request Mar 12, 2021
Description for the "columns" arguments is missing GenericMappingTools/pygmt#764
Closed
obaney pushed a commit to obaney/gmt that referenced this pull request Aug 18, 2021
@leouieda
Update the install instructions (GenericMappingTools#230)
c4708e0
Includes the packaging dependency and IPython listed as optional.
Create the environment and install dependencies in a single command.
Set the conda channel preference order before anything else.
Include sphinx and docutils as testing dependencies (GenericMappingTools#226).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@joa-quim joa-quim joa-quim approved these changes
@seisman seisman seisman approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@PaulWessel PaulWessel

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@PaulWessel @leouieda @seisman @joa-quim
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.