Metadata-Version: 2.4
Name: otdrparser
Version: 0.2.0
Summary: Python library for parsing OTDR files in Telcordia SR-4731 Version 2 format
Author-email: Markus Juenemann <markus@juenemann.net>
Description-Content-Type: text/markdown
License-File: LICENSE
Project-URL: Home, https://github.com/mjuenema/otdrparser

# otdrparser

**otdrparser** is a Python library for parsing OTDR traces in Telcordia SR-4731 Version 2 format (```*.sor``` files).

It is a simplified re-implementation of the [pyOTDR](https://github.com/sid5432/pyOTDR) project. Its author, Hsin-Yu Sidney Li, together with several others deserve a lot of credit for [reverse-engineering](https://morethanfootnotes.blogspot.com/2015/07/the-otdr-optical-time-domain.html) 
the Telcordia SR-4731 standard as it is not freely available. 

The **otdrparser** library differs from the **pyOTDR** project in multiple ways.
* It's just a single class with a ``.parse2()`` method (and a now legacy ``parse()`` method).
* It only supports Version 2 of the Telcordia SR-4731 standard.
* It is assumed that the OTDR file contains only a single trace.
* The checksum block is read but not verified.
* No attempt is made to accomodate vendor specific blocks.
* I am certain **otdrparser** contains bugs. Please open a Github Issue if you find any.

The **otdrparser** library consists of a single class with a ``.parse2()`` method.
```python
import otdrparser
with open('my_trace_file.sor', 'rb') as fp:
    blocks = otdrparser.parse2(fp)
```

* Each "block" has a ```name``` attribute which describes its type.
* The ``.parse2()`` method returns the parsed trace file as a dictionary, keyed by the name of the block.
* Data points are included as a list of (distance, dBm) pairs.
* Vendor proprietary blocks are included as raw bytes.
* Some data is interpreted. For example ```fibre_type=652``` is also interpreted as ```"ITU-T G.652 (standard single-mode fiber)"```

Output of the ``.parse2()`` method converted into JSON: [example-parse2.json](example-parse2.json).

The ``otdrparser.parse()`` method is now considered legacy. It returns the blocks as a list.

Output of the ``.parse()`` method converted into JSON: [example-parse.json](example-parse.json).

