Skip to main content

Compass Python Lib

Conversion commands:

# Install in dev mod
pip install -e ".[dev,test]"

# Install latest stable version
pip install compass_lib

# run some commands
compass convert --input_file=./tests/artifacts/fulford.dat  --output_file=fulford.json --format=json --overwrite
compass convert --input_file=./tests/artifacts/random.dat  --output_file=random.json --format=json --overwrite

GeoJSON section colors

GeoJSON survey legs include properties.color, an opaque CSS #rrggbb color. Every shot in a DAT survey block receives the same generated section color. Sections sharing a station have different colors, including across MAK-linked DAT files. Names alone do not identify sections or station connections: the existing MAK station-scoping rules remain authoritative. Geometric crossings without a shared station do not create a color constraint.

The palette lives in compass_lib/constants.py as SURVEY_COLORS: vivid red, orange, yellow, lime, green, mint, cyan, blue, purple, and hot pink. Both palette colors and generated overflow colors have HSV saturation of at least 80% and value of at least 90%, excluding black, white, gray, and muted shades.

Assignment uses ordinary random choices in at most 16 iterative passes, without hashing, a fixed seed, or algorithm versioning. It stops on completion or no improvement. Remaining sections receive distinct vibrant colors using a finite fallback budget sized to the input, so reaching the pass limit does not leave touching sections with the same viewer fallback color. Colors can change when GeoJSON is regenerated and remain fixed in each stored artifact.

See GeoJSON section coloring for pass semantics, fallback bounds, the color-space limit, export behavior, and test coverage.

CompassSurvey.color is derived metadata assigned during coordinate computation; it is excluded from source JSON and DAT/MAK serialization. SurveyLeg.color carries it through coordinate propagation and loop closure. Passage polygons and clipped passage fragments inherit their leg's color. Station/anchor and misclosure styling retain their existing semantics.

The color property is independent of color_by_origin and CLI --no-colors, which still control origin-based simplestyle stroke/marker-color styling. Clients can use color for shot rendering and fall back to the survey color for legacy data without it. Existing saved GeoJSON must be regenerated to gain these properties; no source files are rewritten. Palette changes also require regenerating stored GeoJSON; existing artifacts retain the colors recorded when they were exported.

Portable regression coverage lives in tests/test_section_colors.py, including duplicate names, linked/scoped stations, crowded junctions, solver paths, round trips, CLI/API exports, vibrant colors, and safe budget exhaustion. Private fixtures remain additional coverage and are never required for these guarantees.

Loop closure

compass_lib.loop_closure.LoopClosure provides Gaussian WLS with explicit mode, positive sigma_m, and per-survey (declination, convergence) values keyed by (file_name, survey_index). The pure compass_lib.loop_closure.prepare_loop_closure API accepts the same inputs plus caller-supplied ENU controls and a complete horizontal preserved-Z map. cave_closure is a required dependency installed with the package.

compass_lib.preset.InverseLengthWeightedL1SpatialSolver reproduces the former Compass-lib SparseSolver using the native HiGHS backend in cave_closure. Pass it as loop_closure=InverseLengthWeightedL1SpatialSolver to the GeoJSON or coordinate APIs. It is an immutable LoopClosure instance, with every setting specified explicitly. It closes the propagated XYZ graph using inverse-length weighted absolute errors and preserves the legacy GeoJSON baselines. Unlike the Gaussian configuration below, it keeps the first observation for each undirected station pair. See loop closure for its origin and settings.

Raw parsed observations provide measurements; propagated positions never replace them. Every repeated and reversed shot remains distinct. C protects normalized active-dimensional displacement with an exact offset. X excludes processing; P and L remain factors. One distance with redundant angles produces one factor, using frontsight components with reversed-backsight fallback. sigma_m declares independent isotropic Cartesian placement noise, not inferred instrument accuracy. W-format does not supply absolute depth readings.

DAT calibration follows the vendor's compass, inclinometer, tape ordering in the native format specification. Parser and formatter now use that order, retain backsight-only calibration, and reverse-backsight inclination keeps its native signed reverse direction. Calibration changes affect derived observations without overwriting raw readings. Historical JSON generated by the old parser can contain mislabeled correction values: reparse original DAT input or migrate only with known source provenance. The adapter does not silently reinterpret named JSON fields.

GeoJSON APIs accept loop_closure=LoopClosure(...). The CLI uses --algorithm with the four enum member names; --mode selects dimensions and --sigma-m declares placement uncertainty. --raw exports unadjusted geometry. The default CLI and web loop closure is Gaussian reduced PCG. Frame corrections can be supplied explicitly or reused from the per-survey geographic calculation.

Import LoopClosureMode and LoopClosureAlgorithm directly from cave_closure. Preparation accepts algorithm=LoopClosureAlgorithm.LSE_REDUCED_PCG (the default), LSE_UNREDUCED_PCG, LSE_SPARSE_QR, or LSE_SPARSE_CHOLESKY. The algorithm selects the least-squares solver independently of mode=LoopClosureMode.HORIZONTAL or mode=LoopClosureMode.SPATIAL.

Metadata

Release files for compass-lib 0.0.10

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

Source distribution (sdist)

Source distribution for compass-lib 0.0.10
File Size Uploaded Provenance Actions
compass_lib-0.0.10.tar.gz 84.0 kB With provenance Details for compass_lib-0.0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for compass-lib 0.0.10
File Interpreter ABI Platform Actions
compass_lib-0.0.10-py3-none-any.whl Python 3 none any Details for compass_lib-0.0.10-py3-none-any.whl

Total release size: 175.8 kB

Release files / compass_lib-0.0.10.tar.gz

Download URL compass_lib-0.0.10.tar.gz
Size 84.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b4e0a5d0b07a8350791b767f1be44b19f23990dfddef65171c53f0dbab9cb6b5
BLAKE2b-256 checksum
How to use checksums
084a543b3ae72099f6b23e206c729309721d2af83b9e59823ce5bbb7e32961c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / compass_lib-0.0.10-py3-none-any.whl

Download URL compass_lib-0.0.10-py3-none-any.whl
Size 91.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd24a6ada86ab2517c469391734b427ee802615e9b3a4faf0fc195ebf14389f2
BLAKE2b-256 checksum
How to use checksums
74e1d8516e72b38557db61b8bde6e58f175b389c4b0187ec56d29f09fc605b10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for compass-lib 0.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for compass_lib-0.0.10.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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