Skip to content

Commit

Permalink
Merge pull request raysect#238 from raysect/development
Browse files Browse the repository at this point in the history
Release v0.5.3
  • Loading branch information
CnlPepper authored Aug 30, 2018
2 parents 4a77981 + 31b7747 commit 412479a
Show file tree
Hide file tree
Showing 139 changed files with 2,735 additions and 1,071 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Raysect Changelog
=================

Release 0.5.3 (30 Aug 2018)
---------------------------

Bug Fixes:
* Mesh load() not correctly populating vertex and triangle data arrays.
* Missing import guard for OpenCV camera, users no longer forced to install OpenCV!
* VTK importer no longer crashes when mesh name is None.

New:
* Pickle support added to all scenegraph objects. It is now possible to pickle a scenegraph.
* Mesh normals can be flipped during import/creation with new flip_normals argument.
* Optimised ImportanceManager gaining a 7% speedup for Cornell Box test case.
* Optimised method call in optical.Ray gaining a 2% speedup for Cornell Box test case.


Release 0.5.2 (7 Aug 2018)
--------------------------

Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include README.md CHANGELOG.txt LICENSE.txt CONTRIBUTING.txt AUTHORS.txt MANIFEST.in setup.py .gitignore
recursive-include raysect *.py *.pyx *.pxd *.csv *.json
include raysect/VERSION
recursive-include raysect *.py *.pyx *.pxd *.csv *.json *.c
recursive-include demos *.py *.pyx *.pxd *.csv *.obj *.rsm
recursive-include docs *
File renamed without changes.
13 changes: 4 additions & 9 deletions demos/bunny.py → demos/materials/bunny.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from raysect.optical.material.emitter import UniformVolumeEmitter
from raysect.optical.material import Lambert
from raysect.primitive import Box, Subtract
from raysect.primitive.mesh import Mesh
from raysect.primitive.mesh import Mesh, import_obj
from raysect.optical.library import schott


Expand All @@ -27,17 +27,12 @@

base_path = os.path.split(os.path.realpath(__file__))[0]

# DIAMOND MATERIAL
diamond = Dielectric(Sellmeier(0.3306, 4.3356, 0.0, 0.1750**2, 0.1060**2, 0.0), ConstantSF(1.0))

world = World()

# BUNNY
# mesh = import_obj(os.path.join(base_path, "resources/stanford_bunny.obj"), scaling=1, parent=world,
# transform=translate(0, 0, 0)*rotate(165, 0, 0), material=diamond)
# BUNNY
mesh = import_obj(os.path.join(base_path, "../resources/stanford_bunny.obj"), parent=world,
transform=translate(0, 0, 0)*rotate(165, 0, 0), material=schott("N-BK7"))

mesh = Mesh.from_file(os.path.join(base_path, "resources/stanford_bunny.rsm"), parent=world,
transform=translate(0, 0, 0)*rotate(165, 0, 0), material=diamond)

# LIGHT BOX
padding = 1e-5
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions demos/materials/volume.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import os
import time
from matplotlib.pyplot import *
from numpy import sqrt, cos
Expand All @@ -8,6 +9,7 @@
from raysect.optical.material import InhomogeneousVolumeEmitter
from raysect.optical.observer import PinholeCamera, RGBPipeline2D, RGBAdaptiveSampler2D
from raysect.primitive import Box
from raysect.core.workflow import MulticoreEngine


class CosGlow(InhomogeneousVolumeEmitter):
Expand All @@ -34,11 +36,13 @@ def emission_function(self, point, direction, spectrum, world, ray, primitive, t
camera.spectral_bins = 15
camera.spectral_rays = 1
camera.pixel_samples = 200
camera.render_engine = MulticoreEngine(4)

# integration resolution
emitter.material.integrator.step = 0.05

# start ray tracing
os.nice(15)
ion()
timestamp = time.strftime("%Y-%m-%d_%H-%M-%S")
for p in range(1, 1000):
Expand Down
File renamed without changes.
100 changes: 100 additions & 0 deletions demos/observers/mesh_power.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

import csv
import os
from math import pi

from raysect.core import translate, rotate_x
from raysect.primitive import Sphere, import_obj, export_vtk
from raysect.optical import World
from raysect.optical.observer import MeshPixel, MeshCamera, PowerPipeline0D, PowerPipeline1D, MonoAdaptiveSampler1D

from raysect.optical.material import AbsorbingSurface
from raysect.optical.material.emitter import UnityVolumeEmitter


def write_results(basename, camera, mesh):

# obtain frame from pipeline
frame = camera.pipelines[0].frame

# calculate power density
power_density = frame.mean / camera.collection_areas
error = frame.errors() / camera.collection_areas

# write as csv
with open(basename + '.csv', 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(('Triangle Index', 'Power Density / Wm-2', 'Error / Wm-2'))
for index in range(frame.length):
writer.writerow((index, power_density[index], error[index]))

triangle_data = {'PowerDensity': power_density, 'PowerDensityError': error}
export_vtk(mesh, basename + '.vtk', triangle_data=triangle_data)


samples = 1000000

sphere_radius = 0.01

min_wl = 400
max_wl = 401


# set-up scenegraph
world = World()
emitter = Sphere(radius=sphere_radius, parent=world, transform=rotate_x(-90)*translate(-0.05409, -0.01264, 0.10064))


base_path = os.path.split(os.path.realpath(__file__))[0]
mesh = import_obj(os.path.join(base_path, "../resources/stanford_bunny.obj"),
material=AbsorbingSurface(), parent=world, flip_normals=True)


power = PowerPipeline0D(accumulate=False)
observer = MeshPixel(mesh, pipelines=[power], parent=world,
min_wavelength=min_wl, max_wavelength=max_wl,
spectral_bins=1, pixel_samples=samples, surface_offset=1E-6)


print("Starting observations with volume emitter...")
calculated_volume_emission = 16 / 3 * pi**2 * sphere_radius**3 * (max_wl - min_wl)

emitter.material = UnityVolumeEmitter()
observer.observe()
measured_volume_emission = power.value.mean
measured_volume_error = power.value.error()

print()
print('Expected volume emission => {} W'.format(calculated_volume_emission))
print('Measured volume emission => {} +/- {} W'.format(measured_volume_emission, measured_volume_error))


power = PowerPipeline1D()
sampler = MonoAdaptiveSampler1D(power, fraction=0.2, ratio=25.0, min_samples=1000, cutoff=0.1)
camera = MeshCamera(
mesh,
surface_offset=1e-6, # launch rays 1mm off surface to avoid intersection with absorbing mesh
pipelines=[power],
frame_sampler=sampler,
parent=world,
spectral_bins=1,
min_wavelength=400,
max_wavelength=401,
pixel_samples=250
)


# render
print('Observing the bunny Mesh...')
output_basename = "bunny_power"
render_pass = 0
while (not camera.render_complete) and (render_pass < 500):
render_pass += 1
print('Render pass {}:'.format(render_pass))
camera.observe()
write_results(output_basename, camera, mesh)

print('Observation complete!')

# export final data as csv
write_results(output_basename, camera, mesh)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion dev/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

CORES=`nproc --all`

echo "Rebuilding Raysect extension modules (in place)..."
python setup.py build_ext --inplace $1 $2 $3 $4 $5
python setup.py build_ext -j$CORES --inplace --use-cython $1 $2 $3 $4 $5
Loading

0 comments on commit 412479a

Please sign in to comment.