Friday, February 7, 2014

Zipit Z2 Information

SAVED FOR POSTERITY
Based on debian sid.
2 users set up by default. root password root. user password user.
The system auto logs in as user at boot and starts the desktop environment.
The keymapping is standard to the other zipit userlands.
The smily face = esc
The zipit key = tab
Alt = alt
… = ctrl
D-pad = arrow keys
Options key turns on and off the mouse (d-pad)
Mouse buttons are: center of d-pad = right click, stop button = left click

Commonly asked “where are these keys?”
alt+next = ~
ctrl+backspace = | (NOTE: on my version this is ALT+Smiley)
alt+. = }
alt+, = {
shift+. = >
shift+, = <
ctrl+shift+j = (
ctrl+shift+k = )
alt+prev = scroll up (in irssi)
alt+next = scroll down (in irssi)
shift+prev = scroll up (in terminal)
shift+next = scroll down (in terminal)

Keybindings for desktop shortcuts:
ctrl+m = menu
ctrl+t = terminal
ctrl+r = run prompt
ctrl+l = close window
ctrl+n = next window
ctrl+p = previous window
ctrl+q = backlights off
ctrl+w = backlights on

To adjust lcd and keyboard backlights manually, run as root:
lcd max high med low off
keys max high med low off

Monday, December 9, 2013

DSP snippets

PEAK DETECTION
John on comp.dsp writes (https://groups.google.com/forum/#!topic/comp.dsp/MqSJjoaq8Hg)
It is entirely inappropriate for some problems, but one peak-picker that I use sometimes is a three segment sliding window:

LLLLLLLLLLCCCCCRRRRRRRRRR

When the maximum of window C is in the middle of C, and that maximum exceeds max(f(L),f(R)), then a peak at the middle of C is declared. The function f can be mean(L) or max(L) or something else. The window lengths are tuned to your requirements

Lito on comp.dsp writes
For a series with well behaved peaks the following
has worked for me.  What it lacks in efficiency it
it makes up for with reliability.

function peaks(x,region,thresh)
  value,index = max(x)
  while value > thresh
    add value, index to list
    zero out region about index
    value,index = max(x)
  endwhile
return list 

Monday, October 28, 2013

Git snippets

REMOVE LARGE FILES (all .pkl files in this case)
git filter-branch --index-filter 'git rm --cached --ignore-unmatch *.pkl' --tag-name-filter cat -- --all

ARTICLE ON GIT SUBMODULES
http://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and-updating/

Basically, git submodule add https://kastnerkyle@github.com/kastnerkyle/RNNLIB RNNLIB

Saturday, September 21, 2013

Adjusting Low Volume in Linux

QUIET RIOT
First, try running
alsamixer
from the command line. If there is still some headroom on any of the sliders, bump them to 100%. Sometimes there are weird interactions between the different volume sliders, and making them all 100% could increase you output volume.

IT AIN'T ENOUGH
For even more volume, we can head to the commandline.
pacmd list-sinks
will list all possible sinks for volume increases on your system. To bump my volume to approximately 200% (100% is 65536), I used:

pacmd set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo 125000

This will increase noise to some extent (looking into some good ways to filter it), but at least those quiet sounds can now be heard!
http://askubuntu.com/questions/219739/adjust-max-possible-volume-in-pulseaudio

Wednesday, July 17, 2013

Python code snippets

EXCELLENT COVERAGE OF MATPLOTLIB
http://nbviewer.ipython.org/urls/raw.github.com/jrjohansson/scientific-python-lectures/master/Lecture-4-Matplotlib.ipynb

ZIP A LIST INTO SUBGROUPS
izip(*[iter(l)]*size)
zip(*[imap(func)]*size)
 
http://stackoverflow.com/questions/4628290/pairs-from-single-list

BETTER EXAMPLE CONTROLLING SSH WITH PEXPECT AND PXSSH 
#!/usr/bin/env python
import pxssh
def getLine(password="password", hostname="host"):
        try:
                s = pxssh.pxssh()
                username = "root"
                s.login (hostname, username, password)
                s.sendline ("echo 'Hello World'")  # run a command
                s.prompt()             # match the prompt
                line = s.before
                s.logout()
                return line
        except pxssh.ExceptionPxssh, e:
                print "pxssh failed on login."
                print str(e)

print getLine()


EXAMPLE OF CONTROLLING SSH IN PURE PYTHON WITH CORE LIBS
#!/usr/bin/env python
import pty
import os
import sys
import time
pid,fd = pty.fork()
if pid==0:
    os.execv("/usr/bin/ssh",["/usr/bin/ssh","root@host","echo 'Hello World!' | awk '{print $2}'"])
else:
    password = 'password\n'
print "Child says",os.read(fd,1024).strip()
print "Child took",os.write(fd,password)
time.sleep(1)
print "Child says",os.read(fd,1024).strip()
#SSH uses pty instead of stdin to communicate
#http://www.gossamer-threads.com/lists/python/python/56425

Thursday, May 30, 2013

Statistics Tidbits

Choosing a statistical test
http://imgur.com/Ctug4Dr

Aikake Information Criterion 
Maximum Likelihood
$AIC = -2*logL(\theta|y) + 2k$
$k = $ total number of parameters

Least Squares
$AIC = n*log(\frac{RSS}{n}) + 2k$
$RSS = SSE = \sum(y - h(x))^2$
$ n = $ number of samples
http://www4.ncsu.edu/~shu3/Presentation/AIC.pdf
http://en.wikipedia.org/wiki/Residual_sum_of_squares


Matrix Form Pointwise Distances
$d_ij = ||x_i - y_j||^2 = ||x_i||^2 + ||y_j||^2 - 2<X_i,y_j>$
means that
$D = X + Y - 2X'Y$
Take the norm of X and Y i.e. X*X' or dot(X,X')

Normalize and calculate covariance
A * A.T (Hermitian!) / sqrt(diag(A.T * A) * diag(A.T * A).T)
http://statinfer.wordpress.com/2011/11/14/efficient-matlab-i-pairwise-distances/

Rolling stats
http://stackoverflow.com/questions/1058813/on-line-iterator-algorithms-for-estimating-statistical-median-mode-skewnes


Current Links for Stats in Python
http://r.789695.n4.nabble.com/Ornstein-Uhlenbeck-td2991060.html

http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/

http://blog.yhathq.com/posts/estimating-user-lifetimes-with-pymc.html

http://robjhyndman.com/hyndsight/crossvalidation/




Tuesday, April 2, 2013

Installing the Redhawk SDR framework

WHAT IS IT?
Redhawk SDR is a new SDR framework, in the vein of GNU Radio Companion and the OSSIE framework, for quickly developing and deploying signal processing algorithms. This U.S. Gov't backed software has extensive support for creating radio flows for a single computer or distributing your SDR processing chain across networked hardware, and has been used in many commercial applications. It will also be incorporating the existing work done under the banner of GNU Radio Companion and OSSIE. See more at www.redhawksdr.org

FLY ON YOUR WINGS (LIKE AN EAGLE)
The first step (or at least the easiest way to get going) is to install CentOS 6.{1-3} x86_64. Redhawk comes in rpm packages, so I am sure other flavors of RedHat Linux could work, but I personally used CentOS 6.3 x86_64 for this tutorial. Of course, some of the difficulties I experienced may be alleviated by a better repository package set like Fedora has.

To install the redhawk software, take the code from the GitHub link below and paste into a bash script, then set executable permissions with chmod +x <scriptname>. I have the latest copy of this posted on my GitHub for Redhawk utilities.

Once this script completes, you should see a folder called redhawkIDE in your home directory. Enter this folder, then type ./eclipse. This should launch the Redhawk IDE, which allows you to create components and blocks to do SDR task.

ODD FUTURE
I am planning to include support for 32bit and 5.x installs of CentOS in the get_redhawk.sh script at some point, but for now only CentOS 6.x 64bit is supported.

Redhawk has begun to integrate GNU Radio components into the framework, which will hopefully bring rtl-sdr support. This should support the E4000 and R820T digitizers, so that we can quickly begin to use the Redhawk SDR environment for some real projects. For now, the only way I can see to get rtl-sdr working with Redhawk is through a nasty hack - make a FIFO and write data from rtl-sdr to that... I will be posting on this in the near future.