Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Updated Readme and docstrings #7

Merged
merged 12 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 64 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,87 @@
![Scio Logo](https://d347awuzx0kdse.cloudfront.net/vicomaus/content-image/Tek_Logo_RGB.png){width="50px"}
<div markdown="1" class="custom-badge-table">

# tm_data_types
| | |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Testing** | [![Code testing status](https://github.com/tektronix/tm_data_types/actions/workflows/test-code.yml/badge.svg?branch=main)](https://github.com/tektronix/tm_data_types/actions/workflows/test-code.yml) [![Docs testing status](https://github.com/tektronix/tm_data_types/actions/workflows/test-docs.yml/badge.svg?branch=main)](https://github.com/tektronix/tm_data_types/actions/workflows/test-docs.yml) [![Coverage status](https://codecov.io/gh/tektronix/tm_data_types/branch/main/graph/badge.svg)](https://codecov.io/gh/tektronix/tm_data_types) |
| **Code Quality** | [![CodeQL status](https://github.com/tektronix/tm_data_types/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/tektronix/tm_data_types/actions/workflows/codeql-analysis.yml) [![CodeFactor grade](https://www.codefactor.io/repository/github/tektronix/tm_data_types/badge)](https://www.codefactor.io/repository/github/tektronix/tm_data_types) [![pre-commit status](https://results.pre-commit.ci/badge/github/tektronix/tm_data_types/main.svg)](https://results.pre-commit.ci/latest/github/tektronix/tm_data_types/main) |
| **Package** | [![PyPI: Package status](https://img.shields.io/pypi/status/tm_data_types?logo=pypi)](https://pypi.org/project/tm_data_types/) [![PyPI: Latest release version](https://img.shields.io/pypi/v/tm_data_types?logo=pypi)](https://pypi.org/project/tm_data_types/) [![PyPI: Supported Python versions](https://img.shields.io/pypi/pyversions/tm_data_types?logo=python)](https://pypi.org/project/tm_data_types/) [![PyPI: Downloads](https://pepy.tech/badge/tm_data_types)](https://pepy.tech/project/tm_data_types) [![License: Apache 2.0](https://img.shields.io/pypi/l/tm_data_types)](https://github.com/tektronix/tm_data_types/blob/main/LICENSE.md) [![Package build status](https://github.com/tektronix/tm_data_types/actions/workflows/package-build.yml/badge.svg?branch=main)](https://github.com/tektronix/tm_data_types/actions/workflows/package-build.yml) [![PyPI upload status](https://github.com/tektronix/tm_data_types/actions/workflows/package-release.yml/badge.svg?branch=main)](https://github.com/tektronix/tm_data_types/actions/workflows/package-release.yml) |
| **Documentation** | [![ReadtheDocs Status](https://img.shields.io/readthedocs/tm_data_types/stable?logo=readthedocs)](https://tm_data_types.readthedocs.io/stable) |
| **Code Style** | [![Test style: pytest](https://img.shields.io/badge/test%20style-pytest-blue)](https://github.com/pytest-dev/pytest) [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-black)](https://docs.astral.sh/ruff/formatter/) [![Docstring style: google](https://img.shields.io/badge/docstring%20style-google-tan)](https://google.github.io/styleguide/pyguide.html) |
| **Linting** | [![pre-commit enabled](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit) [![Docstring formatter: docformatter](https://img.shields.io/badge/docstring%20formatter-docformatter-tan)](https://github.com/PyCQA/docformatter)[![Linter: pylint](https://img.shields.io/badge/linter-pylint-purple)](https://github.com/pylint-dev/pylint) |

## Purpose
</div>

Python Instrument IO can be used to:
---

- **Convert** CSV, WFM, and BIN format into the waveform object format,
- **Generate** analog waveforms with NRZ or PAM4 signal processes,
# tm_data_types: Test & Measurement Data Types

`tm_data_types` provides tools to convert, edit, and write waveform data from Test & Measurement devices.
It simplifies handling waveform formats like CSV, WFM, and BIN in Python.

`tm_data_types` can be used to:

- **Convert** CSV, WFM, and BIN format into a waveform object,
- **Add or edit** waveform metadata,
- **Write** a valid waveform object to a file.

This interface assists the client and development team in parsing the format from Tek instrument and construct a
python object with features. The API is funneled into a single Python file, \[InstrumentIO\]{.title-ref}, which contains
all the functions required to read, write, and generate various instrument data.
## Supported File Formats

For additional documentation, visit our Wiki page.
<div markdown="1" class="custom-table-center-cells support-table">

- Supported files for reader interface function include: '.wfm', '.bin', '.csv', '.awg_wfm'
- Supported files for writer interface function include: '.wfm', '.csv', '.awg_wfm'
| Interface | File formats |
| --------- | ------------------------------ |
| Reader | **.wfm, .bin, .csv, .awg_wfm** |
| Writer | **.wfm, .csv, .awg_wfm** |

## Quick Start
</div>

Requirements: [Python 3.0 or above](https://www.python.org/download/releases/3.0/)
> [!NOTE]
> Currently `tm_data_types` supports only Tektronix proprietary [.wfm format](https://download.tek.com/manual/Waveform-File-Format-Manual-077022011.pdf)
u625355 marked this conversation as resolved.
Show resolved Hide resolved

Installed Library: \[datatime\]{.title-ref}, \[struct\]{.title-ref},
\[numpy\]{.title-ref}, \[scipy\]{.title-ref}, \[pandas\]{.title-ref} (Test waveform plot with \[matplotlib\]{.title-ref})
## Installation

```bash
```shell
pip install tm_data_types
```

## Waveform Object Attributes

- `._vertical_data` → An array of binary values.
- `._size` → The size of the vertical data. Read-only, must be an integer.
- `._spacing` → The horizontal interval between two consecutive vertical data points. Must be an integer or float.
- `._trigger_index` →
- `.vertical_data` → vertical data
- `.horizontal_data` → horizontal data
- `.time_interval` → time intervals across vertical data
- `.trigger_position` → trigger position

## Examples

- `read_file_channels(file_path)` → return lists of channels for csv file only
- `read_file(file_path, channel (opt.))` → return waveform object
- `write_file(waveform obj, file_path, instrument_type (opt.))` → write file with extension format
- `initialize_waveform(size (opt.), sample_rate (opt.))` → return simple waveform with size and sample rate.
- `create_unique_filepath(file_path, file_template)` → return unique file path for converted/created file
- `random_bits(size)` → returns a random array of values 1 or 0 of user-inputted size.
- `random_symbols(size)` → returns a random array of values between 0 and 3 of user-inputted size.
- `nrz(bit_array, symbol_rate=1.0e9, sample_per_ui=10.12345, amplitude=1., offset=0.0, impairment=0.2, noise=0.01, repeats=1)`
→ return NRZ waveform object based on user-inputted bit array. Array could be derived from InstrumentIO's \[random_bits\]{.title-ref} function, or from some other random number generator specified by the user (i.e. PBRS).
- `pam4(symbol_arr, data_rate=1.0e9, sample_per_ui=10.12345, amplitude=1.0, offset=0.0, impairment=0.2, noise=0.01, repeats=1)`
→ return PAM4 waveform object based on user-inputted symbol array. Array could be derived from InstrumentIO's \[random_symbols\]{.title-ref} function, or from some other random number generator specified by the user (i.e. PBRS).
- `square(frequency=1000, repeat=5, amplitude=1, rec_length=1000)` → return square waveform object.
- `sawtooth(frequency=1000, repeat=5, amplitude=1, rec_length=1000)` → return sawtooth waveform object.
- `triangle(frequency=1000, repeat=5, amplitude=1, rec_length=1000)` → return triangle waveform object.
## Basic Usage

## Maintainers
### Write File
u625355 marked this conversation as resolved.
Show resolved Hide resolved

.. TODO: update email - [email protected] - For technical support and questions.
```python
from tm_data_types import AnalogWaveform, write_file

- <[email protected]> - For open-source policy and license questions.
- Keith Rule <[email protected]>
waveform = AnalogWaveform()
file_path = "waveform_1.wfm"
write_file(file_path, waveform)
```

### Read File

For more information about this repository, you can leave a question/comment on the [repository's Discussion board](https://github.com/tektronix/PythonInstrumentIO/discussions).
```python
from tm_data_types import read_file

file_path = "waveform_1.wfm"
waveform = read_file(file_path)
```

## Documentation

See the full documentation at <https://tm_data_types.readthedocs.io/stable/>

## Maintainers

Before reaching out to any maintainers directly, please first check if
your issue or question is already covered by any [open
issues](https://github.com/tektronix/tm_data_types/issues). If the issue or
question you have is not already covered, please [file a new
issue](https://github.com/tektronix/tm_data_types/issues/new/choose) or
start a
[discussion](https://github.com/tektronix/tm_data_types/discussions) and
the maintainers will review and respond there.

- <[email protected]> - For open-source policy and license
questions.

## Contributing

Expand All @@ -90,10 +105,3 @@ The artifact attestations can also be directly downloaded from the
```shell
gh attestation verify --owner tektronix <file>
```

## Credits

`tm_data_types` was created with
[cookiecutter](https://cookiecutter.readthedocs.io/en/latest/README.html)
and the `py-pkgs-cookiecutter`
[template](https://py-pkgs-cookiecutter.readthedocs.io/en/latest/).
6 changes: 6 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%
include-markdown "../CHANGELOG.md"
comments=false
rewrite-relative-urls=false

%}
6 changes: 6 additions & 0 deletions docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%
include-markdown "../CODE_OF_CONDUCT.md"
comments=false
rewrite-relative-urls=false

%}
6 changes: 6 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%
include-markdown "../CONTRIBUTING.md"
comments=false
rewrite-relative-urls=false

%}
8 changes: 8 additions & 0 deletions docs/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# License

{%
include-markdown "../LICENSE.md"
comments=false
rewrite-relative-urls=false

%}
16 changes: 8 additions & 8 deletions docs/_static/css/theme_overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@
white-space: nowrap !important;
}

.rst-content table.device-support-table.docutils thead {
.rst-content table.support-table.docutils thead {
vertical-align: middle;

.line-block {
margin-bottom: 0;
}
}

.device-support-table thead, .device-support-table tbody {
.support-table thead, .support-table tbody {
border: 2px solid black
}

.device-support-table table {
.support-table table {
width: auto !important;
display: table !important;
margin: auto !important;
}

.device-support-table.docutils tbody tr:has(th p),
.device-support-table tr:has(td:first-child:not(:empty)) {
.support-table.docutils tbody tr:has(th p),
.support-table tr:has(td:first-child:not(:empty)) {
border-top-width: 2px;
border-top-color: black;
border-top-style: solid;
}

.device-support-table tbody td[rowspan] {
.support-table tbody td[rowspan] {
background-color: transparent !important;
}

.device-support-table table td:first-child,
.device-support-table table th:first-child {
.support-table table td:first-child,
.support-table table th:first-child {
font-weight: bolder;
background-color: transparent !important;
}
Expand Down
Loading