def eq_spectrum(self, Tgas, mole_fraction=None, path_length=None): """Generate a spectrum at equilibrium Parameters ---------- Tgas: list or float Gas temperature (K) mole_fraction: list or float database species mole fraction. If None, Factory mole fraction is used. path_length: list or float slab size (cm). If None, Factory mole fraction is used. Returns ------- Returns a :class:`~radis.spectrum.spectrum.Spectrum` object Use the :meth:`~radis.spectrum.spectrum.Spectrum.get` method to get something among ``['radiance', 'radiance_noslit', 'absorbance', etc...]`` Or directly the :meth:`~radis.spectrum.spectrum.Spectrum.plot` method to plot it See [1]_ to get an overview of all Spectrum methods References ---------- .. [1] RADIS doc: `Spectrum how to? <https://radis.readthedocs.io/en/latest/spectrum/spectrum.html#label-spectrum>`__ Notes ----- Process: Calculate line strenghts correcting the CDSD reference one. Then call the main routine that sums over all lines """ args = self._format_input( **{ "Tgas": Tgas, "mole_fraction": mole_fraction, "path_length": path_length }) Tgas = args.pop("Tgas") mole_fraction = args.pop("mole_fraction") path_length = args.pop("path_length") # Expand metadata before copy, else it will be lost. # @dev: See :py:data:`~radis.lbl.loader.df_metadata` for more explanations expand_metadata(self.df0, [k for k in df_metadata if hasattr(self.df0, k)]) N = len(Tgas) cast_factory = [self ] * N # note that this is the copy of a same object! Nprocs = min(self.misc.Nprocs, N) if self.verbose: print(("Calculate {0} spectra on {1} procs".format( len(Tgas), Nprocs))) t1 = time() with Pool(Nprocs) as p: spec_list = p.map( _distribute_eq_spectrum, list(zip(cast_factory, Tgas, mole_fraction, path_length)), ) if self.verbose: print(("{0} spectra calculated in {1:.1f}s".format(N, time() - t1))) return spec_list
def non_eq_spectrum(self, Tvib, Trot, mole_fraction=None, path_length=None): """Calculate emission spectrum in non-equilibrium case. Calculates absorption with broadened linestrength and emission with broadened Einstein coefficient. Parameters ---------- Tvib: list or float vibrational temperature [K] Trot: list or float rotational temperature [K] mole_fraction: list or float database species mole fraction. If None, Factory mole fraction is used. path_length: list or float. If None, Factory mole fraction is used. slab size (cm) Returns ------- Returns a :class:`~radis.spectrum.spectrum.Spectrum` object Use the :meth:`~radis.spectrum.spectrum.Spectrum.get` method to get something among ``['radiance', 'radiance_noslit', 'absorbance', etc...]`` Or directly the :meth:`~radis.spectrum.spectrum.Spectrum.plot` method to plot it See [1]_ to get an overview of all Spectrum methods References ---------- .. [1] RADIS doc: `Spectrum how to? <https://radis.readthedocs.io/en/latest/spectrum/spectrum.html#label-spectrum>`__ Notes ----- Hypothesis: - Trot = Ttrans """ args = self._format_input( **{ "Tvib": Tvib, "Trot": Trot, "mole_fraction": mole_fraction, "path_length": path_length, }) Tvib = args["Tvib"] Trot = args["Trot"] mole_fraction = args["mole_fraction"] path_length = args["path_length"] # Expand metadata before copy, else it will be lost. # @dev: See :py:data:`~radis.lbl.loader.df_metadata` for more explanations expand_metadata(self.df0, [k for k in df_metadata if hasattr(self.df0, k)]) N = len(Tvib) cast_factory = [self ] * N # note that this is the copy of a same object! Nprocs = min(self.misc.Nprocs, N) if self.verbose: print(("Calculate {0} spectra on {1} procs".format( len(Tvib), Nprocs))) t1 = time() try: with Pool(Nprocs) as p: # Note: Python 3 syntax only spec_list = p.map( _distribute_noneq_spectrum, list( zip(cast_factory, Tvib, Trot, mole_fraction, path_length)), ) except AttributeError: if sys.version_info[0] == 2: raise NotImplementedError( "parallel is only implemented in Python 3. Time to switch!" ) else: raise if self.verbose: print(("{0} spectra calculated in {1:.1f}s".format(N, time() - t1))) return spec_list
def eq_spectrum(self, Tgas, mole_fraction=None, path_length=None): ''' Generate a spectrum at equilibrium Parameters ---------- Tgas: list or float Gas temperature (K) mole_fraction: list or float database species mole fraction. If None, Factory mole fraction is used. path_length: list or float slab size (cm). If None, Factory mole fraction is used. Returns ------- Returns a :class:`~radis.spectrum.spectrum.Spectrum` object Use the :meth:`~radis.spectrum.spectrum.Spectrum.get` method to get something among ``['radiance', 'radiance_noslit', 'absorbance', etc...]`` Or directly the :meth:`~radis.spectrum.spectrum.Spectrum.plot` method to plot it See [1]_ to get an overview of all Spectrum methods References ---------- .. [1] RADIS doc: `Spectrum how to? <http://radis.readthedocs.io/en/latest/#the-spectrum-class>`__ Notes ----- Process: Calculate line strenghts correcting the CDSD reference one. Then call the main routine that sums over all lines ''' args = self._format_input(**{'Tgas': Tgas, 'mole_fraction': mole_fraction, 'path_length': path_length}) Tgas = args.pop('Tgas') mole_fraction = args.pop('mole_fraction') path_length = args.pop('path_length') # Expand metadata before copy, else it will be lost. # @dev: See :py:data:`~radis.lbl.loader.df_metadata` for more explanations expand_metadata(self.df0, [k for k in df_metadata if hasattr(self.df0, k)]) N = len(Tgas) cast_factory = [self]*N # note that this is the copy of a same object! Nprocs = min(self.misc.Nprocs, N) if self.verbose: print( ('Calculate {0} spectra on {1} procs'.format(len(Tgas), Nprocs))) t1 = time() try: with Pool(Nprocs) as p: # Python 3 only spec_list = p.map(_distribute_eq_spectrum, list( zip(cast_factory, Tgas, mole_fraction, path_length))) except AttributeError: if sys.version_info[0] == 2: raise NotImplementedError('parallel is only implemented in Python 3. Time to switch!') else: raise if self.verbose: print(('{0} spectra calculated in {1:.1f}s'.format(N, time()-t1))) return spec_list