Expand description
IES TM-25 ray files (.TM25RAY): zero-copy and streaming readers, a
writer, flux-preserving subsampling, a far-field C/γ converter, a
luminance map (luminance), a quality report (quality), a channel
mixer (mix) with V(λ) photometry (photometry), and LightTools
import/export (lighttools).
TM-25 describes a light source as individual rays (start point in mm, unit direction, flux) rather than an angular intensity table, so it is the near-field counterpart of EULUMDAT/IES LM-63.
§Layout (TM-25-13, little-endian)
Verified against real vendor files, the reference implementation and
Table 4-2 of the standard; see docs/format.md in the repository for the
full table and the remaining VERIFY items.
| Offset | Content |
|---|---|
| 0 | TM25 magic, i32 version 2013, i32 creation method |
| 12 | f32 luminous flux lm, f32 radiant flux W, u64 ray count |
| 28 | 28-byte ASCII date/time, i32 start-position flag |
| 60 | i32 spectral id (0 none, 1 single λ, 2 per-ray λ, 3 shared table, 4 per-ray table index) |
| 64 | f32 single λ (NaN if unused), f32 λ min, f32 λ max |
| 76 | i32 spectral table count, i32 additional item count, i32 additional text size, reserved to 256 |
| 256 | 8 × i32 known-data flags: position, direction, radiant flux, wavelength, luminous flux, Stokes, tristimulus, spectrum index |
| 288 | 9 × 1000 UTF-32LE description strings |
| 36 288 | spectral tables (i32 N, N × (f32 λ, f32 value)), zero padded to a multiple of 32 bytes |
| then | one 512-byte UTF-32LE name per additional column, then the additional text block (size at offset 84, in bytes) |
| then | ray records: x y z kx ky kz + flagged columns, f32 except the i32 spectrum index |
§Coordinates
TM-25 positions are mm with +z the emission axis. direction_to_c_gamma
gives EULUMDAT angles (γ = 0 on +z, C from +x towards +y) and to_bevy
maps to the y-up convention used by the eulumdat-rs Bevy viewer
(x, −z, y) so a ray-derived solid overlays an LDT solid.
§WASM
The core is std-only and never touches the clock. mmap is an opt-in
feature for native builds. Browser callers feed Blob.slice chunks to
Tm25Reader through any Read adapter.
Re-exports§
pub use error::Result;pub use error::Tm25Error;pub use farfield::FarField;pub use farfield::FarFieldBuilder;pub use farfield::IntensityUnit;pub use header::columns_from_flags;pub use header::Column;pub use header::FluxKind;pub use header::Header;pub use header::KnownDataFlags;pub use header::ParseOptions;pub use header::SpectralId;pub use header::SpectralTable;pub use header::TextFields;pub use header::FIXED_HEADER_SIZE;pub use header::MAGIC;pub use header::VERSION_2013;pub use lighttools::is_lighttools;pub use lighttools::spectrum_from_rays;pub use lighttools::to_lighttools_bytes;pub use lighttools::to_lighttools_bytes_sampled;pub use lighttools::write_lighttools;pub use lighttools::write_lighttools_sampled;pub use lighttools::write_sre;pub use lighttools::LightToolsFile;pub use lighttools::LightToolsHeader;pub use lighttools::SpectrumSampler;pub use lighttools::LIGHTTOOLS_VERSION_TAG;pub use luminance::image_axes;pub use luminance::lambertian_luminance;pub use luminance::luminance_map;pub use luminance::LuminanceMap;pub use mix::combine_spectra;pub use mix::fit_weights;pub use mix::mix;pub use mix::mixed_spectrum;pub use mix::mixed_totals;pub use mix::table_integral;pub use mix::table_value_at;pub use mix::weights_for_flux_fractions;pub use mix::Channel;pub use mix::MixMode;pub use photometry::luminous_efficacy_lm_per_w;pub use photometry::v_lambda;pub use photometry::KM;pub use quality::quality_report;pub use quality::Finding;pub use quality::QualityAccumulator;pub use quality::QualityReport;pub use quality::QualityStats;pub use quality::Severity;pub use ray::direction_to_c_gamma;pub use ray::from_bevy;pub use ray::to_bevy;pub use ray::Ray;pub use ray::RayIter;pub use ray::RayLayout;pub use ray::RayView;pub use reader::RayStream;pub use reader::Tm25File;pub use reader::Tm25Reader;pub use sample::subsample;pub use sample::Reservoir;pub use sample::Rng64;pub use writer::encode_header;pub use writer::to_bytes;pub use writer::write_tm25;
Modules§
- error
- farfield
- Far-field intensity from ray directions: bin into a C/γ grid, divide by solid angle. Start positions are ignored, which is exactly what the far-field approximation discards.
- header
- TM-25-13 header: fixed 36 288-byte block followed by the variable spectral / column-name / additional-text blocks.
- lighttools
- LightTools binary ray files (
.ray): the import format of Synopsys LightTools, written here from a TM-25 ray set so a file inspected or subsampled with this crate can go straight into an illumination design. - luminance
- Luminance (or radiance) map of a ray set seen from a direction: the
near-field image a camera or an eye would see, in cd/m² or W/(sr·m²) per
pixel. Method and noise figures:
docs/luminance.mdin the repository. - mix
- Mixing ray files: several channels of one package (ams OSRAM ships a blue and a phosphor-yellow ray file per white LED, so the user can set the ratio and so the spectra stay adjustable) combined into one TM-25 ray set with chosen weights.
- photometry
- Photopic luminous efficiency V(λ) and what follows from it: the luminous efficacy of a spectral table, which converts a radiometric file’s watts into lumens and checks a vendor’s lm/W against its own spectrum.
- quality
- Ray-file quality report: is this file usable, and what is wrong with it?
- ray
- Ray records: decoding, a zero-copy view over the ray block, and the coordinate helpers shared with the viewer.
- reader
- Zero-copy and streaming readers.
- sample
- Flux-preserving subsampling: random pick from an in-memory view, or reservoir sampling over a stream. Deterministic for a given seed and free of external RNG dependencies (SplitMix64 + xorshift*).
- writer
- TM-25-13 writer: the inverse of
crate::Header::parse, byte-for-byte compatible with the vendor files this crate was verified against.