pygmt.clib.Session.get_common
- Session.get_common(option)[source]
Inquire if a GMT common option has been set and return its current value if possible.
- Parameters:
option (
str) – The GMT common option to check. Valid options are"B","I","J","R","U","V","X","Y","a","b","f","g","h","i","n","o","p","r","s","t", and":".- Return type:
- Returns:
value – Whether the option was set or its value. If the option was not set, return
False. Otherwise, the return value depends on the choice of the option.options
"B","J","U","g","n","p", and"s": returnTrueif set, elseFalse(bool)"I": 2-element array for the increments (float)"R": 4-element array for the region (float)"V": the verbose level (int)"X": the xshift (float)"Y": the yshift (float)"a": geometry of the dataset (int)"b": return 0 if-biwas set and 1 if-bowas set (int)"f": return 0 if-fiwas set and 1 if-fowas set (int)"h": whether to delete existing header records (int)"i": number of input columns (int)"o": number of output columns (int)"r": registration type (int)"t": 2-element array for the transparency (float)":": return 0 if-:iwas set and 1 if-:owas set (int)
Examples
>>> with Session() as lib: ... lib.call_module( ... "basemap", ["-R0/10/10/15", "-JX5i/2.5i", "-Baf", "-Ve"] ... ) ... region = lib.get_common("R") ... projection = lib.get_common("J") ... timestamp = lib.get_common("U") ... verbose = lib.get_common("V") ... lib.call_module("plot", ["-T", "-Xw+1i", "-Yh-1i"]) ... xshift = lib.get_common("X") # xshift/yshift are in inches ... yshift = lib.get_common("Y") >>> print(region, projection, timestamp, verbose, xshift, yshift) [ 0. 10. 10. 15.] True False 3 6.0 1.5 >>> with Session() as lib: ... lib.call_module("basemap", ["-R0/10/10/15", "-JX5i/2.5i", "-Baf"]) ... lib.get_common("A") Traceback (most recent call last): ... pygmt.exceptions.GMTInvalidInput: Unknown GMT common option flag 'A'.