Metadata-Version: 2.3
Name: xrench
Version: 0.1.2
Summary: Utility functions.
Keywords: python
Author: Rob Scheeler
License: MIT License
         
         Copyright (c) 2026, Rob Scheeler
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Dist: pint
Requires-Dist: xarray
Requires-Dist: scipy
Requires-Dist: numpy
Requires-Dist: loguru
Requires-Python: >=3.11, <3.14
Project-URL: homepage, https://github.com/rscheeler/xrench
Project-URL: repository, https://github.com/rscheeler/xrench.git
Project-URL: documentation, https://rscheeler.github.io/xrench
Project-URL: issues, https://github.com/rscheeler/xrench/issues
Description-Content-Type: text/markdown

# 🔧 xrench

Utility functions for [pint](https://pint.readthedocs.io/) and [xarray](https://docs.xarray.dev/) to support RF and microwave design Python tools.

## Installation

```bash
uv add xrench
```

Or with pip:

```bash
pip install xrench
```

## Features

- **Unit-aware arrays** — Seamless integration between `pint` and `xarray` for physical quantities
- **Custom RF units** — Built-in support for dBK (decibel kelvin) and dBHz (decibel hertz)
- **Unit decorator** — `wraps_xr` decorator to strip and re-apply units around functions, preserving xarray coordinates and dimensions
- **Rotation utilities** — Apply `scipy` rotations to coordinate DataArrays, including polarization rotation
- **Logging control** — Mutable/unmutable logger via `XRENCHLogger` for clean library logging

## Usage

### Unit Registry

```python
from xrench.units import ureg

# Use built-in RF units
noise_temp = 290 * ureg.decibelkelvin
bandwidth = 1e6 * ureg.decibelhertz
```

### Convert kwargs to DataArrays

```python
from xrench.xrutils import kw2da

arrays = kw2da(frequency=freq_quantity, angle=angle_array)
```

### Unit-preserving function decorator

```python
from xrench.xrutils import wraps_xr

@wraps_xr(ret_units="meter", arg_units=["meter", "meter"])
def my_func(x, y):
    # work with unit-less DataArrays
    return x + y
```

### Logging

```python
from xrench.logcontrol import XRENCHLogger

XRENCHLogger.unmute()         # enable logs
XRENCHLogger.level = "DEBUG"  # change level
XRENCHLogger.mute()           # silence logs
```

## License

MIT

## Contact

Created by [Rob Scheeler](https://github.com/rscheeler)