aboutsummaryrefslogtreecommitdiff
path: root/fullswof-utils/boundary_profile.py
blob: 22bde1d20da2a618104b15f3c11fe3723a62a8b6 (plain)
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
#!/usr/bin/env python3

import matplotlib.pyplot as plt
import numpy as np
import os
import argparse
from matplotlib.ticker import MultipleLocator

# read command line argument:
parser = argparse.ArgumentParser(
    description="plot elevation versus distance at boundaries")
parser.add_argument("location", help="boundary location")
args = parser.parse_args()

if args.location == 'top':
    inputFilename = "top_boundary.txt"
    lineColour = "tab:blue"
elif args.location == 'bottom':
    inputFilename = "bottom_boundary.txt"
    lineColour = "tab:green"
elif args.location == 'left':
    inputFilename = "left_boundary.txt"
    lineColour = "tab:red"
elif args.location == 'right':
    inputFilename = "right_boundary.txt"
    lineColour = "tab:orange"

def detach_display():
    x, y, z = np.loadtxt(inputFilename, delimiter=' ', unpack=True)
    fig, ax = plt.subplots()
    plt.plot(x,z, color=lineColour, label='elevation')
    plt.xlabel('x / m')
    plt.ylabel('z / m')
    ax.yaxis.set_minor_locator(MultipleLocator(0.2))
    plt.grid(True, which='minor')
    plt.show()

if os.fork():
    # parent
    pass
else:
    # child
    detach_display()