Repository navigation
Expand file tree
/
Copy pathplot_section.py
More file actions
82 lines (74 loc) · 2.66 KB
/
Copy pathplot_section.py
File metadata and controls
82 lines (74 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""Create a PNG from a GeoSIRR cross-section text file."""
import argparse
from pathlib import Path
from geosirr.vis import plot_cross_section
def main():
parser = argparse.ArgumentParser(
description="Plot a GeoSIRR text cross-section as a PNG."
)
parser.add_argument("input", type=Path, help="Cross-section .txt file to plot.")
parser.add_argument(
"-o", "--output", type=Path,
help="PNG path. Defaults to the input path with a .png suffix."
)
parser.add_argument(
"--title", default="Geological Cross Section",
help="Title displayed above the section."
)
parser.add_argument(
"--padding", type=float, default=0.1,
help="Section padding as a fraction of each axis range (default: 0.1)."
)
parser.add_argument(
"--legend-padding", type=float, default=0.25,
help="Figure width reserved for the legend (default: 0.25)."
)
parser.add_argument(
"--legend-gap", type=float, default=0.02,
help="Gap between the model and legend as a fraction of model width (default: 0.02)."
)
parser.add_argument(
"--font-size", type=float, default=8,
help="Legend font size in points (default: 8)."
)
parser.add_argument(
"--vertex-font-size", type=float,
help="Vertex-label font size in points (default: --font-size)."
)
parser.add_argument(
"--line-width", type=float, default=1,
help="Polygon boundary width in points (default: 1)."
)
parser.add_argument(
"--vertex-size", type=float, default=3,
help="Vertex marker size in points (default: 3)."
)
parser.add_argument(
"--title-padding", type=float, default=12,
help="Distance between the title and the model in points (default: 12)."
)
parser.add_argument(
"--figsize", nargs=2, type=float, metavar=("WIDTH", "HEIGHT"),
default=(10, 6), help="Figure size in inches (default: 10 6)."
)
args = parser.parse_args()
if not args.input.is_file():
parser.error(f"input file does not exist: {args.input}")
output = args.output or args.input.with_suffix(".png")
plot_cross_section(
definition=str(args.input),
filename=str(output),
title=args.title,
figsize=tuple(args.figsize),
padding=args.padding,
legend_padding=args.legend_padding,
legend_gap=args.legend_gap,
font_size=args.font_size,
vertex_font_size=args.vertex_font_size,
line_width=args.line_width,
vertex_size=args.vertex_size,
title_padding=args.title_padding,
show=False,
)
if __name__ == "__main__":
main()