A library for reading, writing, and viewing photometric files.
Project description
PhotomPy: Photometric Python
A library for reading, writing, and viewing photometric files.
Installation
Install with pip:
pip install photompy
Alternatively, clone the repo and build locally:
git clone https://github.com/jvbelenky/photompy.git
cd photompy
python setup.py sdist
pip install .
Usage
Modern API (Recommended)
The recommended way to work with IES files is through the IESFile class:
from photompy import IESFile
# Read an IES file
ies = IESFile.read("lamp.ies")
# Access photometry data
print(ies.photometry.thetas) # vertical angles
print(ies.photometry.phis) # horizontal angles
print(ies.photometry.values) # candela values
# Calculate total optical power
power = ies.photometry.total_optical_power()
# Get intensity at specific angles
intensity = ies.photometry.get_intensity(theta=45, phi=0)
# Plot the photometry
fig, ax = ies.plot(plot_type="polar")
fig, ax = ies.plot(plot_type="cartesian", elev=45, azim=30)
# Scale values
ies.scale_to_max(5000) # Scale to max candela value
ies.scale_to_total(1000) # Scale to total power
ies.scale_to_center(2500) # Scale to center intensity
ies.scale(2.0) # Scale by factor
# Write to file
ies.write("output.ies") # Write original angles
ies.write("output.ies", which="full") # Write expanded angles
ies.write("output.ies", which="interp") # Write interpolated angles
# Access header information
print(ies.header.units) # FEET or METERS
print(ies.header.width) # luminous width
print(ies.header.length) # luminous length
print(ies.header.input_watts) # input watts
Legacy API (Deprecated)
The following functions are still available but deprecated. They will emit deprecation warnings:
from photompy import read_ies_data, write_ies_data, total_optical_power, plot_ies
# These still work but will warn
lampdict = read_ies_data(filename)
power = total_optical_power(filename)
fig, ax = plot_ies(filename)
See docs/migration.md for a complete guide on migrating from the legacy API.
Working with Photometry Directly
For advanced use cases, you can work with the Photometry class directly:
from photompy import IESFile
ies = IESFile.read("lamp.ies")
phot = ies.photometry
# Get expanded (mirrored) photometry
expanded = phot.expanded()
# Get interpolated photometry
interpolated = phot.interpolated(num_thetas=361, num_phis=721)
Simple calculations
from photompy import total_optical_power, lamp_area
power = total_optical_power(filename)
luminous_area = lamp_area(filename, units="meters")
Writing files
To scale and write IES files:
from photompy import scale_lamp_to_max, scale_lamp_to_total
# Scale to specific maximum value
scale_lamp_to_max(5000, "input.ies", "output.ies")
# Scale to specific total optical power
scale_lamp_to_total(1000, "input.ies", "output.ies")
Generating files from angular distribution tables
Create IES or LDT files directly from numpy arrays:
from photompy import create_ies, create_ldt
import numpy as np
# Define angular distribution
thetas = np.linspace(0, 90, 19) # vertical angles
phis = np.array([0]) # single plane (axially symmetric)
values = np.cos(np.deg2rad(thetas))[None, :] * 1000 # Lambertian distribution
# Create IES file (required parameters per LM-63 spec)
ies = create_ies(
thetas, phis, values,
manufacturer="Acme Lighting",
lumcat="DL-100",
test="Performance Test 2026-001",
testlab="Acme Test Lab",
issuedate="2026-01-27",
input_watts=15,
)
ies.write("downlight.ies")
# Create LDT file (EULUMDAT format)
ldt = create_ldt(
thetas, phis, values,
manufacturer="Acme Lighting",
luminaire_name="Downlight DL-100",
luminous_width=50, # mm
luminous_length=50, # mm
)
ldt.write("downlight.ldt")
Roadmap
- PhotometricData and AngleData objects (IESFile and Photometry classes)
- [] Generate .ies/.ldt files from an angular distribution table
- Type A and B photometry support
- Dialux file (.ldt) support
- [] More extensive write support
License
Distributed under the MIT License. See LICENSE.txt for more information.
Contact
Vivian Belenky - jvb@osluv.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file photompy-0.2.0.tar.gz.
File metadata
- Download URL: photompy-0.2.0.tar.gz
- Upload date:
- Size: 69.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2626eefb02784235f98192b5b00aee99fa2270a3c31725901574f44bbbe5e818
|
|
| MD5 |
3fe351df9af6317be1cf57db4e629d72
|
|
| BLAKE2b-256 |
f5d10fa51d5058948af70379aeeaa852de11b59f704de91cbbb114cfa59500be
|
File details
Details for the file photompy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: photompy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 51.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41e1d9b45c8e01967f38ac7784378ffb95bd59fbf2e5b0b5ba4b0858f36fc3ca
|
|
| MD5 |
227d79c68157567c5da07b1fba795688
|
|
| BLAKE2b-256 |
1cfdc0e8535f81400ad46f303bd7a5d93e1accdd452cfafdd0414f7260a86658
|