Skip to content

Commit 600a0a6

Browse files
authored
Merge pull request slaclab#53 from aksharsarvesh/pyavToTRC
ENH: Switched every .pyav reference to .trc and added examples
2 parents 647aa53 + 8a569ba commit 600a0a6

File tree

5 files changed

+168
-13
lines changed

5 files changed

+168
-13
lines changed

.gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Config & Save files
22
*.txt
33
*.xml
4-
*.pyav
4+
*.trc
55

66
# Byte-compiled / optimized / DLL files
77
__pycache__/
@@ -134,4 +134,7 @@ dmypy.json
134134
.pyre/
135135

136136
#
137-
.idea/
137+
.idea/
138+
139+
# Debugger
140+
debug_archive_viewer.bash

archive_viewer/av_file_convert.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def import_is_xml(self):
4747

4848
def import_file(self, file_name: Union[str, Path] = None) -> Dict:
4949
"""Import Archive Viewer save data from the provided file. The file
50-
should be one of two types: '.pyav' or '.xml'. The data is returned as
50+
should be one of two types: '.trc' or '.xml'. The data is returned as
5151
well as saved in the stored_data property.
5252
5353
Parameters
@@ -83,30 +83,30 @@ def import_file(self, file_name: Union[str, Path] = None) -> Dict:
8383

8484
def export_file(self, file_name: Union[str, Path] = None, output_data: Union[Dict, PyDMTimePlot] = None) -> None:
8585
"""Export the provided Archive Viewer save data to the provided file.
86-
The file to export to should be of type '.pyav'. The provided data can
86+
The file to export to should be of type '.trc'. The provided data can
8787
be either a dictionary or a PyDMTimePlot object. If no data is provided,
8888
then the converter's previously imported data is exported.
8989
9090
Parameters
9191
----------
9292
file_name : str or pathlib.Path
9393
The absolute file path of the file that save data should be written
94-
to. Should be of file type '.pyav'.
94+
to. Should be of file type '.trc'.
9595
output_data : dict or PyDMTimePlot, optional
9696
The data that should be exported, by default uses previously imported data
9797
9898
Raises
9999
------
100100
FileNotFoundError
101-
If the provided file name does not match the expected output file type '.pyav'
101+
If the provided file name does not match the expected output file type '.trc'
102102
ValueError
103103
If no output data is provided and the converter hasn't imported data previously
104104
"""
105105
if file_name:
106106
self.output_file = Path(file_name)
107107
if not self.output_file.suffix:
108-
self.output_file = self.output_file.with_suffix(".pyav")
109-
elif not self.output_file.match("*.pyav"):
108+
self.output_file = self.output_file.with_suffix(".trc")
109+
elif not self.output_file.match("*.trc"):
110110
raise FileNotFoundError(f"Incorrect output file format: {self.output_file.suffix}")
111111

112112
if not output_data:
@@ -380,10 +380,10 @@ def main(input_file: Path = None, output_file: Path = None, overwrite: bool = Fa
380380

381381
# Check that the output file is usable
382382
if not output_file:
383-
output_file = input_file.with_suffix(".pyav")
383+
output_file = input_file.with_suffix(".trc")
384384
elif not output_file.suffix:
385-
output_file = output_file.with_suffix(".pyav")
386-
elif not output_file.match("*.pyav"):
385+
output_file = output_file.with_suffix(".trc")
386+
elif not output_file.match("*.trc"):
387387
raise FileNotFoundError(f"Incorrect output file format: {output_file}")
388388

389389
# Check if file exists, and if it does if the overwrite flag is used
+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"archiver_url": "http://lcls-archapp.slac.stanford.edu",
3+
"plot": {
4+
"refreshInterval": 0.0,
5+
"title": "",
6+
"xGrid": false,
7+
"yGrid": false,
8+
"opacity": 128,
9+
"backgroundColor": "#ffffff",
10+
"legend": false,
11+
"crosshair": false,
12+
"mouseMode": 1
13+
},
14+
"time_axis": {
15+
"name": "Main Time Axis",
16+
"start": "2024-09-04 11:03:44",
17+
"end": "2024-09-04 12:03:44",
18+
"location": "bottom"
19+
},
20+
"y-axes": [
21+
{
22+
"name": "Axis 1",
23+
"orientation": "left",
24+
"minRange": -1.3843656974520628e-09,
25+
"maxRange": 4.752694382245206e-08,
26+
"autoRange": true,
27+
"logMode": false
28+
},
29+
{
30+
"name": "Axis 2",
31+
"orientation": "left",
32+
"minRange": 9.047133561624635e-10,
33+
"maxRange": 1.3621653831337537e-08,
34+
"autoRange": true,
35+
"logMode": false
36+
},
37+
{
38+
"name": "Axis 3",
39+
"orientation": "left",
40+
"minRange": 1.3015564414604301e-08,
41+
"maxRange": 4.65547480853957e-08,
42+
"autoRange": true,
43+
"logMode": false
44+
},
45+
{
46+
"name": "Axis 4",
47+
"orientation": "left",
48+
"minRange": -1.04,
49+
"maxRange": 1.04,
50+
"autoRange": true,
51+
"logMode": false
52+
}
53+
],
54+
"curves": [
55+
{
56+
"useArchiveData": true,
57+
"liveData": true,
58+
"channel": "KLYS:LI22:31:KVAC",
59+
"name": "KLYS:LI22:31:KVAC",
60+
"color": "#008cf9",
61+
"lineStyle": 1,
62+
"lineWidth": 1,
63+
"symbolSize": 10,
64+
"yAxisName": "Axis 1",
65+
"thresholdColor": "white"
66+
},
67+
{
68+
"useArchiveData": true,
69+
"liveData": true,
70+
"channel": "KLYS:LI22:41:KVAC",
71+
"name": "KLYS:LI22:41:KVAC",
72+
"color": "#006e00",
73+
"lineStyle": 1,
74+
"lineWidth": 1,
75+
"symbolSize": 10,
76+
"yAxisName": "Axis 1",
77+
"thresholdColor": "white"
78+
}
79+
],
80+
"formula": [
81+
{
82+
"useArchiveData": true,
83+
"liveData": true,
84+
"plot_style": "Line",
85+
"formula": "f://{A}+{B}",
86+
"curveDict": {
87+
"A": "KLYS:LI22:31:KVAC",
88+
"B": "KLYS:LI22:41:KVAC"
89+
},
90+
"name": "f://{A}+{B}",
91+
"color": "#b80058",
92+
"lineStyle": 1,
93+
"lineWidth": 1,
94+
"symbolSize": 10,
95+
"yAxisName": "Axis 1",
96+
"thresholdColor": "white"
97+
}
98+
]
99+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"archiver_url": "http://lcls-archapp.slac.stanford.edu",
3+
"plot": {
4+
"refreshInterval": 0.0,
5+
"title": "Very Cool Title",
6+
"xGrid": true,
7+
"yGrid": true,
8+
"opacity": 255,
9+
"backgroundColor": "#ffffff",
10+
"legend": false,
11+
"crosshair": false,
12+
"mouseMode": 1
13+
},
14+
"time_axis": {
15+
"name": "Main Time Axis",
16+
"start": "2024-09-04 11:20:09",
17+
"end": "2024-09-04 12:20:13",
18+
"location": "bottom"
19+
},
20+
"y-axes": [
21+
{
22+
"name": "Axis 1",
23+
"orientation": "left",
24+
"minRange": 7.655507359823855e-09,
25+
"maxRange": 3.336011764017615e-08,
26+
"autoRange": true,
27+
"logMode": false
28+
},
29+
{
30+
"name": "Axis 2",
31+
"orientation": "left",
32+
"minRange": -1.04,
33+
"maxRange": 1.04,
34+
"autoRange": true,
35+
"logMode": false
36+
}
37+
],
38+
"curves": [
39+
{
40+
"useArchiveData": true,
41+
"liveData": true,
42+
"channel": "KLYS:LI22:31:KVAC",
43+
"name": "KLYS:LI22:31:KVAC",
44+
"color": "#008cf9",
45+
"lineStyle": 1,
46+
"lineWidth": 1,
47+
"symbolSize": 10,
48+
"yAxisName": "Axis 1",
49+
"thresholdColor": "white"
50+
}
51+
],
52+
"formula": []
53+
}

archive_viewer/mixins/file_io.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def export_save_file(self) -> None:
2222
"""Prompt the user for a file to export config data to"""
2323
file_name, _ = QFileDialog.getSaveFileName(self, "Save Archive Viewer",
2424
str(self.io_path),
25-
"Python Archive Viewer (*.pyav)")
25+
"Python Archive Viewer (*.trc)")
2626
file_name = Path(file_name)
2727
if file_name.is_dir():
2828
logger.warning("No file name provided to export save file to")
@@ -42,7 +42,7 @@ def import_save_file(self, file_name: str | Path = None) -> None:
4242
if not file_name:
4343
file_name, _ = QFileDialog.getOpenFileName(self, "Open Archive Viewer",
4444
str(self.io_path),
45-
"Python Archive Viewer (*.pyav);;"
45+
"Python Archive Viewer (*.trc);;"
4646
+ "Java Archive Viewer (*.xml);;"
4747
+ "All Files (*)")
4848
file_name = Path(file_name)

0 commit comments

Comments
 (0)