How to use the radis.phys.convert.conv2 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 / operations.py View on Github external
Notes   
    -----
    
    Use only for rough work. If you want to work properly with spectrum 
    objects, see :py:meth:`~radis.los.slabs.MergeSlabs`.
    '''
    # Check input
    var = _get_unique_var(s, var, inplace)

    # Convert to Spectrum unit
    if unit is not None:
        Iunit = s.units[var]
        if unit != Iunit:
            from radis.phys.convert import conv2
            cst = conv2(cst, unit, Iunit)

    if not inplace:
        s = s.copy(quantity=var)
    
    # Add inplace       ( @dev: we have copied already if needed )
    w, I = s.get(var, wunit=s.get_waveunit(), copy=False)  
    I += cst
    # @dev: updates the Spectrum directly because of copy=False
    
#    s.name = '{0}+{1}'.format(s.get_name(), cst)

    return s
github radis / radis / radis / spectrum / operations.py View on Github external
Add Gaussian noise to your Spectrum (assuming there is only one spectral
    quantity defined)::
        
        s += np.random.normal(0,1,len(s.get_wavelength()))

    '''
    # Check input
    var = _get_unique_var(s, var, inplace)

    # Convert to Spectrum unit
    if unit is not None:
        Iunit = s.units[var]
        if unit != Iunit:
            from radis.phys.convert import conv2
            a = conv2(a, unit, Iunit)

    if not inplace:
        s = s.copy(quantity=var)
    
    # Add inplace       ( @dev: we have copied already if needed )
    w, I = s.get(var, wunit=s.get_waveunit(), copy=False)  
    I += a
    # @dev: updates the Spectrum directly because of copy=False

    return s
github radis / radis / radis / spectrum / operations.py View on Github external
See Also
    --------
    
    :py:func:`~radis.spectrum.operations.get_baseline`
    '''
    import numpy as np
    # Check input
    var = _get_unique_var(s, var, inplace)
        
    # Convert to Spectrum unit
    if unit is not None:
        Iunit = s.units[var]
        if unit != Iunit:
            from radis.phys.convert import conv2
            left = conv2(left, unit, Iunit)
            right = conv2(right, unit, Iunit)

    if not inplace:
        s = s.copy(quantity=var)
       
    # @EP: 

    # Substract inplace       ( @dev: we have copied already if needed )
    w, I = s.get(var, wunit=s.get_waveunit(), copy=False)  
    I -= np.linspace(left, right, num=np.size(I))
    # @dev: updates the Spectrum directly because of copy=False

    return s
github radis / radis / radis / spectrum / operations.py View on Github external
See Also
    --------
    
    :py:func:`~radis.spectrum.operations.get_baseline`
    '''
    import numpy as np
    # Check input
    var = _get_unique_var(s, var, inplace)
        
    # Convert to Spectrum unit
    if unit is not None:
        Iunit = s.units[var]
        if unit != Iunit:
            from radis.phys.convert import conv2
            left = conv2(left, unit, Iunit)
            right = conv2(right, unit, Iunit)

    if not inplace:
        s = s.copy(quantity=var)
       
    # @EP: 

    # Substract inplace       ( @dev: we have copied already if needed )
    w, I = s.get(var, wunit=s.get_waveunit(), copy=False)  
    I -= np.linspace(left, right, num=np.size(I))
    # @dev: updates the Spectrum directly because of copy=False

    return s
github radis / radis / radis / spectrum / spectrum.py View on Github external
-------
        
        P: float
            radiated power in ``unit`` 
        
        See Also
        --------
        
        :meth:`~radis.spectrum.spectrum.Spectrum.get_integral`
        
        '''

        P = self.get_integral(
            'radiance_noslit', wunit='nm', Iunit='mW/cm2/sr/nm')
        # P is in mW/cm2/sr/nm * nm
        return conv2(P, 'mW/cm2/sr', unit)
github radis / radis / radis / lbl / factory.py View on Github external
# ----------------------------------------------------------------------

            # Sum over all emission integrals (in the valid range)
            b = (self.df1.wav > self.input.wavenum_min) & (
                self.df1.wav < self.input.wavenum_max)
            P = self.df1['Ei'][b].sum()          # Ei  >> (mW/sr)

            # incorporate density of molecules (see equation (A.16) )
            density = mole_fraction*((pressure_mbar*100)/(k_b*Tgas))*1e-6
            Pv = P * density                     # (mW/sr/cm3)

            # Optically thin case (no self absorption):
            Ptot = Pv*path_length    # (mW/sr/cm2)

            return conv2(Ptot, 'mW/cm2/sr', unit)

        except:
            # An error occured: clean before crashing
            self._clean_temp_file()
            raise
github radis / radis / radis / spectrum / spectrum.py View on Github external
I = convert_universal(I, Iunit0, Iunit, self,
                                      per_nm_is_like='mW/sr/cm2/nm',
                                      per_cm_is_like='mW/sr/cm2/cm_1')
            elif var in ['emisscoeff']:
                # idem for emisscoeff in (~ W/sr/cm3/nm) or (~ /sr/cm3/cm_1)
                I = convert_universal(I, Iunit0, Iunit, self,
                                      per_nm_is_like='mW/sr/cm3/nm',
                                      per_cm_is_like='mW/sr/cm3/cm_1')
            elif var in ['absorbance']:  # no unit
                assert Iunit in ['', '-ln(I/I0)']
                # dont change the variable: I has no dimension
            elif var in ['transmittance']:  # no unit
                assert Iunit in ['', 'I/I0']
                # dont change the variable: I has no dimension
            else:
                I = conv2(I, Iunit0, Iunit)
        else:
            pass

        return w, I