Peano
Loading...
Searching...
No Matches
probe.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import os
4import sys
5import argparse
6
8
9if __name__ == "__main__":
10 parser = argparse.ArgumentParser(
11 description="Peano 4 - Probe Script. Extract the values at one point over time from a Peano patch file into a csv file. The first column is the time stamp, the remaining columns are the unknowns of all data sets. There is no interpolation: we take the value of the finest cell (cell data) or nearest dof (vertex data)."
12 )
13 parser.add_argument(
14 "--point",
15 type=float,
16 nargs="+",
17 required=True,
18 help="Coordinates of probe point (2 or 3 entries; z is ignored for 2d data)",
19 )
20 parser.add_argument(
21 "-o",
22 "--output",
23 default="probe.csv",
24 help="Name of the output csv file",
25 )
26 parser.add_argument(
27 "--set-identifier",
28 default="",
29 help="Probe only this data set (default: all data sets in file)",
30 )
31 parser.add_argument(
32 "-v",
33 "--verbose",
34 action="store_true",
35 default=False,
36 help="Run in a chatty mode",
37 )
38 parser.add_argument(
39 "-s",
40 "--single-file",
41 action="store_true",
42 default=False,
43 help="Input file is single snapshot (and not meta file). Time stamp is then 0",
44 )
45 parser.add_argument(
46 "-j",
47 "--max-workers",
48 type=int,
49 nargs="?",
50 const=None,
51 default=1,
52 help="Number of workers processing the snapshots in parallel",
53 )
54 parser.add_argument(
55 "-start",
56 "--start-snapshot-index",
57 dest="start",
58 type=int,
59 help="First snapshot to probe, default is 0",
60 default=0,
61 )
62 parser.add_argument(
63 "-end",
64 "--end-snapshot-index",
65 dest="end",
66 type=int,
67 help="Last snapshot to probe, default is -1 (last snapshot)",
68 default=-1,
69 )
70 parser.add_argument(dest="filename", help="Input file name")
71 args = parser.parse_args()
72
73 if not os.path.exists(args.filename):
74 raise Exception(
75 "Specified input file '{}' does not exist, exiting...".format(args.filename)
76 )
77 if len(args.point) not in [2, 3]:
78 raise Exception("--point requires 2 or 3 coordinates")
79 if (args.start > args.end and args.end != -1) or args.start < 0 or args.end < -1:
80 raise Exception("Specified snapshot index is wrong, please check.")
81
83 file_name=args.filename,
84 point=args.point,
85 output_file=args.output,
86 start=args.start,
87 end=args.end if args.end != -1 else sys.maxsize,
88 verbose=args.verbose,
89 )
90 probe.identifier = args.set_identifier
91
92 if args.single_file:
93 probe.display_single_file()
94 else:
95 probe.display(args.max_workers)
Probe the data within a Peano patch file at one point over time.
Definition PointProbe.py:37