apstrim 4.2.2__tar.gz → 4.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. apstrim-4.3.0/PKG-INFO +117 -0
  2. apstrim-4.3.0/README.md +101 -0
  3. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/__main__.py +2 -2
  4. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/apstrim.py +11 -21
  5. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/view.py +184 -210
  6. {apstrim-4.2.2 → apstrim-4.3.0}/pyproject.toml +4 -3
  7. apstrim-4.2.2/PKG-INFO +0 -99
  8. apstrim-4.2.2/README.md +0 -82
  9. apstrim-4.2.2/apstrim.aps +0 -0
  10. apstrim-4.2.2/apstrim_20251014_1140.aps +0 -0
  11. apstrim-4.2.2/apstrim_20251014_1257.aps +0 -0
  12. apstrim-4.2.2/apstrim_20251014_1325.aps +0 -0
  13. apstrim-4.2.2/apstrim_20251014_1411.aps +0 -0
  14. apstrim-4.2.2/apstrim_20251014_1429.aps +0 -0
  15. apstrim-4.2.2/apstrim_20251014_1431.aps +0 -0
  16. apstrim-4.2.2/apstrim_20251014_1437.aps +0 -0
  17. apstrim-4.2.2/apstrim_20251014_1438.aps +0 -0
  18. apstrim-4.2.2/apstrim_20251014_1439.aps +0 -0
  19. apstrim-4.2.2/cad_env/__init__.py +0 -1
  20. apstrim-4.2.2/cad_env/cad_env +0 -1
  21. apstrim-4.2.2/cad_env/screenlock_user.py +0 -51
  22. apstrim-4.2.2/cad_error/__init__.py +0 -11
  23. apstrim-4.2.2/cad_error/base.py +0 -13
  24. apstrim-4.2.2/cad_error/rhic_errors.py +0 -1752
  25. apstrim-4.2.2/cad_io/__init__.py +0 -0
  26. apstrim-4.2.2/cad_io/adoIf.py +0 -1436
  27. apstrim-4.2.2/cad_io/adoaccess.py +0 -476
  28. apstrim-4.2.2/cad_io/am.py +0 -2483
  29. apstrim-4.2.2/cad_io/ampy.py +0 -758
  30. apstrim-4.2.2/cad_io/cns.py +0 -158
  31. apstrim-4.2.2/cad_io/declarative_manager.py +0 -1617
  32. apstrim-4.2.2/cad_io/epicsAccess_caproto.py +0 -216
  33. apstrim-4.2.2/cad_io/liteAccess.py +0 -664
  34. apstrim-4.2.2/cad_io/liteCNS.py +0 -33
  35. apstrim-4.2.2/cad_io/notif.py +0 -200
  36. apstrim-4.2.2/cad_io/numpyAccess.py +0 -31
  37. apstrim-4.2.2/cad_io/project_url.py +0 -20
  38. apstrim-4.2.2/cad_io/rpc.py +0 -900
  39. apstrim-4.2.2/cad_io/setHistory.py +0 -309
  40. apstrim-4.2.2/data/apstrim.aps +0 -0
  41. apstrim-4.2.2/data/apstrim_100Hz_10Items.aps +0 -0
  42. apstrim-4.2.2/data/apstrim_100Hz_oneItem.aps +0 -0
  43. apstrim-4.2.2/data/apstrim_am_simple_array_simple.test.sinM.aps +0 -0
  44. {apstrim-4.2.2 → apstrim-4.3.0}/CHANGELOG.md +0 -0
  45. {apstrim-4.2.2 → apstrim-4.3.0}/LICENSE +0 -0
  46. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/__init__.py +0 -0
  47. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/cad_pvaccess.py +0 -0
  48. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/helpTxtView.py +0 -0
  49. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/liteCNS.py +0 -0
  50. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/pubEPICS.py +0 -0
  51. {apstrim-4.2.2 → apstrim-4.3.0}/apstrim/scan.py +0 -0
  52. {apstrim-4.2.2 → apstrim-4.3.0}/config/peaksim_pvp.py +0 -0
  53. {apstrim-4.2.2 → apstrim-4.3.0}/docs/_config.yml +0 -0
  54. {apstrim-4.2.2 → apstrim-4.3.0}/docs/apstrim.html +0 -0
  55. {apstrim-4.2.2 → apstrim-4.3.0}/docs/apstrim_file_format.png +0 -0
  56. {apstrim-4.2.2 → apstrim-4.3.0}/docs/scan.html +0 -0
