Getting Started¶
This page is a single script you can run after Installing PyHDRL. It builds HDRL images in memory (no FITS kit), collapses them, and prints the result type. Algorithm theory and further snippets are in High-level algorithms. Class and method lists are in the API Reference.
Import¶
PyHDRL is imported as hdrl. It needs PyCPL in the same environment
for cpl.core.Image.
import numpy as np
import cpl.core
import hdrl
hdrl.core holds Image, ImageList and Spectrum1D.
hdrl.func holds the high-level algorithms. hdrl.debug is only for
internal type-conversion tests; ignore it in recipes. Core-type details
are in Core types.
Create an image and a list¶
Numpy arrays are (ny, nx). Wrap them as PyCPL images, then as
hdrl.core.Image:
ny, nx = 64, 80
data = cpl.core.Image(np.full((ny, nx), 100.0, dtype=np.float64))
error = cpl.core.Image(np.full((ny, nx), 1.0, dtype=np.float64))
image = hdrl.core.Image(data, error)
imglist = hdrl.core.ImageList()
for _ in range(5):
imglist.append(image.duplicate())
Collapse¶
Most master-bias / master-dark style combinations are a collapse. Create
a strategy object, then compute():
collapse = hdrl.func.Collapse.Mean()
results = collapse.compute(imglist)
master = results.out # hdrl.core.Image
contrib = results.contrib # cpl.core.Image
print(type(results).__name__)
print("collapsed mean data/error:", master.get_mean())
results is hdrl.func.CollapseResult. The same objects (image,
imglist, ny, nx) are what later algorithm pages mean when they
reuse those names.
Interface design¶
Most algorithms take constructor arguments instead of an opaque
hdrl_parameter. There is no hdrl.core.Parameter class (removed in
1.0). Efficiency and Response still use typed objects such as
hdrl.func.EfficiencyParameter and hdrl.func.ResponseCalcParameter.
The C vs Python pairing for Flat (hide hdrl_parameter, return
FlatResult) is in What is PyHDRL?.
Do not pass that Flat snippet imglist after a destructive
Flat.compute without duplicating it first
(Flat).