Beispiel #1
0
def load_camera(config, world):

    if config['machine']['name'] == "MAST-U":

        from cherab.mastu.cameras import load_camera as load_mastu_camera

        camera = load_mastu_camera(config["observer"]["camera_id"],
                                   world,
                                   stride=config["observer"]["stride"])

    else:
        raise ValueError(
            "Automatic camera loading is not supported for your machine.")

    pipelines = []

    if config["observer"]["display_progress"]:
        display_progress = True
    else:
        display_progress = False

    if config["observer"]["rgb_pipeline"]:
        rgb = RGBPipeline2D(display_unsaturated_fraction=0.96,
                            name="sRGB",
                            display_progress=display_progress,
                            display_update_time=15)
        pipelines.append(rgb)

    if config["observer"]["power_pipeline"]:
        power = PowerPipeline2D(display_unsaturated_fraction=0.96,
                                name="Unfiltered Power (W)",
                                display_progress=display_progress,
                                display_update_time=15)
        pipelines.append(power)

    if config["observer"]["radiance_pipeline"]:
        radiance = RadiancePipeline2D(display_unsaturated_fraction=0.96,
                                      name="Unfiltered Radiance (W/m^2/str)",
                                      display_progress=display_progress,
                                      display_update_time=15)
        pipelines.append(radiance)

    camera.pipelines = pipelines
    camera.pixel_samples = config["raytracing"]["pixel_samples"]

    return camera
Beispiel #2
0
         world,
         transform=translate(0.5, 5, 6) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 0.5))
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 4) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 0.5))
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 2) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 0.5))

# observer
rgb = RGBPipeline2D(display_unsaturated_fraction=0.85)
sampler = RGBAdaptiveSampler2D(rgb,
                               ratio=10,
                               fraction=0.2,
                               min_samples=500,
                               cutoff=0.01)
camera = PinholeCamera((1024, 512),
                       pipelines=[rgb],
                       frame_sampler=sampler,
                       transform=translate(0, 3.3, 0) * rotate(0, -47, 0),
                       fov=42,
                       parent=world)
camera.spectral_rays = 1
camera.spectral_bins = 15
camera.pixel_samples = 250
Beispiel #3
0
                     parent=world,
                     transform=translate(-1.1, 1, 0.8) * rotate(10, 0, 0))

box_rotated = Box(Point3D(-1, -1, -0.25),
                  Point3D(1, 1, 0.25),
                  material=VolumeTransform(CosGlow(), rotate(0, 90, 0)),
                  parent=world,
                  transform=translate(-3.2, 1, 0) * rotate(30, 0, 0))

floor = Box(Point3D(-100, -0.1, -100),
            Point3D(100, 0, 100),
            world,
            material=RoughTitanium(0.1))

# camera
rgb_pipeline = RGBPipeline2D(display_update_time=5)
sampler = RGBAdaptiveSampler2D(rgb_pipeline, min_samples=100, fraction=0.2)
camera = PinholeCamera((512, 256),
                       parent=world,
                       transform=translate(0, 6.5, -10) * rotate(0, -30, 0),
                       pipelines=[rgb_pipeline],
                       frame_sampler=sampler)
camera.spectral_bins = 15
camera.spectral_rays = 1
camera.pixel_samples = 100

# integration resolution
box_unshifted.material.integrator.step = 0.05
box_down_shifted.material.material.integrator.step = 0.05
box_up_shifted.material.material.integrator.step = 0.05
box_rotated.material.material.integrator.step = 0.05
Beispiel #4
0
# checker board wall that acts as emitter
emitter = Box(lower=Point3D(-10, -10, 10), upper=Point3D(10, 10, 10.1),
              material=Checkerboard(4, d65_white, d65_white, 0.1, 2.0), transform=rotate(45, 0, 0))

# Sphere
# Note that the sphere must be displaced slightly above the ground plane to prevent numerically issues that could
# cause a light leak at the intersection between the sphere and the ground.
sphere = Sphere(radius=1.5, transform=translate(0, 0.0001, 0), material=schott("N-BK7"))


# 2. Add Observer
# ---------------

