• 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

    Thank you @dgelessus, i will try your pointers and report back.

    @Webmaster4o I haven't created anything that fancy. I recently read the “The Art of LEGO MINDSTORMS EV3 Programming (Full Color)” book by Terry Griffin and tried to recreate the PID controlled line follower (chapter 19) in Python instead of in the Mindstorms environment. I have uploaded the programs and a more detailed description in my new github account.

    posted in General Discussion read more
  • KlMa

    I bought a Lego Mindstorms set to my kids (and to myself) this christmas. And i have been playing around with ev3dev environment for i while and I have managed (with the help of you guys) to create some small programs on my ipad, send them to the Lego brick using Stash and scp, execute the program using Stash and ssh. And it works which is cool. The problem i have now is that my file handling is becoming a mess so i decided to try github so now its even worse :) I have some files on the brick, some on my ipad, some on my pc and then of course in the github cloud.

    Could some of you share you share your github/file handling best practice? It would be nice to keep my files in a little bit better sync.

    posted in General Discussion 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
  • KlMa

    Hi
    I am trying to use ssh from stash but receive the following:

    StaSh v0.5.0
    [~/Documents]$ ssh
    pyte module not found.
    StaSh ssh installing pyte...
    Opening: https://codeload.github.com/selectel/pyte/zip/master
    Save as: /private/var/mobile/Containers/Shared/AppGroup/02FA6CEE-1A00-462F-B842-260483ACFCD9/Documents/site-packages/pyte.zip (52161 bytes)
    8192 [15.71%]
    16384 [31.41%]
    24576 [47.12%]
    32768 [62.82%]
    40960 [78.53%]
    49152 [94.23%]
    52161 [100.00%]
    done
    stash: <type 'exceptions.ImportError'>: No module named wcwidth

    Any ideas?
    Regards
    Klas

    posted in Pythonista read more
  • KlMa

    Thanks! And then the next question, is there a "official" Pythonista way how to install new modules? When i search around there seem to be several ways to do it. Pipista, stash and others. Is there a step by step instruction a newbie like me can follow?

    posted in Pythonista read more
  • KlMa

    I am not able to get matplotlib style sheets to work in Pythonista. Any tips?
    http://matplotlib.org/examples/style_sheets/plot_ggplot.html

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!