Skip to main content

Utility functions.

Project description

🔧 xrench

Utility functions for pint and xarray to support RF and microwave design Python tools.

Installation

uv add xrench

Or with pip:

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 decoratorwraps_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

from xrench.units import ureg

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

Convert kwargs to DataArrays

from xrench.xrutils import kw2da

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

Unit-preserving function decorator

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

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

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

xrench-0.1.2.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

xrench-0.1.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file xrench-0.1.2.tar.gz.

File metadata

  • Download URL: xrench-0.1.2.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.12

File hashes

Hashes for xrench-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3315bc8ae9af5034c34d7a8662b6d743c0b46624a58f2085bc5ca4f3d51d9b86
MD5 1c5f5fed2b507732b420320bb46b1afd
BLAKE2b-256 d6e50c6f4cedaeefad6a81550775b05dcbe30d7c0b4a222154a52faff5e0de4c

See more details on using hashes here.

File details

Details for the file xrench-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: xrench-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.12

File hashes

Hashes for xrench-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9e032c6006001d48b1b443aac4f174cf37b6b2b756ab0cadd8534fa5d160a083
MD5 4f0eb4fd29c91a23d1bca1e9fea7e611
BLAKE2b-256 4b0ed3339343132c5d09f9076dd0c26a9b382e5b54f1201eff5b9c552656dfee

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