# Process the ray-traced spectra with the RGB pipeline.
rgb = RGBPipeline2D()

# camera
camera = PinholeCamera((512, 512), pipelines=[rgb], transform=translate(0, 10, -10) * rotate(0, -45, 0))

# camera - pixel sampling settings
camera.fov = 45
camera.pixel_samples = 250

# camera - ray sampling settings
camera.spectral_rays = 1
camera.spectral_bins = 20
camera.ray_max_depth = 100
camera.ray_extinction_prob = 0.1
camera.min_wavelength = 375.0
camera.max_wavelength = 740.0
Beispiel #5
0
    def check_scene(self, max_iter=200):

        self.vessel.material = Lambert(blue)
        self.camera_outer.material = Lambert(yellow)
        self.camera_top.material = Lambert(yellow)
        self.source.material = Lambert(green)
        self.top_pinhole.material = Lambert(green)
        self.out_pinhole.material = Lambert(green)

        # cube walls
        bottom = Box(lower=Point3D(-0.99, -1.02, -0.99),
                     upper=Point3D(0.99, -1.01, 0.99),
                     parent=self.world,
                     material=Lambert(red))
        # top = Box(lower=Point3D(-0.99, 1.01, -0.99), upper=Point3D(0.99, 1.02, 0.99), parent=self.world,
        #           material=Lambert(red))
        left = Box(lower=Point3D(1.01, -0.99, -0.99),
                   upper=Point3D(1.02, 0.99, 0.99),
                   parent=self.world,
                   material=Lambert(yellow))
        # right = Box(lower=Point3D(-1.02, -0.99, -0.99), upper=Point3D(-1.01, 0.99, 0.99), parent=self.world,
        #             material=Lambert(purple))
        back = Box(lower=Point3D(-0.99, -0.99, 1.01),
                   upper=Point3D(0.99, 0.99, 1.02),
                   parent=self.world,
                   material=Lambert(orange))

        # various wall light sources
        light_front = Box(lower=Point3D(-1.5, -1.5, -10.1),
                          upper=Point3D(1.5, 1.5, -10),
                          parent=self.world,
                          material=UniformSurfaceEmitter(d65_white, 1.0))
        light_top = Box(lower=Point3D(-0.99, 1.01, -0.99),
                        upper=Point3D(0.99, 1.02, 0.99),
                        parent=self.world,
                        material=UniformSurfaceEmitter(d65_white, 1.0),
                        transform=translate(0, 1.0, 0))

        light_bottom = Box(lower=Point3D(-0.99, -3.02, -0.99),
                           upper=Point3D(0.99, -3.01, 0.99),
                           parent=self.world,
                           material=UniformSurfaceEmitter(d65_white, 1.0),
                           transform=translate(0, 1.0, 0))

        light_right = Box(lower=Point3D(-1.92, -0.99, -0.99),
                          upper=Point3D(-1.91, 0.99, 0.99),
                          parent=self.world,
                          material=UniformSurfaceEmitter(d65_white, 1.0))

        light_left = Box(lower=Point3D(1.91, -0.99, -0.99),
                         upper=Point3D(1.92, 0.99, 0.99),
                         parent=self.world,
                         material=UniformSurfaceEmitter(d65_white, 1.0))

        # Process the ray-traced spectra with the RGB pipeline.
        rgb = RGBPipeline2D()

        # camera
        pix = 1000
        camera = PinholeCamera(
            (pix, pix),
            pipelines=[rgb],
            transform=translate(-0.01, 0.0, -0.25) * rotate(0, 0, 0))
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(0.0, 0.0, 0.4) * rotate(180, 0, 0))
        # top view
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(0.0, self.vessel_out_rad+0.15, self.vessel_width/2)*rotate(0, -90, 0))
        # prof
        camera = PinholeCamera(
            (pix, pix),
            pipelines=[rgb],
            transform=translate(-0.13, 0.13, -0.2) * rotate(-25, -25.0, 0))

        # camera top side
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top, self.top_px_first_y+0.0004, self.top_px_z-self.cam_in_radius+0.005)*rotate(0, 0, 0))
        # camera top down-up
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top, self.top_px_first_y-0.01, self.vessel_width/2)*rotate(0, 90, 0))
        # camera top up-down
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top-0.004, self.top_px_first_y+self.lid_top+self.tube_height-0.01, self.vessel_width/2)*rotate(0, -90, 0))

        # camera out side
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(-self.vessel_out_rad-0.015, 0.000, self.vessel_width/2-self.cam_in_radius/2+0.0001))
        # camera out down-up
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.out_px_first_x+0.005+0.005, 0.0, self.vessel_width/2)*rotate(90, 0, 0))
        # camera out up-down
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(-self.vessel_out_rad-self.tube_height-0.01, 0.0, self.vessel_width/2-0.005)*rotate(-90, 0, 0))

        # camera - pixel sampling settings
        camera.fov = 60  # 45
        camera.pixel_samples = 10

        # camera - ray sampling settings
        camera.spectral_rays = 1
        camera.spectral_bins = 25
        camera.parent = self.world

        plt.ion()
        p = 1
        while not camera.render_complete:
            print("Rendering pass {}...".format(p))
            camera.observe()
            print()
            p += 1
            if p > max_iter:
                break

        plt.ioff()
        rgb.display()
