This document lists the public API surface intended for SDK users.
- Source of truth for exported names:
klein_colorimeter/__init__.py. - Public API in this document means names exported from
klein_colorimeterplus non-underscore methods on those exported classes. - Internal helpers (names starting with
_) are intentionally omitted.
Use this sequence for the most common workflow (connect, measure, optional continuous mode, cleanup):
KClmtr()connect(port)setMeasureSpeedMode(SpeedMode.SPEEDMODE_NORMAL | SpeedMode.SPEEDMODE_FAST)(optional)setRange(-1)(auto range; optional)getNextMeasurement()measurement.getBigY()andmeasurement.getCIE1931_x()/getCIE1931_y()measurement.getRGB_Red()/getRGB_Green()/getRGB_Blue()measurement.getWavelength_nm()/getWavelength_duv()startMeasuring()+getMeasurement()for streaming (optional)stopMeasuring()(if streaming)closePort()
Minimal one-shot example:
from klein_colorimeter import KClmtr
meter = KClmtr()
if meter.connect("COM3"):
try:
m = meter.getNextMeasurement()
print(f"Y: {m.getBigY():.4f} nits")
print(f"xy: ({m.getCIE1931_x():.6f}, {m.getCIE1931_y():.6f})")
print(f"RGB: ({m.getRGB_Red():.6f}, {m.getRGB_Green():.6f}, {m.getRGB_Blue():.6f})")
print(f"Wavelength: {m.getWavelength_nm():.3f} nm, duv: {m.getWavelength_duv():.6f}")
finally:
meter.closePort()
else:
print("Unable to connect")Tip: RGB getters return normalized values (typically 0.0-1.0 in-gamut). For percent display, multiply by 100.
from klein_colorimeter import (
KClmtr,
Matrix,
GamutSpec,
Measurement,
Counts,
Flicker,
FlickerSetting,
FlickerSettingRange,
WRGB,
CorrectedCoefficient,
BlackMatrix,
PercentMode,
DecibelMode,
CorrectionMode,
MeasurementRange,
GamutCode,
SpeedMode,
KleinsErrorCodes,
)ContrastMethod = 0Normaized = 1
VESA = 0JEITA = 1
ArrayFit = 0PolyFit = 1
range1 = 1range2 = 2range3 = 3range4 = 4range5 = 5range6 = 6range1B = 1range1T = 2range2B = 3range2T = 4range3B = 5range3T = 6
NTSC = 0EBU = 1REC709 = 2REC2020 = 3SMPTE = 4DCIP3 = 5USER_DEFINE = 6defaultGamut = REC709
SPEEDMODE_NORMAL = 0SPEEDMODE_FAST = 1
NONENOT_OPENTIMED_OUTLOST_CONNECTIONBAD_VALUESCONVERTED_NMKELVINSAIMING_LIGHTSAVERAGING_LOW_LIGHTBOTTOM_UNDER_RANGETOP_OVER_RANGEOVER_HIGH_RANGEBLACK_ZEROBLACK_OVERDRIVEBLACK_EXCESSIVEBLACK_PARSING_ROMBLACK_STORING_ROMCAL_WHITE_RGBCAL_STORINGCAL_CONVERT_BINARYFFT_BAD_STRINGFFT_RANGE_CALFFT_NO_XYZFFT_NO_RANGEFFT_INSUFFICIENT_DATAFFT_PREVIOUS_RANGEFFT_NOT_SUPPORTEDFFT_BAD_SAMPLESFFT_OVER_SATURATEDFIRMWARE
Primary meter/session object for serial connection, measurement, counts, and flicker operations.
setPort(portName: str) -> NonegetPort() -> strisPortOpen() -> boolconnect(portName: str | None = None) -> boolclosePort() -> NonetestConnection(portName: str) -> tuple[bool, str, str](static)getSerialNumber() -> strgetModel() -> strsendMessageToKColorimeter(message: _Command | str, expected: int | None = None, timeout: int | None = None) -> tuple[int, str]readFromKColorimeter(expected: int, timeout_seconds: int) -> tuple[int, str]
setAimingLights(onOff: bool) -> NonesetRange(range_value: int) -> NonegetRange() -> intgetCalFileName() -> strsetCalFileID(calFileID: int) -> NonegetCalFileID() -> intgetCalFileList() -> list[str]deleteCalFile(calFileID: int) -> intsetTempCalFile(coeff: CorrectedCoefficient) -> NonegetCalMatrix() -> Matrix[float]getRGBMatrix() -> Matrix[float]getGamutSpec() -> GamutSpecsetGamutSpec(gs: GamutSpec) -> NonegetCoefficientTestMatrix(reference: WRGB, kclmtr: WRGB) -> CorrectedCoefficientstoreMatrices(id: int, name: str, reference: WRGB | Matrix[float] | CorrectedCoefficient, kclmtr: WRGB | None = None) -> intcaptureBlackLevel() -> BlackMatrixgetFlashMatrix() -> BlackMatrixgetRAMMatrix() -> BlackMatrixgetCoefficientMatrix() -> BlackMatrix
setMaxAverageCount(maxAvg: int) -> boolgetMaxAverageCount() -> intgetMeasureSpeedMode() -> SpeedModesetMeasureSpeedMode(value: SpeedMode) -> None
startMeasuring() -> NonestopMeasuring() -> NoneisMeasuring() -> boolgetMeasurement() -> tuple[bool, Measurement]getNextMeasurement(n: int = -1) -> Measurement
startMeasureCounts() -> NonestopMeasureCounts() -> NoneisMeasureCounts() -> boolgetMeasureCounts() -> tuple[bool, Counts]getNextMeasureCount() -> Counts
setFFT_Cosine(use: bool) -> NonegetFFT_Cosine() -> boolsetFFT_Smoothing(use: bool) -> NonegetFFT_Smoothing() -> boolsetFFT_Samples(samples: int) -> intgetFFT_Samples() -> intsetFFT_PercentJEITA_Discount(onOff: bool) -> NonegetFFT_PercentJEITA_Discount() -> boolsetFFT_DBJEITA_Discount(onOff: bool) -> NonegetFFT_DBJEITA_Discount() -> boolsetFFT_PercentMode(mode: PercentMode) -> NonegetFFT_PercentMode() -> PercentModesetFFT_DBMode(mode: DecibelMode) -> NonegetFFT_DBMode() -> DecibelModesetFFT_numberOfPeaks(numberOfPeaks: int) -> NonegetFFT_numberOfPeaks() -> intstartFlicker() -> intstopFlicker() -> NoneisFlickering() -> boolgetFlicker() -> tuple[bool, Flicker]getNextFlicker() -> Flicker
printMeasure(measurement: Measurement) -> NoneprintFlicker(flicker: Flicker) -> NoneprintCounts(counts: Counts) -> None
Simple 2D matrix container used by the SDK types.
initializeV(rows: int, columns: int, fill: T | float | int = 0) -> Noneclear(fill: T | float | int = 0) -> NonegetRow() -> intgetColumn() -> intcopy() -> Matrix[T]to_numpy(dtype=float)from_rows(rows: Iterable[Iterable[T | float | int]]) -> Matrix[T](class method)
Public attribute:
v: list[list[T | float | int]]
Chromaticity and white-point model plus matrix conversion helpers.
fromCode(code: GamutCode, whiteBigY: float = 100.0) -> GamutSpec(static)getCodeSpec() -> GamutCodesetRed(x: float, y: float) -> NonesetGreen(x: float, y: float) -> NonesetBlue(x: float, y: float) -> NonesetWhite(x: float, y: float, bigY: float) -> NonegetWhite() -> tuple[float, float, float]getRed() -> tuple[float, float, float]getGreen() -> tuple[float, float, float]getBlue() -> tuple[float, float, float]getRGBtoXYZ() -> Matrix[float]getXYZtoRGB() -> Matrix[float]
Public attributes:
redX,redY,greenX,greenY,blueX,blueY,whiteX,whiteY,whiteBigY,code
Computed color measurement object (XYZ, xy, RGB, Lab/LCh, HSV, CCT/Duv, ranges, and errors).
getCIE1931_x() -> floatgetCIE1931_y() -> floatgetBigX() -> floatgetBigY() -> floatgetBigZ() -> floatgetBigXRaw() -> floatgetBigYRaw() -> floatgetBigZRaw() -> floatgetRGB_Red() -> floatgetRGB_Green() -> floatgetRGB_Blue() -> floatgetCIE1974_u() -> floatgetCIE1974_v() -> floatgetWavelength_nm() -> floatgetWavelength_duv() -> floatgetLab_L() -> floatgetLab_a() -> floatgetLab_b() -> floatgetLCh_L() -> floatgetLCh_C() -> floatgetLCh_h() -> floatgetHSV_hue() -> floatgetHSV_saturation() -> floatgetHSV_value() -> floatgetRedRange() -> MeasurementRangegetGreenRange() -> MeasurementRangegetBlueRange() -> MeasurementRangegetColorTemperature_K() -> floatgetColorTemperature_duv() -> floatgetErrorCode() -> intgetAveragingby() -> intgetMinX() -> floatgetMaxX() -> floatgetMinY() -> floatgetMaxY() -> floatgetMinZ() -> floatgetMaxZ() -> floatgetGamutSpec() -> GamutSpecsetGamutSpec(gs: GamutSpec) -> None
deltaE1976(spec: Measurement) -> floatdeltaE1994(spec: Measurement) -> floatdeltaE2000(spec: Measurement) -> floatfromBadMeasurement() -> Measurement(static)fromXYZ(X: float, Y: float, Z: float, gs: GamutSpec | None = None) -> Measurement(static)fromxyY(x: float, y: float, Y: float, gs: GamutSpec | None = None) -> Measurement(static)fromuvprimeY(u: float, v: float, Y: float, gs: GamutSpec | None = None) -> Measurement(static)fromTempduvY(_temp: float, _tempduv: float, Y: float, gs: GamutSpec | None = None) -> Measurement(static)fromnmduvY(_nm: float, _nmduv: float, Y: float, gs: GamutSpec | None = None) -> Measurement(static)fromRGB(red: float, green: float, blue: float, gs: GamutSpec | None = None) -> Measurement(static)fromHSV(hue: float, saturation: float, value: float, gs: GamutSpec | None = None) -> Measurement(static;saturationis 0 to 100,valueis normalized 0.0 to 1.0)fromLab(L: float, a: float, b: float, gs: GamutSpec | None = None) -> Measurement(static)toNits(FootLamberts: float) -> float(static)toFootLamberts(nits: float) -> float(static)
Raw count packet object.
getTh1() -> intgetTh2() -> intgetTherm() -> intgetRedRange() -> MeasurementRangegetGreenRange() -> MeasurementRangegetBlueRange() -> MeasurementRangegetTheCounts() -> Matrix[int]getErrorCode() -> int
Public attributes:
th1,th2,therm,redrange,greenrange,bluerange,theCounts,errorcode
numbers() -> int
Public attributes:
start,end
getResolution() -> floatgetCorrection(hz: float) -> floatappendCorrection(rangeOfHz: FlickerSettingRange, mode: CorrectionMode, array: Iterable[float]) -> booldeleteCorrection() -> None
Public attributes:
samples,speed,numberOfPeaks,cosine,smoothing,JETIADiscount_DB,JEITADiscount_Percent,decibel,percent,corrections
Flicker-analysis result object.
from_samples(settings: FlickerSetting, data, sectionOfFFT: int = 0, nitsLast32Samples: float | None = None) -> Flicker(class method)getBigY() -> floatgetRange() -> MeasurementRangegetPeakFrequencyPercent() -> Matrix[float]getPeakFrequencyDB() -> Matrix[float]getFlickerPercent() -> Matrix[float]getFlickerDB() -> Matrix[float]getCounts() -> Matrix[float]getNits() -> Matrix[float]getAmplitude() -> Matrix[float]getErrorCode() -> intgetSettings() -> FlickerSetting
Public attributes:
bigY,range,peakfrequencyPercent,peakfrequencyDB,flickerPercent,flickerDB,counts,nits,amplitude,errorcode,settings
Container for white + RGB reference triplets used in calibration matrix fitting.
from_measurements(measurements: list[Measurement]) -> WRGB(class method)
Public attribute:
v: list[list[float]]
Calibration payload container.
Public attributes:
colorMatrix: Matrix[float]rgbMatrix: Matrix[float]
Black compensation matrix container.
from_vector(vector: list[float], errorcode: int) -> BlackMatrix(class method)
Public attributes:
range: list[list[float]]therm: floaterrorcode: int
- The package intentionally mirrors original SDK naming, including camelCase method names.
Measurement.getRGB_Red(),getRGB_Green(),getRGB_Blue()return normalized RGB values (typically 0.0 to 1.0 in-gamut), not 0 to 100.- HSV semantics match the app scale.
Measurement.getHSV_value()returnsmax(R,G,B)/(R+G+B)in 0.0 to 1.0.Measurement.getHSV_saturation()returns(delta/max(R,G,B))*100in 0.0 to 100.0 (or-1for achromatic).Measurement.getHSV_hue()andgetHSV_saturation()return-1for achromatic colors.Measurement.getWavelength_nm()andgetWavelength_duv()are computed from the measured chromaticity (u,v) by projection onto the SDK wavelength locus spline.Measurement.getColorTemperature_K()andgetColorTemperature_duv()are computed using the SDK blackbody spline table (same table-driven nearest-curve approach used by the original C++ SDK).- Wavelength outputs can still be
NaNfor degenerate or invalid measurements (for example zero/invalid XYZ where chromaticity cannot be projected). PercentModeand related FFT percent settings apply to flicker analysis, not toMeasurementRGB getters.