nmayorov / allan-variance

Simple allan variance in Python
MIT License
40 stars 19 forks source link

allan_deviation, input_mode are added, int64 is fixed #1

Closed dinya closed 7 years ago

dinya commented 7 years ago
  1. allan_deviation function is added
  2. input_mode parameter for allan_variance for a more flexible interpretation of the input data (as mean and increment)
  3. allan_variance.py:75: RuntimeWarning: overflow encountered in long_scalars: avar[i] = np.mean(c**2, axis=0) / k**2 error is fixed
dinya commented 7 years ago

Docstring fixes are required

dinya commented 7 years ago

By the way.

def params_from_avar(tau, avar):
    """Estimate noise parameters from Allan variance.
...

    Returns
    -------
    params : ndarray, shape (5,)
        Estimated parameters, ordered as quantization, additive white,
        flicker, random walk, linear ramp.
    """
...

    return np.sqrt(x), prediction

Why not to add output_type parameter ('ndarray' or 'dict') and to return something like this:

if output_type == 'ndarray':
    params = np.sqrt(x)
elif output_type == 'dict':
    (quantization, additive_white, flicker, random_walk, linear_ramp) = np.sqrt(x)
    params = dict(quantization=quantization,
                  additive_white=additive_white,
                  flicker=flicker,
                  random_walk=random_walk,
                  linear_ramp=linear_ramp)

return params, prediction

or add another function, which is based on params_from_avar, but returns dict.

Maybe It's not very "scipyonistic", but it's very comfortable to use in the Python code ("pythonistic") :).

dinya commented 7 years ago

@nmayorov, please, check and improve doctrings

nmayorov commented 7 years ago

Could be, but it's minority of the cases. It doesn't really matter to be honest, I just prefer a simpler way.

---- On Thu, 24 Nov 2016 20:46:50 +0500 Denis Sidorov <notifications@github.com> wrote ----

@dinya commented on this pull request.

In allan_variance.py:

> """ + if input_mode.lower() not in ("increment", "mean"): For history. I looked at the scipy code. For example, here:

if connection.lower() not in ['weak', 'strong']: raise ValueError("connection must be 'weak' or 'strong'")

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.