def __init__( self, coefficient, x=None, quantum_yield=1.0, phase_function=None, hist=False, name="Scatterer", ): """ Parameters ---------- coefficient: float, list, tuple or numpy.ndarray Specifies the scattering coefficient per unit length. Constant values can be supplied or a spectrum per nanometer per unit length. x: list, tuple of numpy.ndarray (optional) Wavelength values in nanometers. Required when specifying a the `coefficient` with an list or tuple. quantum_yield: float (optional) Default value is 1.0. To include non-radiative scattering use values between less than 1.0. phase_function callable (optional) Determines the direction of scattering. If None is supplied scattering is isotropic. hist: Bool Specifies how the coefficient spectrum is sampled. If `True` the values are treated as a histogram. If `False` the values are linearly interpolated. name: str A user-defined identifier string """ super(Scatterer, self).__init__(name=name) # Make absorption/scattering spectrum distribution self._coefficient = coefficient if coefficient is None: raise ValueError("Coefficient must be specified.") elif isinstance(coefficient, (float, np.float)): self._abs_dist = Distribution(x=None, y=coefficient, hist=hist) elif isinstance(coefficient, np.ndarray): self._abs_dist = Distribution(x=coefficient[:, 0], y=coefficient[:, 1], hist=hist) elif isinstance(coefficient, (list, tuple)): if x is None: raise ValueError("Requires `x`.") self._abs_dist = Distribution.from_functions(x, coefficient, hist=hist) self.quantum_yield = quantum_yield self.phase_function = (phase_function if phase_function is not None else isotropic)
def __init__( self, coefficient, emission=None, x=None, hist=False, quantum_yield=1.0, phase_function=None, name="Luminophore", ): """ coefficient: float, list, tuple or numpy.ndarray Specifies the absorption coefficient per unit length. Constant values can be supplied or a spectrum per nanometer per unit length. If using a list of tuple you should also specify the wavelengths using the `x` keyword. If using a numpy array use `column_stack` to supply a single array with a wavelength and coefficient values. emission: float, list, tuple or numpy.ndarray (optional) Specifies the emission line-shape per nanometer. If `None` will use a Gaussian centred at 600nm. If using a list of tuple you should also specify the wavelengths using the `x` keyword. If using a numpy array use `column_stack` to supply a single array with a wavelength and coefficient values. x: list, tuple of numpy.ndarray (optional) Wavelength values in nanometers. Required when specifying a the `coefficient` with an list or tuple. quantum_yield: float (optional) The probability of re-emitting a ray. phase_function callable (optional) Specifies the direction of emitted rays. hist: Bool Specifies how the absorption and emission spectra are sampled. If `True` the values are treated as a histogram. If `False` the values are linearly interpolated. name: str A user-defined identifier string """ super(Luminophore, self).__init__( coefficient, x=x, quantum_yield=quantum_yield, phase_function=phase_function, hist=hist, name=name, ) # Make emission spectrum distribution self._emission = emission if emission is None: self._ems_dist = Distribution.from_functions( x, [lambda x: gaussian(x, 1.0, 600.0, 40.0)], hist=hist) elif isinstance(emission, np.ndarray): self._ems_dist = Distribution(x=emission[:, 0], y=emission[:, 1], hist=hist) elif isinstance(emission, (tuple, list)): if x is None: raise ValueError("Requires `x`.") self._ems_dist = Distribution.from_functions(x, emission, hist=hist) else: raise ValueError("Luminophore `emission` arg has wrong type.")
def __init__(self, coefficient, x=None, quantum_yield=1.0, phase_function=None, hist=False, name="Scatterer"): """ coefficient: float, list, tuple or numpy.ndarray Specifies the scattering coefficient per unit length. Constant values can be supplied or a spectrum per nanometer per unit length. If using a list of tuple you should also specify the wavelengths using the `x` keyword:: x = numpy.linspace(600, 800) # nanometer values coefficient = list(numpy.ones(x.shape) * 1.5) # per nm per unit length Scatterer( coefficient, x=x ) If using a numpy array use `column_stack` to supply a single array with a wavelength and coefficient values:: Scatterer( coefficient=numpy.column_stack((x, y)) ) x: list, tuple of numpy.ndarray (optional) Wavelength values in nanometers. Required when specifying a the `coefficient` with an list or tuple. quantum_yield: float (optional) Default value is 1.0. To include non-radiative scattering use values between less than 1.0. phase_function callable (optional) Determines the direction of scattering. If None is supplied scattering is isotropic. hist: Bool Specifies how the coefficient spectrum is sampled. If `True` the values are treated as a histogram. If `False` the values are linearly interpolated. name: str A user-defined identifier string """ super(Scatterer, self).__init__(name=name) # Make absorption/scattering spectrum distribution self._coefficient = coefficient if coefficient is None: raise ValueError("Coefficient must be specified.") elif isinstance(coefficient, (float, np.float)): self._abs_dist = Distribution(x=None, y=coefficient, hist=hist) elif isinstance(coefficient, np.ndarray): self._abs_dist = Distribution(x=coefficient[:, 0], y=coefficient[:, 1], hist=hist) elif isinstance(coefficient, (list, tuple)): if x is None: raise ValueError("Requires `x`.") self._abs_dist = Distribution.from_functions(x, coefficient, hist=hist) self.quantum_yield = quantum_yield self.phase_function = phase_function if phase_function is not None else isotropic