Skip to main content

Python package for handling hierarchical coordinate systems.

Project description

hics: Hierarchical Coordinate Systems

hics is a Python package for handling hierarchical coordinate systems (HCS). It allows you to define relative transformations (translation and rotation) between frames and automatically resolves them to global positions (ECEF) or relative positions between any two frames in the tree.

Core Concepts

1. Defining a Coordinate System

You can define a coordinate system using a position tuple and an optional reference frame. If no reference is provided, it defaults to the GLOBAL_CS.

from hics import HCS, ureg
import numpy as np

# A simple coordinate system 5 meters above the global origin
roof = HCS((0, 0, 5) * ureg.meter)

# A coordinate system relative to 'roof'
antenna = HCS((0, 0, 2) * ureg.meter, reference=roof)

# Resolves to [0, 0, 7]
print(antenna.global_position)

2. Rotations and Compound Transformations

hics integrates with scipy.spatial.transform.Rotation. Transformations are chained automatically down the hierarchy.

from scipy.spatial.transform import Rotation

# Define a tower rotated 90 degrees on the roof
tower = HCS(
    (0, 4, 5) * ureg.meter,
    rotation=Rotation.from_euler("ZYZ", (0, 90, 0), degrees=True),
    reference=roof,
)

# Define an antenna on that rotated tower
local_ant = HCS(
    (0, 6, 5) * ureg.meter,
    reference=tower,
)

3. Relative Calculations

You can calculate the position or distance of one frame as seen from another, even if they are in different branches of the hierarchy.

# How far is the antenna from the tower?
dist = local_ant.relative_distance(tower)

# What is the roof's position in the antenna's coordinate frame?
# This returns the roof's coordinates relative to local_ant's origin and rotation.
rel_pos = local_ant.relative_position(roof)

Geospatial Integration

hics includes powerful utilities for mapping coordinate systems to real-world paths using Digital Elevation Models (DEM) and Land Cover data.

1. Creating a CS from Lat/Lon/Alt

You can initialize a coordinate system directly from geographic coordinates. If hagl=True, the altitude is treated as "Height Above Ground Level" and added to the terrain elevation at that point.

# Initialize an HCS at a specific location in Boulder, CO
# 20 meters above the ground (HAGL)
cs_boulder = HCS.from_crs(
    (40.015 * ureg.degree, -105.270556 * ureg.degree, 20 * ureg.m), 
    hagl=True
)

# This resolves to a global ECEF position
print(cs_boulder.global_position)

2. Racetrack and Path Interpolation

You can generate a coordinate system that follows a trajectory (like a vehicle or aircraft) defined by latitude/longitude points.

from hics.geo.scenarios import interp_llpnts2hcs, racetrack_latlon

# Generate a 10km altitude racetrack path
center = (40.037578, -105.228117) * ureg.degree
racetrack_pnts = racetrack_latlon(center[0], center[1], length=8.48*ureg.km, width=1.5*ureg.km)

racetrack = interp_llpnts2hcs(
    racetrack_pnts, 
    altitude=10*ureg.km, 
    speed=100*ureg.m/ureg.s, 
    bank_turns=True
)

3. Height Above Ground Level (HAGL)

If hagl=True is specified, hics uses the underlying DEM data to "pin" the coordinate system to the terrain height.

# A car driving 2 meters above the ground following a path
drivecs = interp_llpnts2hcs(
    ll_path_points, 
    hagl=2*ureg.m, 
    speed=30*ureg.mph, 
    hagl=True
)

Advanced Usage: Xarray and Lazy Loading

hics leverages xarray and dask for performance.

  • Lazy Merging: Large terrain datasets are merged lazily via VRT (Virtual Raster) files to save memory.
  • Time-Series Support: Coordinate systems can be defined over time-indexed DataArrays, allowing for easy interpolation of moving objects.

References

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

hics-0.1.0.tar.gz (46.0 kB view details)

Uploaded Source

Built Distribution

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

hics-0.1.0-py3-none-any.whl (51.8 kB view details)

Uploaded Python 3

File details

Details for the file hics-0.1.0.tar.gz.

File metadata

  • Download URL: hics-0.1.0.tar.gz
  • Upload date:
  • Size: 46.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.5

File hashes

Hashes for hics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 550f204dbb0e5f235c0cb7f6430b211b2700280291ec224ffed07ba144e3d888
MD5 edc98b865e3c301da180d82ceecb38a9
BLAKE2b-256 d33b2d3341c305ee60356102a2ea7cbce6f1daf35a31e445a320d204406d6984

See more details on using hashes here.

File details

Details for the file hics-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hics-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 51.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.5

File hashes

Hashes for hics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38dac1a4731c2f23f7b345cb0147e27da0b6baf3ea4ba8a8cd728851ecf34f29
MD5 89647b6110772413e24eba4de0fc2f69
BLAKE2b-256 74ea9ec9622a168b53a989f000544d477e6dda3d5c462a40c3bfccafd6565fec

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