Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e157096
Add spectrum integration function, updated weather file handling
mjprilliman May 30, 2025
2a3ddb5
Update calls to generate spectra, including adding inputs for min and
mjprilliman Sep 17, 2025
d158a07
Merge branch 'development' into spectral-fixes
mjprilliman Sep 17, 2025
b90ce94
Initial commit from Claude gpt. Pytests are working but implementati…
cdeline Sep 24, 2025
6834125
Merge branch 'development' into 533_pyradiance
cdeline Oct 7, 2025
0766739
Check for minute column in weather data (i.e. calculate at 30 minutes
mjprilliman Oct 29, 2025
bef88cc
Merge branch 'development' into spectral-fixes
mjprilliman Oct 30, 2025
18c01b4
Revert change in readWeatherFile outputs (must be metdata, not tuple
mjprilliman Oct 31, 2025
62cf9db
Add test_integrated_spectrum in test_spectra.py.
cdeline Oct 31, 2025
161215c
inline comment cleanup
cdeline Oct 31, 2025
4f48419
Merge branch 'development' into 533_pyradiance
cdeline Nov 3, 2025
939747a
Merge pull request #1 from cdeline/mjprilliman-spectral-fixes
mjprilliman Nov 4, 2025
bd1ad8d
add temporary monkey patch of pyradiance.gendaylit to allow -ang func…
cdeline Nov 4, 2025
14da31a
update saveImage for pyradiance (still needs testing)
cdeline Nov 4, 2025
21df6d7
update whatsnew and manualapi.rst
cdeline Nov 5, 2025
9592594
Merge branch 'mjprilliman-spectral-fixes' into 533_pyradiance
cdeline Nov 5, 2025
8964082
Merge branch 'development' into 533_pyradiance
cdeline Nov 7, 2025
966665b
Start to code up the pextrem function in python
cdeline Mar 8, 2026
c1d9838
move pextrem to pyradiance_gendaylit.py. NEED TO TEST makeImage and …
cdeline Mar 20, 2026
87d0b24
Merge branch 'development' into 533_pyradiance
cdeline Apr 3, 2026
8a7a593
Merge branch '533_pyradiance' into 533_pyrad_pextrem
cdeline Apr 3, 2026
b7a9246
Fix saveImage
cdeline Apr 3, 2026
888fb5d
fixed makeImage and makeFalseColor
cdeline Apr 6, 2026
df76d7d
re-run tutorial 1
cdeline Apr 6, 2026
0780777
saveimage check for list vs str radfiles. fix module.saveImage
cdeline Apr 7, 2026
0454b00
update pytests
cdeline Apr 7, 2026
12c8447
Merge branch 'development' into 533_pyrad_pextrem
cdeline Apr 7, 2026
25aff05
refactor sceneObj.radfiles to always be a list. fixes tests for pyth…
cdeline Apr 7, 2026
4a98174
update github workflow to deprecate 3.8 and require >= py3.10
cdeline Apr 7, 2026
0aa0d2b
update requirements.txt for 3.10 and 3.12 compatibility.
cdeline Apr 7, 2026
c5fb596
add whatsnew/v0.6.0.rst
cdeline Apr 8, 2026
97426de
Merge pull request #1 from cdeline/533_pyrad_pextrem
cdeline Apr 8, 2026
b7f3134
slightly expand high_azimuth_modelchain acceptance window
cdeline Apr 9, 2026
e4e2e0d
update pytests to accuracy=high
cdeline Apr 10, 2026
609c08e
update RADIANCE version loaded by github CI pytests
cdeline Apr 10, 2026
c9f6140
update pytests to match new RADIANCE software
cdeline Apr 10, 2026
8522c4f
set accuracy = high for ini_gencumsky.ini
cdeline Apr 10, 2026
50fc5e3
replace deprecated coactions/setup-xvfb in github pytest.yaml
cdeline Apr 10, 2026
39b0127
Merge branch '593_rtrace' into 533_pyradiance
cdeline Apr 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: test
name: test

on: [pull_request, push]

# Force all JavaScript actions to use Node 24 to silence the v4/v5 warnings
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
pytest:

runs-on: ubuntu-latest
strategy:
fail-fast: false # don't cancel other matrix jobs when one fails
matrix:
python-version: ["3.8","3.11"]
python-version: ["3.10", "3.12"]
# Test two environments:
# 1) dependencies with pinned versions from requirements.txt
# 2) 'pip install --upgrade --upgrade-strategy=eager .' to install upgraded
Expand All @@ -33,14 +36,16 @@ jobs:

- name: Install Radiance v5.3
run: |
wget https://github.com/LBNL-ETA/Radiance/releases/download/012cb178/Radiance_012cb178_Linux.zip -O radiance.zip
#wget https://github.com/LBNL-ETA/Radiance/releases/download/012cb178/Radiance_012cb178_Linux.zip -O radiance.zip
wget https://github.com/LBNL-ETA/Radiance/releases/download/rad6R0P2/Radiance_c1700d56_Linux.zip -O radiance.zip
unzip radiance.zip
tar -xvf radiance-5.3.012cb17835-Linux.tar.gz
#tar -xvf radiance-5.3.012cb17835-Linux.tar.gz
tar -xvf radiance-6.0.c1700d56cc-Linux.tar.gz
ls -l $PWD

- name: Copy gencumulativesky into radiance /bin
run: |
cp $PWD/bifacial_radiance/data/gencumulativesky $PWD/radiance-5.3.012cb17835-Linux/usr/local/radiance/bin/
cp $PWD/bifacial_radiance/data/gencumulativesky $PWD/radiance-6.0.c1700d56cc-Linux/usr/local/radiance/bin/

- name: Install SMARTS 2.9.5
run: |
Expand All @@ -61,17 +66,18 @@ jobs:
- name: Set environment variables
run: |
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#adding-a-system-path
echo "/home/runner/work/bifacial_radiance/bifacial_radiance/radiance-5.3.012cb17835-Linux/usr/local/radiance/bin" >> $GITHUB_PATH
echo "/home/runner/work/bifacial_radiance/bifacial_radiance/radiance-6.0.c1700d56cc-Linux/usr/local/radiance/bin" >> $GITHUB_PATH
echo "/home/runner/work/bifacial_radiance/bifacial_radiance/SMARTS_295_Linux" >> $GITHUB_PATH

- name: Install xvfb
run: sudo apt-get update && sudo apt-get install -y xvfb

- name: Test with pytest ${{ matrix.env }}
uses: coactions/setup-xvfb@6b00cf1889f4e1d5a48635647013c0508128ee1a # GUI testing requires xvfb
with:
run: |
coverage run -m pytest
coverage report
run: |
xvfb-run -a coverage run -m pytest
coverage report
env: # environment variables available to this step
RAYPATH: .:/home/runner/work/bifacial_radiance/bifacial_radiance/radiance-5.3.012cb17835-Linux/usr/local/radiance/lib
RAYPATH: .:/home/runner/work/bifacial_radiance/bifacial_radiance/radiance-6.0.c1700d56cc-Linux/usr/local/radiance/lib
SMARTSPATH: /home/runner/work/bifacial_radiance/bifacial_radiance/SMARTS_295_Linux

- name: Coveralls
Expand Down
120 changes: 120 additions & 0 deletions PYRADIANCE_INTEGRATION_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# PyRadiance Integration Summary

## Overview
Successfully integrated pyradiance package into bifacial_radiance to replace subprocess calls to RADIANCE commands with native Python function calls where possible.

## Changes Made

### 1. Main Integration (bifacial_radiance/main.py)

#### Added PyRadiance Import and Availability Check
- Added try/except block to import pyradiance
- Created `PYRADIANCE_AVAILABLE` global flag
- Added fallback warning if pyradiance is not available

#### Replaced RADIANCE Command Calls

**oconv (Octree Creation):**
- Replaced `_popen(['oconv'] + filelist)` with `pyradiance.oconv(*filelist)`
- Added fallback to subprocess if pyradiance fails
- Handles both string and bytes output appropriately

**rpict (Picture Rendering):**
- Replaced command string construction with `pyradiance.rpict(view_params, octfile, params=ray_params)`
- Parses view files to extract view parameters
- Maintains same ray tracing parameters for quality

**rtrace (Ray Tracing):**
- Replaced `rtrace` command with `pyradiance.rtrace(rays, octfile, params=params)`
- Supports both 'low' and 'high' accuracy modes
- Handles ray input encoding and output decoding

**falsecolor (False Color Generation):**
- Replaced `falsecolor` command with `pyradiance.falsecolor(image, label, multiplier, scale, ndivs)`
- Maintains auto-scaling functionality
- Handles both fixed scale (1100) and dynamic scaling

**gendaylit (Sky Generation):**
- Replaced inline `!gendaylit` commands with `pyradiance.gendaylit()`
- Converts datetime objects appropriately
- Maintains DNI, DHI, and ground reflectance parameters
- Falls back to RADIANCE command strings if pyradiance fails

#### Commands Kept as Subprocess (Not Available in PyRadiance)
- `gencumulativesky` - Custom RADIANCE command
- `pextrem` - Extrema finding utility
- `objview` - Interactive viewer
- `rad` - High-level RADIANCE script

### 2. Module Integration (bifacial_radiance/module.py)

#### Updated Import Structure
- Added pyradiance availability check
- Imported `PYRADIANCE_AVAILABLE` flag from main module

#### Updated Commands
- Added TODO comments for `objview` and `rad` commands
- Maintained existing functionality with subprocess fallback

### 3. Test Infrastructure

#### Created Integration Test (test_pyradiance_integration.py)
- Tests pyradiance import and availability
- Verifies RADIANCE function availability
- Tests bifacial_radiance integration
- Provides clear pass/fail feedback

## Benefits of Integration

1. **Performance**: Native Python calls are faster than subprocess overhead
2. **Error Handling**: Better exception handling and error messages
3. **Memory Efficiency**: Direct data passing without file I/O for intermediate results
4. **Platform Independence**: Reduces dependency on system PATH and executable location
5. **Maintainability**: Easier to debug and maintain Python code vs subprocess calls

## Fallback Strategy

The integration maintains full backward compatibility:
- If pyradiance is not installed, falls back to subprocess calls
- If pyradiance functions fail, falls back to subprocess calls
- All original functionality is preserved
- No breaking changes to existing API

## Testing Status

✅ **PASSED**: Integration test confirms:
- PyRadiance imports successfully
- RADIANCE functions are available
- Bifacial_radiance integrates properly
- RadianceObj can be created without errors

## Installation Requirements

To use pyradiance integration:
```bash
# Install pyradiance (assuming conda environment)
conda install pyradiance

# Or with pip
pip install pyradiance
```

## Future Enhancements

1. **Additional Function Coverage**: Replace more RADIANCE commands as pyradiance adds support
2. **Performance Optimization**: Benchmark and optimize function call patterns
3. **Error Recovery**: Enhance fallback mechanisms for edge cases
4. **Documentation**: Update user documentation to mention pyradiance benefits

## Files Modified

- `bifacial_radiance/main.py` - Main integration and function replacements
- `bifacial_radiance/module.py` - Module-specific integration
- `test_pyradiance_integration.py` - Integration testing (new file)
- `PYRADIANCE_INTEGRATION_SUMMARY.md` - This documentation (new file)

## Branch Information

- **Branch**: 533_pyradiance
- **Purpose**: PyRadiance integration for NREL/bifacial_radiance
- **Status**: Ready for testing and review
Loading
Loading