|
| 1 | +""" |
| 2 | +directional_rose - Add a map directional rose. |
| 3 | +""" |
| 4 | + |
| 5 | +from collections.abc import Sequence |
| 6 | +from typing import Literal |
| 7 | + |
| 8 | +from pygmt.alias import Alias, AliasSystem |
| 9 | +from pygmt.clib import Session |
| 10 | +from pygmt.exceptions import GMTInvalidInput |
| 11 | +from pygmt.helpers import build_arg_list |
| 12 | +from pygmt.params import Box, Position |
| 13 | + |
| 14 | + |
| 15 | +def directional_rose( |
| 16 | + self, |
| 17 | + position: Position | None = None, |
| 18 | + width: float | str | None = None, |
| 19 | + label: Sequence[str] | bool = False, |
| 20 | + fancy: Literal[1, 2, 3] | bool = False, |
| 21 | + box: Box | bool = False, |
| 22 | + perspective: str | bool = False, |
| 23 | + verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] |
| 24 | + | bool = False, |
| 25 | + transparency: float | None = None, |
| 26 | +): |
| 27 | + """ |
| 28 | + Add a directional rose on the map. |
| 29 | +
|
| 30 | + Parameters |
| 31 | + ---------- |
| 32 | + position |
| 33 | + Specify the position of the directional rose on a map. See |
| 34 | + :class:`pygmt.params.Position` for details. |
| 35 | + width |
| 36 | + Width of the rose in plot coordinates (append **i** (inch), **cm** |
| 37 | + (centimeters), or **p** (points)), or append % for a size in percentage of map |
| 38 | + width [Default is 10 %]. |
| 39 | + label |
| 40 | + A sequence of four strings to label the cardinal points W,E,S,N. Use an empty |
| 41 | + string to skip a specific label. If set to ``True``, use the default labels |
| 42 | + ``["W", "E", "S", "N"]``. |
| 43 | + fancy |
| 44 | + Get a fancy rose. The fanciness level can be set to 1, 2, or 3: |
| 45 | +
|
| 46 | + - Level 1 draws the two principal E-W, N-S orientations |
| 47 | + - Level 2 adds the two intermediate NW-SE and NE-SW orientations |
| 48 | + - Level 3 adds the four minor orientations WNW-ESE, NNW-SSE, NNE-SSW, and |
| 49 | + ENE-WSW |
| 50 | +
|
| 51 | + If set to ``True``, defaults to level 1. |
| 52 | + box |
| 53 | + Draw a background box behind the directional rose. If set to ``True``, a simple |
| 54 | + rectangular box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box |
| 55 | + appearance, pass a :class:`pygmt.params.Box` object to control style, fill, pen, |
| 56 | + and other box properties. |
| 57 | + $perspective |
| 58 | + $verbose |
| 59 | + $transparency |
| 60 | +
|
| 61 | + Examples |
| 62 | + -------- |
| 63 | + >>> import pygmt |
| 64 | + >>> fig = pygmt.Figure() |
| 65 | + >>> fig.basemap(region=[0, 80, -30, 30], projection="M10c", frame=True) |
| 66 | + >>> fig.directional_rose(position=Position((10, 10), cstype="mapcoords")) |
| 67 | + >>> fig.show() |
| 68 | + """ |
| 69 | + self._activate_figure() |
| 70 | + |
| 71 | + if position is None: |
| 72 | + msg = "Parameter 'position' is required." |
| 73 | + raise GMTInvalidInput(msg) |
| 74 | + |
| 75 | + aliasdict = AliasSystem( |
| 76 | + F=Alias(box, name="box"), |
| 77 | + Td=[ |
| 78 | + Alias(position, name="position"), |
| 79 | + Alias(width, name="width", prefix="+w"), |
| 80 | + Alias(fancy, name="fancy", prefix="+f"), # +F is not supported yet. |
| 81 | + Alias(label, name="label", prefix="+l", sep=",", size=4), |
| 82 | + ], |
| 83 | + ).add_common( |
| 84 | + V=verbose, |
| 85 | + p=perspective, |
| 86 | + t=transparency, |
| 87 | + ) |
| 88 | + |
| 89 | + with Session() as lib: |
| 90 | + lib.call_module(module="basemap", args=build_arg_list(aliasdict)) |
0 commit comments