GithubHelp home page GithubHelp logo

readtrc's Introduction

readTrc

Little Python helper class to read .trc binary files from LeCroy Oscilloscopes. Tested on Python3.

Installation

Just copy the readTrc.py file in your python path.

Usage

from readTrc import Trc
trc = Trc()
fName = "./C1_00000.trc"
datX, datY, d = trc.open(fName)
plot(datX, datY)
print(d)
# Or alternatively
plot(trc.x, trc.y)
print(trc.d)

Note that in the above example d is a dictionary which contains the metadata. For example:

{'ACQ_DURATION': 0.0,
 'ACQ_VERT_OFFSET': 0.0,
 'BANDWIDTH_LIMIT': 'off',
 'FIRST_POINT': 0,
 'FIRST_VALID_PNT': 0,
 'FIXED_VERT_GAIN': '50_mV/div',
 'HORIZ_INTERVAL': 1.6666699270695418e-11,
 'HORIZ_OFFSET': -0.000100000004229008,
 'HORIZ_UNCERTAINTY': 9.999999960041972e-13,
 'HORUNIT': 'S',
 'INSTRUMENT_NAME': 'LECROYSDA18000',
 'INSTRUMENT_NUMBER': 15238,
 'LAST_VALID_PNT': 12000001,
 'MAX_VALUE': 22914.0,
 'MIN_VALUE': -23170.0,
 'NOMINAL_BITS': 8,
 'NOM_SUBARRAY_COUNT': 1,
 'PAIR_OFFSET': 0,
 'PIXEL_OFFSET': -0.0001,
 'PNTS_PER_SCREEN': 12000000,
 'POINTS_PER_PAIR': 0,
 'PROBE_ATT': 1.0,
 'PROCESSING_DONE': 'no_processing',
 'RECORD_TYPE': 'single_sweep',
 'RIS_SWEEPS': 1,
 'SEGMENT_INDEX': 0,
 'SPARSING_FACTOR': 1,
 'SUBARRAY_COUNT': 1,
 'SWEEPS_PER_ACQ': 1,
 'TIMEBASE': '20_us/div',
 'TRACE_LABEL': '',
 'TRIGGER_TIME': datetime.datetime(2015, 9, 10, 17, 5, 19, 127343),
 'USER_TEXT': '',
 'VERTICAL_GAIN': 8.631759556010365e-06,
 'VERTICAL_OFFSET': 0.0,
 'VERTICAL_VERNIER': 1.0,
 'VERTUNIT': 'V',
 'VERT_COUPLING': 'DC_50_Ohms',
 'WAVE_ARRAY_COUNT': 12000002,
 'WAVE_SOURCE': 0}

See here for more details.

readtrc's People

Contributors

michael-betz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

readtrc's Issues

Usage with pyvisa

Hi!

How can you use this script with pyvisa, where you directly import data in form of bytes and not in the binary form you get when loading file?

Br Kristian

arrays from trc files are twice the size

Hi,
Thanks for the script to read the *.trc files. But when i copied the file to the folder and read the data, i used to get arrays (x,y) of twice the length that they are supposed to be. I attach a sample .trc file.
Can you please help me to solve it.
Thanks
Nitesh
C1.zip

.Trc file from labnotebook results in 'UnicodeDecodeError'

Hi @yetifrisstlama ,
Thanks for the script! I used it with a directly exported .trc file first, but I also wanted to use data I exported as labnotebook (.lnb). So I was able to unpack the notebook, but the contained .trc file can not be read via readTrc().

UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-39-f7bc7e777e0d> in <module>()
      1 
      2 fName = "MyLabNotebook--00000/C4.trc"
----> 3 datX, datY, m = readTrc.readTrc( fName )

~\path\to\readTrc.py in readTrc(fName)
     61         # Get Instrument info
     62         #------------------------
---> 63         d["INSTRUMENT_NAME"]  = readX( fid, "16s",    wdOffset + 76 ).decode().split('\x00')[0]
     64         d["INSTRUMENT_NUMBER"]= readX( fid, endi+"l", wdOffset + 92 )
     65         d["TRACE_LABEL"]      = readX( fid, "16s",    wdOffset + 96 ).decode().split('\x00')[0]

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 12: invalid continuation byte

I would try to fix this on my own, but I don't where to look for. For sure, it's line 63 in the source code, but I don't know what's the difference between the pure .trc file and the extracted one.

Of course I could use wavestudio to export the data from the labnotebook as csv. But it would be handy to skip that step.

Instrument used: LECROYWR640Zi

Shifted x-values

Hi, and thank you very much for the useful script.
I compared the return values with the original file on my Lecroy WaveRunner, and found that the x-values were all shifted by one HORIZ_INTERVAL.
It worked fine after I change row 181 to
x = np.arange(len(y), dtype=float)
Thanks!
Yona.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.