How to use the radis.misc.basics.is_float 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 / lbl / broadening.py View on Github external
# Deal with all lines directly (usually faster)
                line_profile = self._calc_lineshape(df)       # usually the bottleneck
                (wavenumber, abscoeff) = self._apply_lineshape(df.S.values, line_profile, 
                                                               df.shiftwav.values)
            
            elif chunksize == 'DLM':
                # Use DLM
                              
                line_profile_DLM, wL, wG, wL_dat, wG_dat = self._calc_lineshape_DLM(df)
                (wavenumber, abscoeff) = self._apply_lineshape_DLM(df.S.values, 
                                                                   line_profile_DLM, 
                                                                   df.shiftwav.values, 
                                                                   wL, wG, 
                                                                   wL_dat, wG_dat)
            
            elif is_float(chunksize):
                # Cut lines in smaller bits for better memory handling
                N = int(len(df)*len(wavenumber)/chunksize)+1
                # Too big may be faster but overload memory.
                # See Performance for more information
        
                abscoeff = zeros_like(self.wavenumber)
     
                pb = ProgressBar(N, active=self.verbose)
                for i, (_, dg) in enumerate(df.groupby(arange(len(df)) % N)):
                    line_profile = self._calc_lineshape(dg)
                    (wavenumber, absorption) = self._apply_lineshape(dg.S.values, 
                                                                     line_profile, 
                                                                     dg.shiftwav.values)
                    abscoeff += absorption
                    pb.update(i)
                pb.done()
