Skip to main content

Welcome to AI.CS

AI.CS is the coordinates transformation package in Python. It offers functionality for converting data between geometrical coordinates (cartesian, spherical and cylindrical) as well as between geocentric and heliocentric coordinate systems typically used in spacecraft measurements. The package currently also supports rotations of data by means of rotation matrices. Transformations between spacecraft coordinate systems are implemented as a Python binding to the CXFORM library.

The full documentation is available at aics.rtfd.io.

Getting started

This tutorial will guide you through basic usage of AI.CS.

Installation

AI.CS is developed for Python 3, so make sure that you have a working isntallation of it. The package is distributed together with C portion of CXFORM library, which is compiled automatically during installation. Thus make sure that you have a functioning compiler in your system, for instance, gcc.

Assuming the above requirements are satisfied install the package with Python package manager:

$ pip install ai.cs

Geometrical coordinates

AI.CS ships with functions for conversion between cartesian and spherical coordinates and between cartesian and cylindrical coordinates:

import numpy as np
from ai import cs

# cartesian to spherical
r, theta, phi = cs.cart2sp(x=1, y=1, z=1)

# spherical to cartesian
x, y, z = cs.sp2cart(r=1, theta=np.pi/4, phi=np.pi/4)

# cartesian to cylindrical
r, phi, z = cs.cart2cyl(x=1, y=1, z=1)

# cylindrical to cartesian
x, y, z = cs.cyl2cart(r=1, phi=np.pi/2, z=1)

Most of the functions support both scalars and numpy arrays as input:

import numpy as np
from ai import cs

# converting spherical spiral from spherical to cartesian coordinates
x, y, z = cs.sp2cart(
    r=np.ones(100),
    theta=np.linspace(-np.pi/2, np.pi/2, 100),
    phi=np.linspace(0, np.pi*6, 100)
)

Spacecraft coordinates

AI.CS provides Python bindings to CXFORM library for conversion between various geocentric and heliocentric cartesian coordinate systems. For example, the code below performs transformation of data from GSE to HEEQ coordinate system:

from datetime import datetime
from astropy import units as u
from ai import cs

# converting (0.5, 0.5, 0.5) AU location from GSE to HEEQ at current time
x, y, z = cs.cxform(
    'GSE',
    'HEEQ',
    datetime.now(),
    x=u.au.to(u.m, 0.5),
    y=u.au.to(u.m, 0.5),
    z=u.au.to(u.m, 0.5)
)

Both scalars and numpy arrays are supported as input:

from datetime import datetime, timedelta
from astropy import units as u
from ai import cs

# converting circular orbit at 1 AU from cylindrical to cartesian coordinates
r = np.ones(365)*u.au.to(u.m, 1)
phi = np.linspace(0, np.pi*2, 365)
z = np.zeros(365)
x_HEE, y_HEE, z_HEE = cs.cyl2cart(r, phi, z)

# converting HEE to HEEQ
x_HEEQ, y_HEEQ, z_HEEQ = cs.cxform(
    'HEE',
    'HEEQ',
    [datetime(2016, 1, 1)+timedelta(days=d) for d in range(365)],
    x=x_HEE,
    y=y_HEE,
    z=z_HEE
)

Geometrical transformations

Currently AI.CS offers only one type of geometrical transformations - rotations. Rotation is executed by means of 3D transformation matrices for right-handed rotations around X, Y and Z axes:

import numpy as np
from ai import cs

# get (3x3) rotation matrix for rotation by pi/4 around X axis
Tx = cs.mx_rot_x(gamma=np.pi/4)
# get (3x3) rotation matrix for rotation by -pi/4 around Y axis
Ty = cs.mx_rot_y(theta=-np.pi/4)
# get (3x3) rotation matrix for rotation by pi/2 around Z axis
Tz = cs.mx_rot_z(phi=np.pi/2)

Is is also possible to construct rotation matrices for compound rotations in one shot:

import numpy as np
from ai import cs

# get matrix for right-handed rotation around X, Y and Z axes (exactly in this order)
T = cs.mx_rot(theta=np.pi/4, phi=np.pi/4, gamma=np.pi/4)

# get matrix for right-handed rotation around Z, Y and X axes (exactly in this order)
T_reverse = cs.mx_rot_reverse(theta-np.pi/4, phi=-np.pi/4, gamma=-np.pi/4)
# T_reverse effectively reverses the transformation described by T in this case

Rotation matrices can be applied to data in cartesian coordinates in the following way:

import numpy as np
from ai import cs

# a cube with the side length 2
x = np.array([1, 1, 1, 1, -1, -1, -1, -1])
y = np.array([1, 1, -1, -1, 1, 1, -1, -1])
z = np.array([1, -1, 1, -1, 1, 1, -1, -1])

# rotate cube by pi/4 around each axis
T = cs.mx_rot(theta=np.pi/4, phi=np.pi/4, gamma=np.pi/4)
x, y, z = cs.mx_apply(T, x, y, z)

Release files for ai.cs 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai.cs 1.0.7
File Size Uploaded
ai.cs-1.0.7.tar.gz 20.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ai.cs 1.0.7
File Interpreter ABI Platform
ai.cs-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 42.6 kB

Release files / ai.cs-1.0.7.tar.gz

Download URL ai.cs-1.0.7.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
68a4f86a8b0d67d664bf63c5ca59af1e4e48b16e2553203586d76d654d8d7fc2
BLAKE2b-256 checksum
How to use checksums
2066e05282b4e8546cea4b09a55eaa9efc8ca4fd9702a2d34484e2bc9fa0e2ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / ai.cs-1.0.7-py3-none-any.whl

Download URL ai.cs-1.0.7-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5a2c7c31cabd4764fd1042916ef19680ea905b8ffb2fba85fcf0b8104a30272
BLAKE2b-256 checksum
How to use checksums
e0526add9ff47b0d6f3652f5d5b5e7815e49114754289a59b886441308cf2651
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page