Beispiel #6
0
glass = Subtract(glass_outer,
                 glass_inner,
                 material=schott("N-BK7"),
                 parent=light_box)

emitter = Box(Point3D(-0.10 + glass_thickness + padding,
                      -0.02 + glass_thickness + padding,
                      -0.10 + glass_thickness + padding),
              Point3D(0.10 - glass_thickness - padding,
                      0.0 - glass_thickness - padding,
                      0.10 - glass_thickness - padding),
              material=UniformVolumeEmitter(d65_white, 50),
              parent=light_box)

# CAMERA
rgb = RGBPipeline2D(display_unsaturated_fraction=0.96, name="sRGB")
sampler = RGBAdaptiveSampler2D(rgb,
                               ratio=10,
                               fraction=0.2,
                               min_samples=2000,
                               cutoff=0.01)
camera = PinholeCamera((1024, 1024),
                       parent=world,
                       transform=translate(0, 0.16, -0.4) * rotate(0, -12, 0),
                       pipelines=[rgb],
                       frame_sampler=sampler)
camera.spectral_rays = 15
camera.spectral_bins = 15
camera.pixel_samples = 250
camera.ray_max_depth = 500
camera.ray_extinction_min_depth = 3
Beispiel #7
0
         1.0,
         world,
         transform=translate(0.5, 5, 6) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 4) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 2) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))

rgb = RGBPipeline2D(name="sRGB")
sampler = RGBAdaptiveSampler2D(rgb,
                               ratio=10,
                               fraction=0.2,
                               min_samples=500,
                               cutoff=0.05)

# observer
camera = PinholeCamera((512, 256),
                       fov=42,
                       parent=world,
                       transform=translate(0, 3.3, 0) * rotate(0, -47, 0),
                       pipelines=[rgb],
                       frame_sampler=sampler)
camera.spectral_bins = 25
camera.pixel_samples = 250
Beispiel #8
0
    material=RoughTitanium(0.1))

# front light
Sphere(5,
       world,
       transform=translate(1, 8, -10),
       material=UniformVolumeEmitter(d65_white, 1.0))

# fill light
Sphere(10,
       world,
       transform=translate(7, 20, 20),
       material=UniformSurfaceEmitter(d65_white, 0.15))

# camera
rgb = RGBPipeline2D(display_update_time=15, display_unsaturated_fraction=0.995)
sampler = RGBAdaptiveSampler2D(rgb,
                               min_samples=1000,
                               fraction=0.1,
                               cutoff=0.01)
camera = PinholeCamera((1024, 1024),
                       parent=world,
                       transform=translate(0, 4, -3.5) * rotate(0, -46, 0),
                       pipelines=[rgb],
                       frame_sampler=sampler)
camera.spectral_bins = 21
camera.spectral_rays = 21
camera.pixel_samples = 250
camera.ray_max_depth = 10000
camera.ray_extinction_min_depth = 3
camera.ray_extinction_prob = 0.002