github radis / radis / radis / lbl / bands.py View on Github external
try:

            # check inputs, update defaults
            if path_length is not None:
                self.input.path_length = path_length
            if mole_fraction is not None:
                self.input.mole_fraction = mole_fraction
            if pressure is not None:
                self.input.pressure_mbar = pressure*1e3
            if not (is_float(Tvib) or isinstance(Tvib, tuple)):
                raise TypeError('Tvib should be float, or tuple (got {0})'.format(type(Tvib)) +
                                'For parallel processing use ParallelFactory with a ' +
                                'list of float or a list of tuple')
            singleTvibmode = is_float(Tvib)
            if not is_float(Trot):
                raise ValueError(
                    'Trot should be float. Use ParallelFactory for multiple cases')
            assert type(levels) in [str, list, int]
            if type(levels) == str:
                assert levels == 'all'
            else:
                if len(levels) != len(set(levels)):
                    raise ValueError('levels list has duplicates')
            if not vib_distribution in ['boltzmann']:
                raise ValueError(
                    'calculate per band not meaningful if not Boltzmann')
            # Temporary:
            if type(levels) == int:
                raise NotImplementedError
            if return_lines is not None:
                warn(DeprecationWarning(
github radis / radis / radis / misc / cache_files.py View on Github external
def _h5_compatible(a_dict):
    ''' Make dictionary ``a_dict`` h5 compatible '''
    out = {}
    for k, v in a_dict.items():
        if v is None:
            continue   # dont store None
        elif is_float(v):
            out[k] = v
        else:
            out[k] = str(v)   # convert to str
    return out
github radis / radis / radis / lbl / factory.py View on Github external
# %% Preprocessing
            # --------------------------------------------------------------------

            # check inputs, update defaults
            if path_length is not None:
                self.input.path_length = path_length
            if mole_fraction is not None:
                self.input.mole_fraction = mole_fraction
            if pressure is not None:
                self.input.pressure_mbar = pressure*1e3
            if not (is_float(Tvib) or isinstance(Tvib, tuple)):
                raise TypeError('Tvib should be float, or tuple (got {0})'.format(type(Tvib)) +
                                'For parallel processing use ParallelFactory with a ' +
                                'list of float or a list of tuple')
            singleTvibmode = is_float(Tvib)
            if not is_float(Trot):
                raise ValueError(
                    'Trot should be float. Use ParallelFactory for multiple cases')
            if overpopulation is None:
                overpopulation = {}
            assert vib_distribution in ['boltzmann', 'treanor']
            assert rot_distribution in ['boltzmann']
            self.input.overpopulation = overpopulation
            self.input.rot_distribution = rot_distribution
            self.input.vib_distribution = vib_distribution

            # Get translational temperature
            Tgas = Ttrans
            if Tgas is None:
                Tgas = Trot     # assuming Ttrans = Trot
            self.input.Tgas = Tgas
github radis / radis / radis / tools / line_survey.py View on Github external
def get_label_cdsd(row, details):
        label = ('CO2[iso{iso}] [{branch}{jl:.0f}]({v1l:.0f}{v2l:.0f}`{l2l:.0f}`{v3l:.0f})->({v1u:.0f}{v2u:.0f}`{l2u:.0f}`{v3u:.0f})'.format(
            **dict([(k, row[k]) for k in ['v1u', 'v2u', 'l2u', 'v3u',
                                          'v1l', 'v2l', 'l2l', 'v3l',
                                          'jl', 'iso']]+
                    [('branch',_fix_branch_format[row['branch']])])))

        for k in details:
            name, _, unit = details[k]
            if is_float(row[k]):
                label += '\n{0} {1}: {2:.3g} {3}'.format(k, name, row[k], unit)
            else:
                label += '\n{0} {1}: {2} {3}'.format(name, k, row[k], unit)

        return label
github radis / radis / radis / lbl / factory.py View on Github external
'''

        try:

            # %% Preprocessing
            # --------------------------------------------------------------------

            # check inputs, update defaults
            if path_length is not None:
                self.input.path_length = path_length
            if mole_fraction is not None:
                self.input.mole_fraction = mole_fraction
            if pressure is not None:
                self.input.pressure_mbar = pressure*1e3
            if not (is_float(Tvib) or isinstance(Tvib, tuple)):
                raise TypeError('Tvib should be float, or tuple (got {0})'.format(type(Tvib)) +
                                'For parallel processing use ParallelFactory with a ' +
                                'list of float or a list of tuple')
            singleTvibmode = is_float(Tvib)
            if not is_float(Trot):
                raise ValueError(
                    'Trot should be float. Use ParallelFactory for multiple cases')
            if overpopulation is None:
                overpopulation = {}
            assert vib_distribution in ['boltzmann', 'treanor']
            assert rot_distribution in ['boltzmann']
            self.input.overpopulation = overpopulation
            self.input.rot_distribution = rot_distribution
            self.input.vib_distribution = vib_distribution

            # Get translational temperature
github radis / radis / radis / lbl / bands.py View on Github external
'''

        try:

            # check inputs, update defaults
            if path_length is not None:
                self.input.path_length = path_length
            if mole_fraction is not None:
                self.input.mole_fraction = mole_fraction
            if pressure is not None:
                self.input.pressure_mbar = pressure*1e3
            if not (is_float(Tvib) or isinstance(Tvib, tuple)):
                raise TypeError('Tvib should be float, or tuple (got {0})'.format(type(Tvib)) +
                                'For parallel processing use ParallelFactory with a ' +
                                'list of float or a list of tuple')
            singleTvibmode = is_float(Tvib)
            if not is_float(Trot):
                raise ValueError(
                    'Trot should be float. Use ParallelFactory for multiple cases')
            assert type(levels) in [str, list, int]
            if type(levels) == str:
                assert levels == 'all'
            else:
                if len(levels) != len(set(levels)):
                    raise ValueError('levels list has duplicates')
            if not vib_distribution in ['boltzmann']:
                raise ValueError(
                    'calculate per band not meaningful if not Boltzmann')
            # Temporary:
            if type(levels) == int:
                raise NotImplementedError
            if return_lines is not None:
github radis / radis / radis / lbl / factory.py View on Github external
# %% Preprocessing
            # --------------------------------------------------------------------

            # check inputs, update defaults
            if path_length is not None:
                self.input.path_length = path_length
            if mole_fraction is not None:
                self.input.mole_fraction = mole_fraction
            if pressure is not None:
                self.input.pressure_mbar = pressure*1e3
            if not (is_float(Tvib) or isinstance(Tvib, tuple)):
                raise TypeError('Tvib should be float, or tuple (got {0})'.format(type(Tvib)) +
                                'For parallel processing use ParallelFactory with a ' +
                                'list of float or a list of tuple')
            singleTvibmode = is_float(Tvib)
            if not is_float(Trot):
                raise ValueError(
                    'Trot should be float. Use ParallelFactory for multiple cases')
            if overpopulation is None:
                overpopulation = {}
            assert vib_distribution in ['boltzmann', 'treanor']
            assert rot_distribution in ['boltzmann']
            self.input.overpopulation = overpopulation
            self.input.rot_distribution = rot_distribution
            self.input.vib_distribution = vib_distribution

            # Get translational temperature
            Tgas = Ttrans
            if Tgas is None:
                Tgas = Trot     # assuming Ttrans = Trot
            self.input.Tgas = Tgas
            self.input.Tvib = Tvib
github radis / radis / radis / tools / line_survey.py View on Github external
('branch',_fix_branch_format[row['branch']])])))
        elif molecule in HITRAN_CLASS5:
            label = ('{molec}[iso{iso:.0f}] [{branch}{jl:.0f}]({v1l:.0f}{v2l:.0f}`{l2l:.0f}`{v3l:.0f} {rl:.0f})->({v1u:.0f}{v2u:.0f}`{l2u:.0f}`{v3u:.0f} {ru:.0f})'.format(
                **dict([(k, row[k]) for k in ['v1u', 'v2u', 'l2u', 'v3u',
                                              'v1l', 'v2l', 'l2l', 'v3l',
                                              'rl', 'ru',
                                              'jl', 'iso']]+
                        [('molec',molecule),
                         ('branch',_fix_branch_format[row['branch']])])))
        else:
            raise NotImplementedError('No label for {0}. Please add it!'.format(molecule))

        # Add details about some line properties
        for k in details:
            name, _, unit = details[k]
            if is_float(row[k]):
                label += '\n{0} {1}: {2:.3g} {3}'.format(k, name, row[k], unit)
            else:
                label += '\n{0} {1}: {2} {3}'.format(k, name, row[k], unit)

        return label