Skip to content

Commit

Permalink
Merge pull request #16 from LBNL-ETA/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
taoning authored Jul 13, 2023
2 parents 9e0d8c6 + 8dcb45c commit 7830645
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
python setup.py bdist_wheel
- name: upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl

Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
python setup.py bdist_wheel
- name: upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl

Expand All @@ -80,7 +80,7 @@ jobs:
build_test_windows:
runs-on: windows-latest
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
Expand All @@ -105,7 +105,7 @@ jobs:
python setup.py bdist_wheel
- name: upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl

Expand Down
2 changes: 2 additions & 0 deletions pyradiance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@

from .util import (
dctimestep,
evalglare,
get_header,
get_image_dimensions,
getinfo,
Expand Down Expand Up @@ -104,6 +105,7 @@
"bsdf2ttree",
"cnt",
"dctimestep",
"evalglare",
"genblinds",
"genbsdf",
"gendaylit",
Expand Down
11 changes: 0 additions & 11 deletions pyradiance/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,6 @@ def parse_view(vstr: str) -> View:
args_list = vstr.strip().split()
vparser = argparse.ArgumentParser()
vparser = add_view_args(vparser)
# vparser.add_argument("-v", action="store", dest="vt")
# vparser.add_argument("-vp", nargs=3, type=float, default=(0, 0, 0))
# vparser.add_argument("-vd", nargs=3, type=float, default=(0, 1, 0))
# vparser.add_argument("-vu", nargs=3, type=float, default=(0, 0, 1))
# vparser.add_argument("-vv", type=float, default=45)
# vparser.add_argument("-vh", type=float, default=45)
# vparser.add_argument("-vo", type=float, default=0)
# vparser.add_argument("-va", type=float, default=0)
# vparser.add_argument("-vs", type=float, default=0)
# vparser.add_argument("-vl", type=float, default=0)
# vparser.add_argument("-vf", type=argparse.FileType("r"))
args, _ = vparser.parse_known_args(args_list)
if args.vf is not None:
args, _ = vparser.parse_known_args(
Expand Down
107 changes: 107 additions & 0 deletions pyradiance/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,113 @@
from .ot import getbbox


@handle_called_process_error
def evalglare(
inp,
view: Optional[List[str]] = None,
detailed: bool = False,
ev_only: bool = False,
ev: Optional[float] = None,
smooth: bool = False,
threshold: Optional[float] = None,
task_area: Optional[tuple] = None,
masking_file: Optional[Union[str, Path]] = None,
band_lum_angle: Optional[float] = None,
check_file: Optional[Union[str, Path]] = None,
correction_mode: Optional[str] = None,
peak_extraction: bool = True,
peak_extraction_value: float = 50000,
bg_lum_mode: int = 0,
search_radius: float = 0.2,
version: bool = False,
source_color: Optional[Tuple[float, float, float]] = None,
):
"""Run evalglare on a Radiance image.
Args:
inp: input image
view: view parameters
detailed: detailed output
ev_only: return vertical illuminance value
ev: vertical illuminance value to use instead of the one computer from the image.
smooth: enable smoothing function.
threshold: Threshold factor.
task_area: task area
masking_file: masking file
band_lum_angle: band luminance angle
check_file: check file path.
correction_mode: correction mode
peak_extraction: enable luminance peak extraction
peak_extraction_value: luminance peak extraction value
bg_lum_mode: background luminance calculation mode
search_radius: search radius
version: print version
source_color: source color
Returns:
Evalglare output
"""
stdin = None
cmd = [str(BINPATH / "evalglare")]
if version:
cmd.append("-v")
return sp.run(cmd, check=True, capture_output=True).stdout
if ev_only:
cmd.append("-V")
else:
if detailed:
cmd.append("-d")
if ev is not None:
if isinstance(ev, (float, int)):
cmd.extend(["-i", str(ev)])
else:
cmd.extend(["-I", *map(str, ev)])
if view is not None:
cmd.extend(view)
if check_file is not None:
cmd.append("-c")
cmd.append(str(check_file))
if source_color is not None:
cmd.append("-u")
cmd.extend(*map(str, source_color))
if smooth:
cmd.append("-s")
if threshold is not None:
cmd.append("-b")
cmd.append(str(threshold))
if task_area:
if check_file is not None:
cmd.append("-T")
else:
cmd.append("-t")
cmd.extend(*map(str, task_area))
if bg_lum_mode:
cmd.append("-q")
cmd.append(str(bg_lum_mode))
if masking_file:
cmd.append("-A")
cmd.append(str(masking_file))
if band_lum_angle:
cmd.append("-B")
cmd.append(str(band_lum_angle))
if correction_mode:
cmd.append("-C")
cmd.append(str(correction_mode))
if not peak_extraction:
cmd.append("-x")
if peak_extraction_value:
cmd.append("-Y")
cmd.append(str(peak_extraction_value))
if search_radius != 0.2:
cmd.append("-r")
cmd.append(str(search_radius))
if isinstance(inp, bytes):
stdin = inp
elif isinstance(inp, (Path, str)):
cmd.append(str(inp))
else:
raise ValueError("input must be a path, string, or bytes")
return sp.run(cmd, input=stdin, check=True, capture_output=True).stdout


@handle_called_process_error
def dctimestep(
*mtx,
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from auditwheel.wheeltools import InWheel
from wheel.bdist_wheel import bdist_wheel

RADTAG = "2f5bc2ef"
RADTAG = "ee06fd82"

RADBINS = [
'bsdf2ttree',
Expand Down Expand Up @@ -230,6 +230,7 @@
"Radiance/src/common/error.c",
"Radiance/src/common/ezxml.c",
"Radiance/src/common/face.c",
"Radiance/src/common/fdate.c",
"Radiance/src/common/fgetline.c",
"Radiance/src/common/fgetval.c",
"Radiance/src/common/fgetword.c",
Expand Down Expand Up @@ -477,7 +478,7 @@ def get_ext_filename(self, ext_name):
name="pyradiance",
author="LBNL",
author_email="[email protected]",
version="0.0.10a1",
version="0.1.0b1",
description="Python interface for Radiance command-line tools",
long_description=Path("README.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
Expand Down
2 changes: 0 additions & 2 deletions test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ def test_BSDF():
def test_parse_view():
inp_str = "-vta -vv 180 -vh 180 -vp 0 0 0 -vd 0 -1 0"
res = model.parse_view(inp_str)
answer = {"vt": "a", "vv": 180, "vh": 180,
"vp": [0, 0, 0], "vd": [0, -1, 0]}
assert res.position == [0, 0, 0]
assert res.direction == [0, -1, 0]
assert res.vtype == "a"
Expand Down

0 comments on commit 7830645

Please sign in to comment.