nenupytf.other.tools

tools

nenupytf.other.tools.idx_of(array, value, order='low')[source]

Find the index of value in array.

Parameters:
  • array (np.ndarray) – Array upon which to search for indices.
  • value (float) – Value to find the index for.
  • order (str) – Could be ‘low’ or ‘high’. Let’s say array[2] < value < array[3]. If ‘low’, the result will be 2. If ‘high’, the result will be 3.
nenupytf.other.tools.to_unix(time)[source]
nenupytf.other.tools.rebin1d(array, shape)[source]
class nenupytf.other.tools.ProgressBar(valmax=100, barsize=None, title=None, bar=True, up_every=2)[source]

Bases: object

Class to do fancy progressbars
by G. Schworer

https://github.com/ceyzeriat/patiencebar Provides a terminal-friendly single-thread progress bar :param * valmax: the finish value of the progress bar. Default is 100. :type * valmax: float :param * barsize: the size of the bar in the opened terminal. If None, the bar will automatically fit the width of the window. :type * barsize: int >0 :param * title: the title, printed one line above the progress bar :type * title: str :param * bar: whether the bar should be displayed or not. If False, only the text given at each update() will be printed :type * bar: bool :param * up_every: if bar is True, the progress bar will be updated every up_every percent of progress. Setting up_every = 0 updates the progress bar at each update() :type * up_every: int [0-100]

>>> import patiencebar as PB
>>> n_calc = 34
>>> pb = PB.ProgressBar(valmax=n_calc, barsize=50, title="Test bar")
>>> for i in range(n_calc):
>>>     do_stuff()
>>>     pb.update()
bar
barsize
reset(valmax=None, barsize=None, title=None, bar=None, up_every=None)[source]

Resets the progress bar with initialization values, unless new values are given :param * valmax: the finish value of the progress bar. Default is 100. :type * valmax: float :param * barsize: the size of the bar in the opened terminal. If None, the bar will automatically fit the width of the window. :type * barsize: int >0 :param * title: the title, printed one line above the progress bar. :type * title: str :param * bar: whether the bar should be displayed or not. If False, only the text given at each update() will be printed. :type * bar: bool :param * up_every: if bar is True, the progress bar will be updated every up_every percent of progress. Setting up_every = 0 updates the progress bar at each update(). :type * up_every: int [0-100]

>>> n_calc = 34
>>> pb = PB.Patiencebar(valmax=n_calc, barsize=50, title="Test bar")
>>> for i in range(n_calc):
>>>     do_stuff()
>>>     pb.update()
>>> pb.reset(title="Second trial", barsize=70)
>>> for i in range(n_calc):
>>>     do_stuff()
>>>     pb.update()
running
title
up_every
update(step=None)[source]

Updates the progress bar to a newer value :param * step: adds 1 to the progress of the bar, where valmax is the finish value. :type * step: None :param * step: sets the progress of the bar to the step value, where valmax is the finish value. :type * step: float :param * step: displays step on a new line. For this to work, bar must be False (no progress bar displayed) otherwise the update instruction is ignored. :type * step: str

valmax