Example #1
0
    def calculate_sensitivity(self, voxel_collection, ray_count=10000):
        """
        Calculates a sensitivity vector for this detector on the specified voxel collection.

        This function is used for calculating sensitivity matrices which can be combined for
        multiple detectors into a sensitivity matrix :math:`\mathbf{W}`.

        :param VoxelCollection voxel_collection: The voxel collection on which to calculate
          the sensitivities.
        :param int ray_count: The number of rays to use in the calculation. This should be
          at least >= 10000 for decent statistics.
        :return: A 1D array of sensitivities with length equal to the number of voxels
          in the collection.
        """

        if not isinstance(voxel_collection, VoxelCollection):
            raise TypeError("voxel_collection must be of type VoxelCollection")

        if self.units == "Power":
            pipeline = SpectralPowerPipeline0D(display_progress=False)
        elif self.units == "Radiance":
            pipeline = SpectralRadiancePipeline0D(display_progress=False)
        else:
            raise ValueError(
                "Sensitivity units can only be of type 'Power' or 'Radiance'.")

        voxel_collection.set_active("all")

        cached_max_wavelength = self.max_wavelength
        cached_min_wavelength = self.min_wavelength
        cached_bins = self.spectral_bins
        cached_pipelines = self.pipelines
        cached_ray_count = self.pixel_samples

        self.pipelines = [pipeline]
        self.min_wavelength = 1
        self.max_wavelength = voxel_collection.count + 1
        self.spectral_bins = voxel_collection.count
        self.pixel_samples = ray_count

        self.observe()

        self.max_wavelength = cached_max_wavelength
        self.min_wavelength = cached_min_wavelength
        self.spectral_bins = cached_bins
        self.pipelines = cached_pipelines
        self.pixel_samples = cached_ray_count

        return pipeline.samples.mean
Example #2
0
    def calculate_sensitivity(self, voxel_collection, ray_count=10000):

        if not isinstance(voxel_collection, VoxelCollection):
            raise TypeError("voxel_collection must be of type VoxelCollection")

        if self.units == "Power":
            pipeline = SpectralPowerPipeline0D(display_progress=False)
        elif self.units == "Radiance":
            pipeline = SpectralRadiancePipeline0D(display_progress=False)
        else:
            raise ValueError(
                "Sensitivity units can only be of type 'Power' or 'Radiance'.")

        voxel_collection.set_active("all")

        cached_max_wavelength = self.max_wavelength
        cached_min_wavelength = self.min_wavelength
        cached_bins = self.spectral_bins
        cached_pipelines = self.pipelines
        cached_ray_count = self.pixel_samples

        self.pipelines = [pipeline]
        self.min_wavelength = 1
        self.max_wavelength = voxel_collection.count + 1
        self.spectral_bins = voxel_collection.count
        self.pixel_samples = ray_count

        self.observe()

        self.max_wavelength = cached_max_wavelength
        self.min_wavelength = cached_min_wavelength
        self.spectral_bins = cached_bins
        self.pipelines = cached_pipelines
        self.pixel_samples = cached_ray_count

        return pipeline.samples.mean
Example #3
0
                transform=translate(0, 0.0001, 0),
                material=schott("N-BK7"))

# 2. Build Scenegraph
# -------------------

world = World()

sphere.parent = world
ground.parent = world
emitter.parent = world

# 3. Add Observer
# ---------------

spectra = SpectralPowerPipeline0D()
power = PowerPipeline0D()
fibre = FibreOptic([spectra, power],
                   acceptance_angle=2,
                   radius=0.001,
                   transform=translate(0, 0, -5),
                   parent=world)
fibre.spectral_bins = 500
fibre.spectral_rays = 1
fibre.pixel_samples = pixel_samples = 1000

# 4. Observe()
# ------------

plt.ion()
fibre.observe()
Example #4
0
plt.plot(z, beam_half_densities, label="half energy")
plt.xlabel('z axis (beam coords)')
plt.ylabel('beam component density [m^-3]')
plt.title("Beam attenuation by energy component")
plt.legend()


# OBSERVATIONS ----------------------------------------------------------------
camera = PinholeCamera((128, 128), parent=world, transform=translate(1.25, -3.5, 0) * rotate_basis(Vector3D(0, 1, 0), Vector3D(0, 0, 1)))
camera.spectral_rays = 1
camera.spectral_bins = 15
camera.pixel_samples = 5

# turning off parallisation because this causes issues with the way RENATE currently loads atomic data
from raysect.core.workflow import SerialEngine
camera.render_engine = SerialEngine()

plt.ion()
camera.observe()

power = PowerPipeline0D(accumulate=False)
spectral_power = SpectralPowerPipeline0D()
los = SightLine(pipelines=[power, spectral_power], min_wavelength=640, max_wavelength=665,
                parent=world, transform=translate(*los_start) * rotate_basis(los_direction, Vector3D(0, 0, 1)))
los.pixel_samples = 1
los.spectral_bins = 2000
los.observe()

plt.ioff()
plt.show()