How to use the radis.spectrum.spectrum.Spectrum function in radis

To help you get started, we’ve selected a few radis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github radis / radis / radis / spectrum / spectrum.py View on Github external
try:
                # 143 us  (2 ms with deepcopy(lines))
                lines = self.lines.copy(deep=True)
            except AttributeError:
                pass

        try:
            populations = self.populations
        except AttributeError:
            populations = None

        waveunit = self.get_waveunit()    # 163 ns
        name = self.name

        # Generate copied Spectrum
        s = Spectrum(      # 1.51 ms
            quantities=quantities,
            conditions=conditions,
            cond_units=cond_units,
            populations=populations,
            lines=lines,
            units=units,
            waveunit=waveunit,
            name=name,
            warnings=False,   # saves about 3.5 ms on the Performance test object
        )

        # Add extra information

        # ... file name (if exists)
        s.file = self.file
github radis / radis / radis / tools / database.py View on Github external
isotope = int(isotope)
                except ValueError:
                    pass  # keep isotope as it was
                kwargs['populations'][molecule][isotope] = states

    else:
        kwargs['populations'] = None

    # ... load other properties if exist
    for attr in ['units', 'cond_units', 'name']:
        try:
            kwargs[attr] = sload[attr]
        except KeyError:
            kwargs[attr] = None

    s = Spectrum(quantities=quantities,
                 conditions=conditions,
                 waveunit=waveunit,
                 **kwargs)

    # ... add file
    s.file = basename(file)

    # ... add slit
    s._slit = slit

    return s
github radis / radis / radis / phys / blackbody.py View on Github external
# generate the vector of wavenumbers (shape M)
        w = arange(wavenum_min, wavenum_max+wstep, wstep)
        Iunit = 'mW/sr/cm2/cm_1'
        I = planck_wn(w, T, eps=eps, unit=Iunit)
    else:
        # generate the vector of wavenumbers (shape M)
        w = arange(wavelength_min, wavelength_max+wstep, wstep)
        Iunit = 'mW/sr/cm2/nm'
        I = planck(w, T, eps=eps, unit=Iunit)

    conditions = {'wstep': wstep,
                  'medium': medium}
    # add all extra parameters in conditions (ex: path_length)
    conditions.update(**kwargs)

    return Spectrum(quantities={'radiance_noslit': (w, I),
                                'transmittance_noslit': (w, zeros_like(w)),
                                'absorbance': (w, ones_like(w)*inf)},
                    conditions=conditions,
                    units={'radiance_noslit': Iunit,
                           'transmittance_noslit': 'I/I0',
                           'absorbance': '-ln(I/I0)'},
                    cond_units={'wstep': waveunit},
                    waveunit=waveunit,
                    name='Planck {0}K, eps={1:.2g}'.format(T, eps))
github radis / radis / radis / lbl / factory.py View on Github external
quantities = {
                'abscoeff': (wavenumber, abscoeff),
                'absorbance': (wavenumber, absorbance),
                # (mW/cm3/sr/nm)
                'emisscoeff': (wavenumber, emisscoeff),
                'transmittance_noslit': (wavenumber, transmittance_noslit),
                # (mW/cm2/sr/nm)
                'radiance_noslit': (wavenumber, radiance_noslit),
            }
            if k_continuum is not None and self._export_continuum:
                quantities.update(
                    {'abscoeff_continuum': (wavenumber, k_continuum*density),
                     'emisscoeff_continuum': (wavenumber, j_continuum*density)})

            # Store results in Spectrum class
            s = Spectrum(
                quantities=quantities,
                conditions=conditions,
                populations=populations,
                lines=lines,
                units=self.units,
                cond_units=self.cond_units,
                waveunit=self.params.waveunit,  # cm-1
                # dont check input (much faster, and Spectrum
                warnings=False,
                # is freshly baken so probably in a good format
                name=name,
            )
            
            # update database if asked so
            if self.autoupdatedatabase:
                self.SpecDatabase.add(
github radis / radis / radis / los / slabs.py View on Github external
added['abscoeff'] = (w_noconv, abscoeff_eq)

        # ... emission coefficient
        if 'emisscoeff' in recompute:
            if __debug__:
                printdbg('... merge: calculating emisscoeff j=sum(j_i)')
            emisscoeff_eq = np.sum([s.get('emisscoeff', wunit=waveunit, Iunit=units0['emisscoeff'])[
                                 1] for s in slabs], axis=0)
            assert len(w_noconv) == len(emisscoeff_eq)
            added['emisscoeff'] = (w_noconv, emisscoeff_eq)
    
        # name
        name = '//'.join([s.get_name() for s in slabs])
        
        # TODO: check units are consistent in all slabs inputs
        s = Spectrum(quantities=added, conditions=conditions,
                        cond_units=cond_units, units=units0,
                        name=name)
        
        # %% Calculate all quantities from emisscoeff and abscoeff
        
        if 'emissivity_noslit' in requested and (
                'thermal_equilibrium' not in s.conditions or s.is_at_equilibrium() != True):
            requested.remove('emissivity_noslit')
            if __debug__:
                printdbg('... merge: all slabs are not proven to be at equilibrium. '+\
                         'Emissivity was not calculated')
                
        # Add the rest of the spectral quantities afterwards:
        s.update([k for k in requested if k not in ['emisscoeff', 'abscoeff']], 
                  optically_thin=optically_thin, verbose=verbose)
github radis / radis / radis / lbl / bands.py View on Github external
# Add band name and hitran band name in conditions
                conditions.update({'band': band})

                if lines:
                    def add_attr(attr):
                        if attr in lines:
                            if band == 'others':
                                val = 'N/A'
                            else:
                                # all have to be the same
                                val = lines[attr].iloc[0]
                            conditions.update({attr: val})
                    add_attr('band_htrn')
                    add_attr('viblvl_l')
                    add_attr('viblvl_u')
                s = Spectrum(
                    quantities={
                        'abscoeff': (wavenumber, abscoeff),
                        'absorbance': (wavenumber, absorbance),
                        'emissivity_noslit': (wavenumber, emissivity_noslit),
                        'transmittance_noslit': (wavenumber, transmittance_noslit),
                        # (mW/cm2/sr/nm)
                        'radiance_noslit': (wavenumber, radiance_noslit),
                    },
                    conditions=conditions,
                    populations=populations,
                    lines=lines,
                    units=self.units,
                    cond_units=self.cond_units,
                    waveunit=self.params.waveunit,  # cm-1
                    name=band,
                    # dont check input (much faster, and Spectrum