How to use the sunpy.util.progressbar.TTYProgressBar function in sunpy

To help you get started, we’ve selected a few sunpy 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 sunpy / ndcube / spectra / spectral_cube.py View on Github external
If True, the gaussian fits will be recalculated, even if there's an
            existing fit for the given wavelengths already in the memo. This
            keyword should be set to True if changing the amplitude or width of
            the fit.
        **kwargs: dict
            Extra keyword arguments are ultimately passed on to the astropy
            fitter.
        """
        recalc = kwargs.pop('recalc', False)
        if line_guess is None:
            key = 'auto'
        else:
            key = tuple([guess[1] for guess in (line_guess,) + extra_lines])
        if recalc or key not in self._memo:
            gaussian_array = np.empty(self.spectra.shape, dtype=object)
            bar = PB(self.spectra.shape[0] * self.spectra.shape[1])
            drawbar = kwargs.pop('progress_bar', False)
            for i in range(self.spectra.shape[0]):
                for j in range(self.spectra.shape[1]):
                    fit = self.spectra[i, j].gaussian_fit(line_guess,
                                                          *extra_lines,
                                                          **kwargs)
                    gaussian_array[i, j] = fit
                    if drawbar:
                        bar.poke()
            self._memo[key] = gaussian_array
            bar.finish()
            return gaussian_array
        else:
            return self._memo[key]