How to use the radis.misc.progress_bar.ProgressBar 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 / bands.py View on Github external
a chunck splitting loop in the band groupby loop

        See _calc_lineshape for more information
        '''

        # Reactivate one-time warnings for new run
        reset_warnings(self.warnings)
        # --------------------------

        abscoeff_bands = {}
        emisscoeff_bands = {}

        gb = df.groupby('band')
        chunksize = self.misc.chunksize     # used for DLM keyword in 0.9.20 until proper implementation is done

        pb = ProgressBar(len(gb), active=self.verbose)
        for i, (band, dg) in enumerate(gb):
            if chunksize == 'DLM':
                line_profile_DLM, wL, wG, wL_dat, wG_dat = self._calc_lineshape_DLM(dg)
                (wavenumber, absorption) = self._apply_lineshape_DLM(dg.S.values, 
                                                                   line_profile_DLM, 
                                                                   dg.shiftwav.values, 
                                                                   wL, wG, 
                                                                   wL_dat, wG_dat)
                (_, emission) = self._apply_lineshape_DLM(dg.Ei.values, 
                                                            line_profile_DLM, 
                                                            dg.shiftwav.values, 
                                                            wL, wG, 
                                                            wL_dat, wG_dat)
                
            else:
                line_profile = self._calc_lineshape(dg)
github radis / radis / radis / lbl / broadening.py View on Github external
# the equilibrium case: only the closest matching line is common to the
                # absorption & emission steps. The bottleneck is the distribution
                # of the line over the DLM, which has to be done for both abscoeff & emisscoeff. 
            
            elif is_float(chunksize):
                # Cut lines in smaller bits for better memory handling
                
                # Get size of numpy array for vectorialization
                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)
                emisscoeff = 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)
                    (_, emission) = self._apply_lineshape(dg.Ei.values, 
                                                          line_profile, 
                                                          dg.shiftwav.values)
                    abscoeff += absorption       #
                    emisscoeff += emission
                    pb.update(i)
                pb.done()
                
            else:
                raise ValueError('Unexpected value for chunksize: {0}'.format(chunksize))
github radis / radis / radis / levels / partfunc.py View on Github external
v1max += 1
        while ElecState.Erovib(0, v2max, v2max, 0, J=0, remove_ZPE=True) < Ediss:
            v2max += 1
        while ElecState.Erovib(0, 0, 0, v3max, J=0, remove_ZPE=True) < Ediss:
            v3max += 1
        if vmax is not None:
            v1max = min(vmax, v1max)
            v2max = min(vmax, v2max)
            v3max = min(vmax, v3max)

        # Then fill mixed modes levels

        # %%

        levels = []   # vibrational levels
        pb = ProgressBar(v1max+1, active=True)
        Jmax_calc = 0
        for v1 in range(v1max+1):
            pb.update(v1)
            for v2 in range(v2max+1):
                for l2 in [v2]:
                    # Calculation with HITRAN spectroscopic convention: v2=l2
                    # instead of l2 = [v2::v2+1::2]
                    # It follows than gvib = v2+1
                    # This is added later
                    for v3 in range(v3max+1):
                        # Spectroscopic rule
                        # ------------------
                        # J>=l2: as in the symmetric rotor
                        # ------------------
                        viblvl = vib_lvl_name(v1, v2, l2, v3)
github radis / radis / radis / lbl / bands.py View on Github external
note: there is no more splitting over line chuncks of given different
        (NotImplemented). This may result in large arrays and MemoryErrors for
        extreme spectral ranges. If that ever happens we may have to insert
        a chunck splitting loop in the band groupby loop

        See _calc_lineshape for more information
        '''

        # Reactivate one-time warnings for new run
        reset_warnings(self.warnings)
        # --------------------------

        gb = df.groupby('band')

        abscoeff_bands = {}
        pb=ProgressBar(len(gb), active=self.verbose)
        chunksize = self.misc.chunksize     # used for DLM keyword in 0.9.20 until proper implementation is done
            
        
        for i, (band, dg) in enumerate(gb):
            if chunksize == 'DLM':
                line_profile_DLM, wL, wG, wL_dat, wG_dat = self._calc_lineshape_DLM(dg)
                (wavenumber, absorption) = self._apply_lineshape_DLM(dg.S.values, 
                                                                   line_profile_DLM, 
                                                                   dg.shiftwav.values, 
                                                                   wL, wG, 
                                                                   wL_dat, wG_dat)
            else:
                line_profile = self._calc_lineshape(dg)
                (wavenumber, absorption) = self._apply_lineshape(dg.S.values, 
                                                                 line_profile, 
                                                                 dg.shiftwav.values)
github radis / radis / radis / lbl / bands.py View on Github external
for band in merge_bands:
                    abscoeff = abscoeff_v_bands.pop(band)
                    abscoeff_others += abscoeff
                abscoeff_v_bands['others'] = abscoeff_others
                if verbose:
                    print('{0} bands grouped under `others`'.format(
                        len(merge_bands)))

            # ----------------------------------------------------------------------
            # Generate spectra

            # Progress bar for spectra generation
            Nbands = len(abscoeff_v_bands)
            if self.verbose:
                print('Generating bands ({0})'.format(Nbands))
            pb = ProgressBar(Nbands, active=self.verbose)
            if Nbands < 100:
                pb.set_active(False)  # hide for low line number

            # Generate spectra
            s_bands = {}
            for i, (band, abscoeff_v) in enumerate(abscoeff_v_bands.items()):

                # incorporate density of molecules (see equation (A.16) )
                density = mole_fraction*((pressure_mbar*100)/(k_b*Tgas))*1e-6
                #  :
                # (#/cm3)
                abscoeff = abscoeff_v * density      # cm-1

                # ==============================================================================
                # Warning
                # ---------
github radis / radis / radis / lbl / bands.py View on Github external
abscoeff_others += abscoeff
                    emisscoeff_others += emisscoeff
                abscoeff_v_bands['others'] = abscoeff_others
                emisscoeff_v_bands['others'] = emisscoeff_others
                if verbose:
                    print('{0} bands grouped under `others`'.format(
                        len(merge_bands)))

            # ----------------------------------------------------------------------
            # Generate spectra

            # Progress bar for spectra generation
            Nbands = len(abscoeff_v_bands)
            if self.verbose:
                print('Generating bands ({0})'.format(Nbands))
            pb = ProgressBar(Nbands, active=self.verbose)
            if Nbands < 100:
                pb.set_active(False)  # hide for low line number

            # Create spectra
            s_bands = {}
            for i, band in enumerate(abscoeff_v_bands):
                abscoeff_v = abscoeff_v_bands[band]
                emisscoeff_v = emisscoeff_v_bands[band]

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

                abscoeff = abscoeff_v * density                     # cm-1
                emisscoeff = emisscoeff_v * density                 # m/sr/cm3/cm_1
github radis / radis / radis / lbl / broadening.py View on Github external
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()
                
            else:
                raise ValueError('Unexpected value for chunksize: {0}'.format(chunksize))
                
        except MemoryError:
            import traceback
            traceback.print_exc()
            raise MemoryError('See details above. Try to use or reduce the '+\