apstrim-4.3.0/PKG-INFO ADDED
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.5
2
+ Name: apstrim
3
+ Version: 4.3.0
4
+ Summary: Logger and extractor of time-series data (e.g. EPICS PVs or liteServer LDOs).
5
+ Project-URL: Homepage, https://github.com/ASukhanov/apstrim
6
+ Project-URL: Bug Tracker, https://github.com/ASukhanov/apstrim/issues
7
+ Author-email: Andrey Sukhanov <cyxandr@gmail.com>
8
+ License-File: LICENSE
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.7
13
+ Requires-Dist: liteaccess
14
+ Requires-Dist: msgpack
15
+ Description-Content-Type: text/markdown
16
+
17
+ # apstrim
18
+
19
+ Logger and extractor of time-series data (e.g. EPICS PVs).
20
+
21
+ - Data are objects indexed in time order.
22
+ - Supported control infrastructures: EPICS Channel Access + PV Access, ADO, and LITE. Easily extendable.
23
+ - Wide range of data objects: strings, lists, maps, NumPy arrays, and custom types.
24
+ - Data objects can be inhomogeneous and have arbitrary frequencies.
25
+ - Self-describing data format; no schema is required.
26
+ - Data objects are binary serialized using MessagePack.
27
+ - Fast online compression.
28
+ - Fast random-access retrieval of data objects for a selected time interval.
29
+ - Simultaneous writing and reading.
30
+ - Typical speed of compressed serialization to a logbook file is 80 MB/s.
31
+ - Deserialization speed is up to 1200 MB/s when the logbook is cached in memory.
32
+ - Basic plotting of logged data.
33
+
34
+ <img src="/docs/apstrim_file_format.png" width="400">
35
+
36
+ ## Installation
37
+
38
+ Main dependency: **msgpack,numpy**
39
+
40
+ Additional dependencies:
41
+ - **lz4framed**, if compression is enabled
42
+ - EPICS PV Access requires **p4p**.
43
+ - EPICS Channel Access requires **caproto**.
44
+ - The program for deserialization and plotting, **apstrim.view**, requires **pyqtgraph**.
45
+
46
+
47
+ ```console
48
+ pip3 install apstrim
49
+ ```
50
+
51
+ ## API reference
52
+
53
+ [apstrim](https://htmlpreview.github.io/?https://github.com/ASukhanov/apstrim/blob/main/docs/apstrim.html)
54
+
55
+ [scan](https://htmlpreview.github.io/?https://github.com/ASukhanov/apstrim/blob/main/docs/scan.html)
56
+
57
+ ## Examples
58
+
59
+ ### Serialization
60
+
61
+ ```console
62
+ # Serialization of one float64 parameter from an EPICS simulated scope IOC:
63
+ python -m apstrim -nEPICS -T59 testAPD:scope1:MeanValue_RBV
64
+ Logging finished for 1 section, 1 parList, 7.263 KB.
65
+ ...
66
+
67
+ # The same with compression:
68
+ python -m apstrim -nEPICS -T59 testAPD:scope1:MeanValue_RBV --compress
69
+ Logging finished for 1 section, 1 parList, 6.101 KB. Compression ratio: 1.19
70
+ ...
71
+
72
+ # Serialization of a 1000-element array and a scalar of floats:
73
+ python -m apstrim -nEPICS -T59 testAPD:scope1:MeanValue_RBV,Waveform_RBV --compress
74
+ Logging finished for 1 section, 2 parLists, 2405.354 KB. Compression ratio: 1.0
75
+ ...
76
+ # Compression is poor for floating-point arrays with high entropy.
77
+
78
+ # Serialization of an incrementing integer parameter:
79
+ python -m apstrim -nLITE --compress liteHost:dev1:cycle
80
+ Logging finished for 1 section, 1 parList, 56.526 KB. Compression ratio: 1.25
81
+ ...
82
+ # In this case, the normalized compressed volume is 9.3 bytes per entry.
83
+ # Each entry consists of an int64 timestamp and an int64 value, which would
84
+ # occupy 16 bytes per entry when written using the standard format.
85
+ ```
86
+
87
+ ### Deserialization
88
+
89
+ Example of deserializing and plotting all parameters from several logbooks:
90
+
91
+ ```console
92
+ python -m apstrim.view -i all -p '*.aps'
93
+ ```
94
+
95
+ Python code snippet for extracting items 1, 2, and 3 from a logbook
96
+ for a 20-second interval starting on 2021-08-12 at 23:31:31:
97
+
98
+ ```python
99
+ from apstrim.scan import APScan
100
+
101
+ apscan = APScan("aLogbook.aps")
102
+ headers = apscan.get_headers()
103
+ print(headers["Index"])
104
+ extracted = apscan.extract_objects(
105
+ span=20,
106
+ items=[1, 2, 3],
107
+ startTime="210812_233131",
108
+ )
109
+ print(extracted[3]) # Print the extracted data for item [3]
110
+ # Returned:
111
+ {
112
+ "par": "liteBridge.peakSimulator:rps", # object (PV) name of item [3]
113
+ "times": [1628825500.8938403, 1628825510.898658], # timestamps for item [3]
114
+ "values": [95.675125, 95.55396], # values for item [3]
115
+ }
116
+ ```
117
+
@@ -0,0 +1,101 @@
1
+ # apstrim
2
+
3
+ Logger and extractor of time-series data (e.g. EPICS PVs).
4
+
5
+ - Data are objects indexed in time order.
6
+ - Supported control infrastructures: EPICS Channel Access + PV Access, ADO, and LITE. Easily extendable.
7
+ - Wide range of data objects: strings, lists, maps, NumPy arrays, and custom types.
8
+ - Data objects can be inhomogeneous and have arbitrary frequencies.
9
+ - Self-describing data format; no schema is required.
10
+ - Data objects are binary serialized using MessagePack.
11
+ - Fast online compression.
12
+ - Fast random-access retrieval of data objects for a selected time interval.
13
+ - Simultaneous writing and reading.
14
+ - Typical speed of compressed serialization to a logbook file is 80 MB/s.
15
+ - Deserialization speed is up to 1200 MB/s when the logbook is cached in memory.
16
+ - Basic plotting of logged data.
17
+
18
+ <img src="/docs/apstrim_file_format.png" width="400">
19
+
20
+ ## Installation
21
+
22
+ Main dependency: **msgpack,numpy**
23
+
24
+ Additional dependencies:
25
+ - **lz4framed**, if compression is enabled
26
+ - EPICS PV Access requires **p4p**.
27
+ - EPICS Channel Access requires **caproto**.
28
+ - The program for deserialization and plotting, **apstrim.view**, requires **pyqtgraph**.
29
+
30
+
31
+ ```console
32
+ pip3 install apstrim
33
+ ```
34
+
35
+ ## API reference
36
+
37
+ [apstrim](https://htmlpreview.github.io/?https://github.com/ASukhanov/apstrim/blob/main/docs/apstrim.html)
38
+
39
+ [scan](https://htmlpreview.github.io/?https://github.com/ASukhanov/apstrim/blob/main/docs/scan.html)
40
+
41
+ ## Examples
42
+
43
+ ### Serialization
44
+
45
+ ```console
46
+ # Serialization of one float64 parameter from an EPICS simulated scope IOC:
47
+ python -m apstrim -nEPICS -T59 testAPD:scope1:MeanValue_RBV
48
+ Logging finished for 1 section, 1 parList, 7.263 KB.
49
+ ...
50
+
51
+ # The same with compression:
52
+ python -m apstrim -nEPICS -T59 testAPD:scope1:MeanValue_RBV --compress
53
+ Logging finished for 1 section, 1 parList, 6.101 KB. Compression ratio: 1.19
54
+ ...
55
+
56
+ # Serialization of a 1000-element array and a scalar of floats:
57
+ python -m apstrim -nEPICS -T59 testAPD:scope1:MeanValue_RBV,Waveform_RBV --compress
58
+ Logging finished for 1 section, 2 parLists, 2405.354 KB. Compression ratio: 1.0
59
+ ...
60
+ # Compression is poor for floating-point arrays with high entropy.
61
+
62
+ # Serialization of an incrementing integer parameter:
63
+ python -m apstrim -nLITE --compress liteHost:dev1:cycle
64
+ Logging finished for 1 section, 1 parList, 56.526 KB. Compression ratio: 1.25
65
+ ...
66
+ # In this case, the normalized compressed volume is 9.3 bytes per entry.
67
+ # Each entry consists of an int64 timestamp and an int64 value, which would
68
+ # occupy 16 bytes per entry when written using the standard format.
69
+ ```
70
+
71
+ ### Deserialization
72
+
73
+ Example of deserializing and plotting all parameters from several logbooks:
74
+
75
+ ```console
76
+ python -m apstrim.view -i all -p '*.aps'
77
+ ```
78
+
79
+ Python code snippet for extracting items 1, 2, and 3 from a logbook
80
+ for a 20-second interval starting on 2021-08-12 at 23:31:31:
81
+
82
+ ```python
83
+ from apstrim.scan import APScan
84
+
85
+ apscan = APScan("aLogbook.aps")
86
+ headers = apscan.get_headers()
87
+ print(headers["Index"])
88
+ extracted = apscan.extract_objects(
89
+ span=20,
90
+ items=[1, 2, 3],
91
+ startTime="210812_233131",
92
+ )
93
+ print(extracted[3]) # Print the extracted data for item [3]
94
+ # Returned:
95
+ {
96
+ "par": "liteBridge.peakSimulator:rps", # object (PV) name of item [3]
97
+ "times": [1628825500.8938403, 1628825510.898658], # timestamps for item [3]
98
+ "values": [95.675125, 95.55396], # values for item [3]
99
+ }
100
+ ```
101
+
@@ -18,8 +18,8 @@ def main():
18
18
  #'Disable conversion of float64 to float32')
19
19
  #parser.add_argument('-f', '--file', default=None, help=\
20
20
  #'Configuration file')
21
- parser.add_argument('-o', '--outfile', default='apstrim.aps', help=\
22
- 'Logbook file for storing PVs and data objects')
21
+ parser.add_argument('-o', '--outfile', default='apstrim', help=\
22
+ 'Prefix of the logbook file for storing PVs and data objects, the file name will have form: prefix_yyyymmdd_hhmm.aps')
23
23
  parser.add_argument('-n', '--namespace', default='EPICS',
24
24
  choices=['EPICS', 'PVAccess', 'ADO', 'LITE'], help=
25
25
  'Infrastructure namespace')
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # https://github.com/ASukhanov/apstrim/blob/main/LICENSE
8
8
  #
9
- __version__ = '4.2.2 2025-10-15' # Do not _safeExit() in _serialize_sections()
9
+ __version__ = '4.2.3 2025-10-17' # 1)do not safe_exit() after serialize, 2)output file name have form: prefix_yyyymmdd_hhmm.aps
10
10
 
11
11
  import sys, time, string, copy
12
12
  import os, pathlib, datetime
@@ -88,9 +88,8 @@ def packnp(key, data, use_single_float=True):
88
88
  try:
89
89
  npdata = np.array(data)
90
90
  except Exception as e:
91
- printe(f'In packnp: {e}')
92
- sys.exit()
93
- return data
91
+ printw(f'In packnp of item {key}: {e}')
92
+ return None
94
93
  #print(f'npdata shape: {npdata.shape} of {npdata.dtype}')
95
94
  if npdata.shape == ():
96
95
  return data
@@ -230,29 +229,20 @@ class apstrim():
230
229
  pvname = f'{pvname}[{pslice[0]}:{pslice[1]}]'
231
230
  pvlist.append(pvname)
232
231
  self.indexSection = encoderDump({'index':pvlist})
233
- printi(f'IndexSection: {self.indexSection}')
232
+ #printi(f'IndexSection: {self.indexSection}')
234
233
 
235
- def start(self, fileName='apstrim.aps', howLong=99e6):
234
+ def start(self, prefix='apstrim', howLong=99e6):
236
235
  """Start the streaming of the data objects to the logbook file.
237
- If file is already exists then it will be renamed and
238
- a new file will be open with the provided name.
239
-
236
+ prefix: the file name will have form: prefix_yyyymmdd_hhmm.aps
240
237
  **howLong**: Time interval (seconds) for data collection.
241
238
  """
242
239
  self._eventStop.clear()
243
240
  self.howLong = howLong
244
- fileName = os.path.expanduser(fileName)
245
- try:
246
- modificationTime = pathlib.Path(fileName).stat().st_mtime
247
- dt = datetime.datetime.fromtimestamp(modificationTime)
248
- suffix = dt.strftime('_%Y%m%d_%H%M')
249
- try: fname,ext = fileName.rsplit('.',1)
250
- except: fname,ext = fileName,''
251
- otherName = fname + suffix + '.' + ext
252
- os.rename(fileName, otherName)
253
- printw(f'Existing file {fileName} have been renamed to {otherName}')
254
- except Exception as e:
255
- pass
241
+ #modificationTime = pathlib.Path(fileName).stat().st_mtime
242
+ #dt = datetime.datetime.fromtimestamp(modificationTime)
243
+ #suffix = dt.strftime('_%Y%m%d_%H%M')
244
+ suffix = time.strftime('_%Y%m%d_%H%M.aps')
245
+ fileName = os.path.expanduser(prefix+suffix)
256
246
 
257
247
  self.logbook = open(fileName, 'wb')
258
248