HdsNameShrinker#
- class lsst.images.ndf.HdsNameShrinker(max_length: int = 15)#
Bases:
objectShrink HDS component names to fit the HDS object-name length limit.
Names are uppercased; names at or under the limit pass through unchanged. Each distinct over-long name is assigned a readable prefix followed by an underscore-separated hexadecimal counter that increments per assignment, so distinct names written through the same shrinker never collide. Assignments are remembered, so repeated requests for the same name return the same result.
A shrinker is scoped to a single output file: shrunk names are not stable across files, so readers must use the paths recorded in the file’s JSON tree rather than recomputing them.
Parameters#
- max_length
Maximum component length, by default the HDS limit (
DAT__SZNAM).
Methods Summary
shrink(name[, reserve])Shrink a component name to fit in
max_length - reserve.shrink_versioned(base, version)Shrink a component while preserving a visible version suffix.
Methods Documentation
- shrink(name: str, reserve: int = 0) str#
Shrink a component name to fit in
max_length - reserve.Parameters#
- name
The component name to shrink.
- reserve
Number of characters to leave available for a suffix the caller will append (e.g. a version suffix).
Returns#
strThe uppercased name, unchanged if it fits, otherwise truncated and suffixed with
_and an uppercase hexadecimal counter (at least three digits) so the result is exactlymax_length - reservecharacters.
- shrink_versioned(base: str, version: int) str#
Shrink a component while preserving a visible version suffix.
When
versionis greater than one a_{version}suffix is reserved at the tail and thebaseis shrunk into the remaining characters, so the version number stays readable in Starlink tools. Version one (the first occurrence) is shrunk exactly like an unversioned component.