Metadata-Version: 2.4
Name: eulumdat-ies
Version: 1.1.0
Summary: Bidirectional LDT ↔ IES LM-63-2002 converter for the eulumdat-* ecosystem
Author: 123VincentB
License: MIT License
        
        Copyright (c) 2026 123VincentB
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/123VincentB/eulumdat-ies
Project-URL: Repository, https://github.com/123VincentB/eulumdat-ies
Project-URL: Bug Tracker, https://github.com/123VincentB/eulumdat-ies/issues
Keywords: photometry,eulumdat,ldt,ies,lm-63,lighting,luminaire
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: eulumdat-py>=1.0.0
Requires-Dist: click>=8.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# eulumdat-ies

[![PyPI version](https://img.shields.io/pypi/v/eulumdat-ies.svg)](https://pypi.org/project/eulumdat-ies/)
[![Python](https://img.shields.io/pypi/pyversions/eulumdat-ies.svg)](https://pypi.org/project/eulumdat-ies/)
[![License: MIT](https://img.shields.io/github/license/123VincentB/eulumdat-ies)](https://github.com/123VincentB/eulumdat-ies/blob/main/LICENSE)

Bidirectional converter between EULUMDAT (`.ldt`) and IES LM-63-2002 (`.ies`) photometric file formats — part of the [eulumdat-*](https://pypi.org/project/eulumdat-py/) ecosystem.

**IES Type C only.** Type A and Type B photometry are out of scope.

## Installation

```bash
pip install eulumdat-ies
```

## Command-line interface

```bash
# IES → LDT
ies-to-ldt luminaire.ies
ies-to-ldt luminaire.ies -o output/

# LDT → IES
ldt-to-ies luminaire.ldt
ldt-to-ies luminaire.ldt -o output/
```

Output files are written in the same directory as the source file by default,
using the same stem: `luminaire.ies` → `luminaire.ldt`, `luminaire.ldt` → `luminaire.ies`.

## Python API

```python
from pyldt import LdtReader
from eulumdat_ies import ldt_to_ies, ies_to_ldt

# LDT → IES
ldt = LdtReader.read("luminaire.ldt")
ldt_to_ies(ldt, "luminaire.ies")        # write to file
ies_str = ldt_to_ies(ldt)               # or return as string

# IES → LDT
ldt = ies_to_ldt("luminaire.ies")       # from file path
ldt = ies_to_ldt(ies_string)            # or from string content
```

The `Ldt` object returned by `ies_to_ldt` is fully compatible with the entire
`eulumdat-*` ecosystem (`eulumdat-plot`, `eulumdat-luminance`, `eulumdat-ugr`, etc.).

## Format notes

### LDT → IES

- Intensities converted from cd/klm to absolute candelas using `lamp_flux × num_lamps / 1000`
- If lamp flux is unavailable, `lamp_lumens = -1` is written (IES convention for measured flux)
- All C-planes from the expanded LDT matrix are written (ISYM is transparent to the caller)
- C=360° is omitted if C=0° is also present (no duplicate)
- Dimensions converted from mm to metres

### IES → LDT

- Intensities converted from absolute candelas to cd/klm
- If `lamp_lumens = -1`: values stored as-is, `lamp_flux` set to 1000 lm, warning emitted
- Matrix is always `ISYM=0` — use `eulumdat-symmetry` to re-detect symmetry if needed
- C=360° duplicate stripped if present
- Negative IES dimensions (circular source) → positive millimetre values

## Error handling

```python
from eulumdat_ies import IESTypeError, IESParseError

try:
    ldt = ies_to_ldt("luminaire.ies")
except IESTypeError:
    print("Not a Type C file")
except IESParseError:
    print("Malformed IES file")
```

## Ecosystem

```
eulumdat-py  (pyldt)
    └── eulumdat-ies  (eulumdat_ies)   ← this package
```

`eulumdat-ies` depends only on `eulumdat-py`. No NumPy, no external dependencies.

| Package | Role |
|---|---|
| [eulumdat-py](https://pypi.org/project/eulumdat-py/) | LDT parser — base of the ecosystem |
| [eulumdat-symmetry](https://pypi.org/project/eulumdat-symmetry/) | ISYM detection and symmetrisation |
| [eulumdat-plot](https://pypi.org/project/eulumdat-plot/) | Polar intensity diagram (SVG/PNG) |
| [eulumdat-luminance](https://pypi.org/project/eulumdat-luminance/) | Luminance table and polar diagram |
| [eulumdat-ugr](https://pypi.org/project/eulumdat-ugr/) | UGR catalogue table (CIE 117/190) |
| [eulumdat-report](https://pypi.org/project/eulumdat-report/) | Full photometric datasheet (HTML/PDF) |

## License

MIT
