• KlMa

    Here you can find the capture script, and here a script that processes the array and creates a few plots. Any help with Y axis units are appreciated. Make sure you secure the ipad before testing :)

    posted in Pythonista read more
  • KlMa

    Apparently there is a bug in matplotlib 1.4.0 related to sliced arrays. A work around is to flattening the input.

    # coding: utf-8
    import console
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.mlab as ml
    
    # console.clear()
    file_name = 'wc-cent-2.npy'
    data = np.load(file_name)
    
    fig_mag = plt.figure()
    plt.psd(data[:, 0].flatten(), NFFT=256, Fs=80, window=ml.window_hanning, detrend = ml.detrend_none, scale_by_freq = True, noverlap = 0, pad_to = None, sides = 'onesided')
    plt.xlabel('Frequency (Hz)')
    plt.ylabel('Power/Frequency (dB/Hz)')
    plt.title('PSD X')
    plt.show()
    

    posted in Pythonista read more
  • KlMa

    Hi,
    I wanted to see if i could find out the centrifugation speed of my old washing machine using some vibration analysis in Numpy using fft etc. So i wrote a little script that captured accelerometer data at 80Hz for one minute and then placed my ipad on top of the machine during centrifugation. I stored the data in an array in an .npy file. My graphs looked ok, I think, with a dominant peak at about 12Hz(12*60=720rpm...this probably explains why my clothes are so wet coming out from the machine). I tried the same using the the psd function in matplotlib using Python 2.7 and got a similar result, but when i run the code in Python 3.5 I get a very diffrent result. Can somebody explain why? Is it the diffrent versions Python or matplotlib or Pythonista or something else, i dont get it? The .npy file can be found here

    # coding: utf-8
    import console
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.mlab as ml
    
    # console.clear()
    file_name = 'wc-cent-2.npy'
    data = np.load(file_name)
    
    fig_mag = plt.figure()
    plt.psd(data[:, 0], NFFT=256, Fs=80, window=ml.window_hanning, detrend = ml.detrend_none, scale_by_freq = True, noverlap = 0, pad_to = None, sides = 'onesided')
    plt.xlabel('Frequency (Hz)')
    plt.ylabel('Power/Frequency (dB/Hz)')
    plt.title('PSD X')
    plt.show()
    

    posted in Pythonista read more
  • KlMa

    Ok thanks. Is there a way to use the beta or should i wait for the bug fix? Or should i buy Pythonista 3?

    posted in Pythonista read more
  • KlMa

    Hi
    I am using Pythonista 2.1 on a ipad air and having problems with Pythonista crashing. Maybe matplotlib is involved, but its difficult for me to say. If I for example try to add a row after the plt.plot(np.arange... row below and start to write "plt.plo..." and wait a few seconds it crashes. I see the problem in other scripts using matplotlib as well. Any ideas?

    # coding: utf-8
    
    import console
    import motion
    import time
    import numpy as np
    import matplotlib.pyplot as plt
    
    def show(ori_func, ft, sampling_period): 
       n = len(ori_func) 
       interval = sampling_period / n 
       plt.subplot(2, 1, 1) 
       plt.plot(np.arange(0, sampling_period, interval), ori_func, 'black')
       plt.xlabel('Time'), plt.ylabel('Amplitude') 
       plt.subplot(2,1,2) 
       frequency = np.arange(n / 2) / (n * interval) 
       nfft = abs(ft[range(int(n / 2))] / n ) 
       plt.plot(frequency, nfft, 'red') 
       plt.xlabel('Freq (Hz)'), plt.ylabel('Amp. Spectrum') 
       plt.show() 
    

    posted in Pythonista read more
  • KlMa

    Thanks @ywangd , it works now.

    Regards
    Klas

    posted in Pythonista read more
  • KlMa

    A related question. I am trying to login to my Lego Mindstorms brick (with ev3dev firmware) but get the following error:

    [~/Documents]$ ssh.py --password maker robot@192.168.1.17
    Connecting...
    Looking for SSH keys...
    No SSH key found. Trying password...
    No handlers could be found for logger "paramiko.transport"
    Auth Error
    Connection Failed

    I am able to login from my windows pc using putty.

    Regards
    Klas

    posted in Pythonista read more
  • KlMa

    Thanks! It seem to work now.

    Regards
    Klas

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!