def get_maximum_valid_range(self): """find maximum spectral range that spans real and imaginary data. Checks both real and imaginary parts of spectral data and finds the maximum spectral range which is valid for both parts. Returns ------- 2x1 np.array the maximum valid range """ if not (self.data['name'] == 'nk' or self.data['name'] == 'eps'): raise RuntimeError("valid_range cannot be defined as " + "Material does not yet contain " + " a valid n/k or permittivity spectrum") if self.data['complex'] is None: real_range_std = self.data['real'].valid_range.standard_rep imag_range_std = self.data['imag'].valid_range.standard_rep real_lower = np.min(real_range_std) real_upper = np.max(real_range_std) imag_lower = np.min(imag_range_std) imag_upper = np.max(imag_range_std) lower = np.max([real_lower, imag_lower]) upper = np.min([real_upper, imag_upper]) else: lower = np.min(self.data['complex'].valid_range.values) upper = np.max(self.data['complex'].valid_range.values) max_range = np.array([lower, upper]) spec = Spectrum(max_range) return spec.convert_to(self.defaults['spectrum_type'], self.defaults['unit'])
def test_to_wavenumber(): spectrum = Spectrum([500, 800], spectrum_type='wavelength', unit='nanometer') vals = spectrum.convert_to('wavenumber', '1/cm')
def test_to_frequency(): spectrum = Spectrum([500, 800], spectrum_type='wavelength', unit='nanometer') vals = spectrum.convert_to('frequency', 'hz')
def test_to_angfrequency(): spectrum = Spectrum([500, 800], spectrum_type='wavelength', unit='nanometer') vals = spectrum.convert_to('angularfrequency', '1/s')
def test_from_energy(): spectrum = Spectrum([500, 800], spectrum_type='wavelength', unit='nanometer') vals = spectrum.convert_to('energy', 'ev')