Skip to main content

Utility for reading Rhode and Schwarz oscilloscope binary files

Project description

RS file reader

This is a simple libraray for reading and processing binary files generated by Rhode and Schwarz oscilloscopes. There is no affiliation between me and Rode and Schwarz. This library was written by guessing what the content of .bin and Wfm.bin files might mean. It works well for my needs but might fail for many other use cases.

Usage

In the most simple case, you have a .bin file with a single acquisition with a limited number of samples. In this case, processing the data is easy.

from rs_file_reader import RS_File

rs_file=RS_File('my_file.bin')
file_content=rs_file.getAsDf()

file_content now contains a pandas DataFrame which you can easily process.

You migth have used the oscilloscope's history function, e.g. in fast segmentation mode of because you were requesting averaging. In this case, the file might contain multiple acquisitions. If you call getAsDf without parameters you will get all acquistions, one after another. To separate acquisitions, you need to provide an acquisition parameter. E.g. in the following we iterate over all acquistitions:

rs_file=RS_File('my_file.bin')
acquisitions=rs_file.no_acquisitions

for acq in acquisitions:
    content_one_acq=rs_file.getAsDf(acquisition=acq)
    print(content_one_acq)

One of the great features of R&S oscilloscopes is their large memory depth. However, this poses some challenges to processing the generated data. One way to deal with large amounts of data is to process the raw ADC data. For this purpose RS_Fileprovides the method getRaw which will return the data in the format saved by the oscilloscope without further processing. Note that the oscilloscope will only save raw adc data, if you enabled that feature. If saving raw adc data is disabled, getRaw will return floating point numbers as the were saved by the oscilloscope. Note, that again you can access single acquisitions via the acquisition parameter:

rs_file=RS_File('my_file.bin')
for acq in acquisitions:
    content_one_acq=rs_file.getRaw(acquisition=acq)
    print(content_one_acq)

If you have very large files, inspecting them is an issue. RS_analysis provides some functions for inspection. E.g. a 2D histogram can be useful:

from rs_file_reader import RS_File, RS_analysis
from matplotlib import pyplot as plt
rs_file=RS_File('my_file.bin')
rs_analysis=RS_analysis

histogram, extent=det_file.get_2d_histo(source)

dx=extent[1]-extent[0]
dy=extent[3]-extent[2]
    
aspect=dx/dy*0.5
plt.imshow(np.flip(histogram,1).transpose(), aspect=aspect, cmap='gist_stern',  extent=extent)

plt.tight_layout()
    
plt.show()

There is also a small gui for inspection.

from rs_file_reader import plot_gui
plot_gui()

If you have rs_file_reader installed as a package you can also open the gui from the terminal via:

python3 -m rs_file_reader 

RS_File and RS_analysis contain some more functionality. For now documention is availbale in the source code only. Hopefully, I'll soon be able to post a link to sphinx generated documentation.

Development

Unit tests are contained in the tests folder. If you make changes, make sure they pass.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rs_file_reader-0.1.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rs_file_reader-0.1.0-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file rs_file_reader-0.1.0.tar.gz.

File metadata

  • Download URL: rs_file_reader-0.1.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for rs_file_reader-0.1.0.tar.gz
Algorithm Hash digest
SHA256 39d0cf624eec0fb6d46ca30243e45f6e0681ea025c0e9f54eaff56a2a104c2be
MD5 956cadf2b8b339fe86e78f3bc0e5e6a5
BLAKE2b-256 85e78215af26694e0175f5f9975bb66b5ee1912df4aa611ca487e118bbdbda52

See more details on using hashes here.

File details

Details for the file rs_file_reader-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rs_file_reader-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

File hashes

Hashes for rs_file_reader-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 effe318f41ed1e55f2b567be645159f10b316a85af1d6c6bb9d11aba1dafaec5
MD5 fcad1d05b57fdd0b44c8bbeade3a3fa3
BLAKE2b-256 12b42517fa4a10293db6601292c328c9824ad7ed97b9b3b1ce22cf4d650c9f3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page