Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radon Short Time Average is not a real moving average over last 24hr #17

Open
mariusg0000 opened this issue Jun 18, 2023 · 3 comments
Open

Comments

@mariusg0000
Copy link

mariusg0000 commented Jun 18, 2023

Hello,

I use a pseudo-inversing algo from numpy in order to obtain original values from a moving average series. When i use this script on movig average from randomly generated number, everyting is ok, i can obtain original values with a small error but when I use the same script on STA values from last 7 days, the result not as expected, many negative values, high volatility which makes me think that STA in not a real moving (rolling) average, but something else. Can you provide the algorithm used for obtaining STA values or can you provide the raw, instant radon values over the last hour ?

Here is the python script I use:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.ndimage import shift
import random

def reconstruct_orig(sm_x:np.ndarray, win_size:int=7):

    arr_size = sm_x.shape[0]+win_size
    # get A and its inverse     
    A = (np.tril(np.ones((arr_size,arr_size)),-1) - np.tril(np.ones((arr_size,arr_size)),-(win_size+1)))/win_size
    A = A[win_size:,:]
    pA = np.linalg.pinv(A) #pseudo inverse
    return np.dot(pA, sm_x)

if __name__=="__main__":

    data = np.loadtxt("sta.csv", delimiter=",",dtype='float')
    orig = pd.DataFrame(data)
    
    re_x = reconstruct_orig(orig, win_size=24)
    
    data = np.concatenate([np.zeros((23)), data]) # right shift 24 values  

    plt.plot(data,label='original x')
    plt.plot(re_x, label='reconstructed x')
    plt.legend()
    plt.show()

REVERSE_RND
reverse_sta

@tonbut
Copy link

tonbut commented Sep 18, 2024

@mariusg0000 Nice analysis! I had suspected the data wasn't a moving average either and it would certainly nice to get a realtime output and do my own averaging as required. It's shame as i'd like to get faster feedback than whatever it is doing now.

@mariusg0000
Copy link
Author

Meanwhile, I sold my Airthings Wave and bought a RadonEye RD200, a beautiful device, precise and easy to use. I can read it via Bluetooth with a Python script or even with an ESP32 module. I get a reading every 10 minutes and a one-hour moving average.

@tonbut
Copy link

tonbut commented Sep 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants