Astro~/0.3
** CLI / astro ldc * PAGE 17 / 22
** Astro * CLI
** /cli/ldc

astro ldc

Lossless data compression, compress, decompress, inspect.

Lossless data compression with Rice coding (CCSDS 121.0-B-3).

Samples are whole numbers of a fixed width, not octets: a stream of 12-bit readings from an instrument, say. The commands read and write them big-endian at the width --resolution rounds up to, so a 12-bit sample travels in two octets with the top four unused.

Subcommands

CommandDescription
astro ldc compressCompress a sample stream
astro ldc decompressRecover the samples
astro ldc inspectShow a compressed file's header without decompressing

The file carries its parameters

Section 7 defines a self-describing format: a twelve-octet header with every parameter, the coded data, then padding to the output word size.

So decompress takes no parameter flags, and that is deliberate. Guessing at parameters the header already states is how a decompression comes out plausible and wrong.


astro ldc compress

astro ldc compress [file] [flags]

Flags

FlagDefaultDescription
--resolution8Bits per input sample, n: 1 to 32
--block-size16Samples per block, J: 8, 16, 32 or 64
--predictorunit-delayPreprocessor: unit-delay, none, or bypass
--reference-interval256Blocks between reference samples, r: 1 to 4096
--signedfalseSamples are two's complement
--restrictedfalseRestricted code option set (resolution 4 or fewer)
--word-size1Output word size in octets, B: 1 to 8
--inputbinInput format: hex or bin
--formatbinOutput format: bin, hex, or text

A sample that does not fit the stated resolution is refused rather than truncated, and input that is not a whole number of samples is refused rather than having a trailing octet dropped. Both mean the flag and the data disagree, which is worth being told.

Examples

# 8-bit samples
astro ldc compress --input bin --resolution 8 readings.bin > coded.ldc

# 12-bit samples in two octets each, larger blocks
astro ldc compress --input bin --resolution 12 --block-size 32 readings.bin > coded.ldc

# See the ratio
astro ldc compress --input bin --resolution 8 --format text readings.bin

astro ldc decompress

astro ldc decompress [file] [flags]

Flags

FlagDefaultDescription
--inputbinInput format: hex or bin
--formatbinOutput format: bin, hex, or text

Examples

# Round trip, byte for byte
astro ldc compress --input bin --resolution 8 readings.bin |
  astro ldc decompress --input bin > recovered.bin

cmp readings.bin recovered.bin

astro ldc inspect

Read the header and print the parameters the body was coded with, without decompressing it. Useful when you have been handed a file and do not know how it was made.

astro ldc inspect [file] [flags]

Flags

FlagDefaultDescription
--inputbinInput format: hex or bin
--formattextOutput format: text or json

Examples

astro ldc inspect --input bin coded.ldc
LDC File Header
  Word size .......... 1 octets
  Samples ............ 512
LDC Parameters
  Block size ......... 16 samples
  Resolution ......... 8 bits, unsigned
  Predictor .......... unit delay
  Reference every .... 256 blocks
  Code option set .... basic (3-bit identifiers, k up to 5)
  File size .......... 300 octets

Limits

The compression identification packet of section 6 is not built here, insertion into Space Packets is the caller's job, and the application-specific predictor and mapper the standard names but does not define are absent.


See also: the protocol page for the standard and the Go API, and the conformance statement for what is and is not implemented.

** Conformance-tested CCSDS and ECSS protocols for building spacecraft and ground software. **PAGE 17 / 22