ATLAS Offline Software
Loading...
Searching...
No Matches
plot-intgrid Namespace Reference

Functions

 parse_file_contents (file_content, file_name)
 is_float (value)

Variables

 parser = argparse.ArgumentParser(description="Parse file and extract x, y values and title.")
 Parse command line input #.
 type
 str
 help
 args = parser.parse_args()
 file_content = file.read()

Function Documentation

◆ is_float()

plot-intgrid.is_float ( value)

Definition at line 47 of file plot-intgrid.py.

47def is_float(value):
48 try:
49 float(value)
50 return True
51 except ValueError:
52 return False
53

◆ parse_file_contents()

plot-intgrid.parse_file_contents ( file_content,
file_name )

Definition at line 3 of file plot-intgrid.py.

3def parse_file_contents(file_content,file_name):
4 # Initialize empty lists for x and y values
5 x_values = []
6 y_values = []
7 title = ""
8
9 # Split the file content into lines
10 lines = file_content.strip().split('\n')
11
12 # Iterate through each line
13 for line in lines:
14 if line.strip().startswith("join"):
15 if title == "":
16 continue
17 print("saving plot "+title)
18 new_x = range(len(x_values))
19 new_x = [i/(len(x_values)-1) for i in new_x]
20 plt.plot(x_values,y_values,"o-")
21 plt.plot(new_x,y_values,"o-")
22 plt.title(title)
23 plt.savefig(title+".png",format="png")
24 plt.close()
25 x_values = []
26 y_values = []
27 title = ""
28 if line.strip().startswith("title"):
29 title = line.split('"')[1]
30 title = title.split()
31 title = file_name+"_dim"+title[1]
32 print("title "+title)
33
34 # Split the line into words (or values)
35 values = line.split()
36 if title == "":
37 continue
38 # Check if the line contains numerical values (excluding title and set limits)
39 if len(values) == 2 and all(is_float(v) for v in values):
40 # Convert values to float and append to the respective lists
41 x_values.append(float(values[0]))
42 y_values.append(float(values[1]))
43
44 #return x_values, y_values
45
46
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

Variable Documentation

◆ args

plot-intgrid.args = parser.parse_args()

Definition at line 67 of file plot-intgrid.py.

◆ file_content

plot-intgrid.file_content = file.read()

Definition at line 72 of file plot-intgrid.py.

◆ help

plot-intgrid.help

Definition at line 64 of file plot-intgrid.py.

◆ parser

plot-intgrid.parser = argparse.ArgumentParser(description="Parse file and extract x, y values and title.")

Parse command line input #.

Set up argument parser

Definition at line 61 of file plot-intgrid.py.

◆ str

plot-intgrid.str

Definition at line 64 of file plot-intgrid.py.

◆ type

plot-intgrid.type

Definition at line 64 of file plot-intgrid.py.