lunar_toolkit.csm
¶
Read, write and resample USGS CSM linescan cameras (ISD and model state) to match ISIS reduce / crop.
CsmCamera(data, kind, header=None)
dataclass
¶
A CSM camera file: an ALE / isd_generate ISD or a USGS CSM model state.
| Attributes: |
|
|---|
size
property
¶
(samples, lines) of the image the camera describes.
CubeGeometry(samples, lines, alpha_samples, alpha_lines, sample_scale=1.0, sample_offset=0.0, line_scale=1.0, line_offset=0.0)
dataclass
¶
Size of an ISIS cube and its pixel mapping onto the original (alpha) image.
alpha = scale * beta + offset per axis in CSM coordinates (pixel
edges at integers), from the cube's AlphaCube group (identity when
absent).
parse_camera(text)
¶
Parse a CSM camera from text (ISD JSON, or a model state with or without its name line).
read_camera(path)
¶
Read a CSM camera file (.json ISD, model state or ASP .adjusted_state.json).
format_camera(cam)
¶
Text of cam in its original layout (state name line kept).
transform_camera(cam, sample_scale, sample_offset, line_scale, line_offset, size)
¶
Camera for an image whose pixels map affinely onto cam's image.
CSM image coordinates put the top-left pixel edge at 0 (first pixel
centre at 0.5). A point at (x, y) of the new image is
(sample_scale * x + sample_offset, line_scale * y + line_offset) of
the old one. Across track this scales the detector sample summing and
shifts the starting detector sample; along track it scales the
integration times (and the line summing, which converts the residual
detector-line offset into image lines in groundToImage) and moves the
integration start lines so that line y is exposed when old line
line_scale * y + line_offset was.
| Parameters: |
|
|---|
| Returns: |
|
|---|
reduce_camera(camera, factor, out_json=None, size=None)
¶
CSM camera of an image averaged by factor (ISIS reduce, mode=scale).
reduce output pixel k (0-based) averages input pixels
k*f .. k*f + f - 1, so in CSM coordinates (pixel edges at integers)
the mapping is a pure scale by f: summing and integration times grow
by f, sizes shrink by f.
| Parameters: |
|
|---|
read_isis_label(cube, max_bytes=1 << 22)
¶
The attached PVL label of an ISIS cube (text up to the closing End).
camera_for_cube(cam, cube, source=None)
¶
Re-map cam so it describes cube pixel for pixel.
cam is taken to describe the original (alpha) image when its size
matches cube.alpha_* (cameras from isd_generate on the
uncropped cube, as in the ASP LRONAC example), else the source cube
that cube was derived from (reduce / crop of a cube whose own
camera was written for it).
isis_reduce_with_csm(cube, camera, factor, out_dir, algorithm='average', force=False)
¶
ISIS reduce a cube by factor and write the matching CSM camera.
| Parameters: |
|
|---|
| Returns: |
|
|---|