Skip to main content

To parse CITI format file to xarray.

Project description

CITIfile

Read CITI format file by python.

Introduction

CITIfile is a tiny library that allows you to read CITI format file by using Python.

Installation

pip install -U CITIfile

Tutorial

CITIfile is easy to use:

from CITIfile import read_citifile


data = read_citifile("data.citi")

Then, it will parse the data file and return a xarray.Dataset object. Like the following:

<xarray.Dataset>
Dimensions:   (C_d2: 3, L_load: 6, freq: 6)
Coordinates:
  * L_load    (L_load) float64 20.0 21.0 22.0 23.0 24.0 25.0
  * C_d2      (C_d2) float64 1.0 1.5 2.0
  * freq      (freq) float64 3e+07 3.1e+07 3.2e+07 3.3e+07 3.4e+07 3.5e+07
Data variables:
    S[1,1]    (L_load, C_d2, freq) complex128 (0.0517763713-0.00941470346j) ... (0.0593002475-0.0233189028j)
    S[1,2]    (L_load, C_d2, freq) complex128 (0.771829001+0.00291050315j) ... (0.774683786+0.0184790199j)
    S[2,1]    (L_load, C_d2, freq) complex128 (0.771829001+0.00291050315j) ... (0.774683786+0.0184790199j)
    S[2,2]    (L_load, C_d2, freq) complex128 (0.0517763713-0.00941470346j) ... (0.0593002475-0.0233189028j)

CITIfile parses and converts CITI format to xarray.Dataset object, because CITI format file stores data in multidimensional array format and xarray are designed to handle this kind of data.

See xarray documents to learn that how to manipulate xarray.Dataset object.

Displaying Coordinates and Data Vairables

print('Coordinates:')
for cname in data.coords:
    cdata = data.coords[cname].data
    print(f'- {cname}: {len(cname)} ({cdata}, {cdata.dtype})')

print('Data:')
for vname in data.data_vars:
    vdata = data.data_vars[vname]
    print(f'- {vname}: {vdata.dtype}')

This displays the names and types of the corrdinates and data variables, as well as the available corrdinate values (which are numpy.ndarray).

Extracting Usable 2D Data

In this example, we extract S[1,1] vs. freq, at some given coordinates for C_load and C_d2:


# select the data variable at the given corrdinates
data_slice = data.data_vars["S[1,1]"].sel(L_load=20, C_d2=1)

# now there is only one coordinate (freq) left as independent variable
x = data_slice.coords["freq"].data

# dependent variable (Y-axis)
y = data_slice.data

for px, py in zip(x, y):
    print(f"freq={px} -> S[1,1]={py}")

Both x and y are numpy.ndarray.

Websites

Main website: https://github.com/TitorX/CITIfile

CITIfile Definitions: http://literature.cdn.keysight.com/litweb/pdf/ads15/cktsim/ck2016.html

xarray document: http://xarray.pydata.org/en/stable/

Reports

Report bugs or ask questions at https://github.com/TitorX/CITIfile/issues.

Contact

Written by Shoukun Sun.

Email: titor.sun@gmail.com

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

citifile-0.1.6.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

CITIfile-0.1.6-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file citifile-0.1.6.tar.gz.

File metadata

  • Download URL: citifile-0.1.6.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for citifile-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e374a86a24dd4eaf81ee7707ee0c3bab08f910e45a896a4208d773776a0ec5c1
MD5 2617b50185d71010de1d6084bde49610
BLAKE2b-256 75b7b369723e805e12b0ed921ada0d94589d13281f6e3052c279a6ceae788bde

See more details on using hashes here.

File details

Details for the file CITIfile-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: CITIfile-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for CITIfile-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d06afee5fe05031182c13d06b5cdcf4635bb0f2eee4475a2a8f675c2d8fb11f1
MD5 2e503fa3bafee0899e70895e86a8f91f
BLAKE2b-256 d3a03fe9f7cf501275cc8ee8cd7295c6c25c8b9629e6058314a3c406bd37f451

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page