medhelp sleep graph replacement using python

In other words, graphing time of day versus date in python.

This morning I logged on to medhelp.org only to see that it had gone from somewhat usable for my purposes:

from my previous post, http://www.orangenarwhals.com/?p=129

where I can at least type in the times to some extent, even if there is no batch input (e.g. uploading a text file), to

wtf is this? i am clearly not in their target demographic…

So I decided to get up off my lazy butt and do some python plotting.

This is the end result:

(it’s flipped, so time increases going upward like you would expect a graph to do but opposite of how you would read the medhelp graph, where time increases going downwards, which I feel makes more intuitive sense).

The code is here:
https://github.com/nouyang/sleepgraph/blob/master/graph.py

I keep track of my sleep in a google doc that I just downloaded as a csv file. See the github repo.

===

brain/linkdump as i was working out how to do this

===

http://stackoverflow.com/questions/5498510/creating-graph-with-date-and-time-in-axis-labels-with-matplotlib
http://stackoverflow.com/questions/2369492/generate-a-heatmap-in-matplotlib-using-a-scatter-data-set?rq=1
http://stackoverflow.com/questions/8973846/how-do-i-create-this-kind-of-grid-table-using-matplotlib?rq=1
http://blog.brianhouse.net/post/6877602920/an-activity-heatmap-from-fitbit-data
http://stackoverflow.com/questions/4790265/plot-time-of-day-vs-date-in-matplotlib
vlines

http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.vlines
can set line width but the plot does not adjust to this (how to pad the dates out so the lines won’t ever overlap?)

unix time
http://www.epochconverter.com/

bar plot
http://matplotlib.org/api/pyplot_api.html?highlight=pyplot%20bar#matplotlib.pyplot.bar
http://stackoverflow.com/questions/5902371/matplotlib-bar-chart-with-dates
 now just need to adjust so not height, but also have start time

x = ‘3/18/2013’
datetime.datetime.strptime(str(x),’%m/%d/%Y’)

x = 1365739200
datetime.datetime.fromtimestamp(x)
# datetime.datetime(2013, 4, 12, 0, 0)

http://matplotlib.org/api/pyplot_api.html?highlight=pyplot%20bar#matplotlib.pyplot.bar
http://matplotlib.org/api/axes_api.html?highlight=xaxis_date#matplotlib.axes.Axes.xaxis_date
http://matplotlib.org/api/dates_api.html#matplotlib.dates.DateFormatter
dates.DateFormatter(‘%B %d, %Y’) # January 16, 1970
format: http://linux.die.net/man/3/strptime

http://stackoverflow.com/questions/886716/controling-bars-width-in-matplotlib-with-per-month-data

http://datadebrief.blogspot.com/2010/10/plotting-sunrise-sunset-times-in-python.html
okay, this solves the y-axis problem! excellent.

http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html
In particular,genfromtxt is able to take missing data into account, when other faster and simpler functions like loadtxt cannot

does not deal well with quotation marks in data
“Line #31 (got 8 columns instead of 7)”

24:00 –> 0:00:00 else

ValueError: time data '3/18/2013 24:00:00' does not match format '%m/%d/%Y %H:%M:%S'

also does not like 0 instead of 0:00:00

acrylic bracelets, lasercut cards, red bull contest

acrylic bracelets

I woke up early one day and tested this instructables before class:
http://www.instructables.com/id/Acrylic-bracelets/

I was tempted to skip class and lasercut things, but I did not! (It’s an music theory 101 class, 21M.301, that I’m listening in on and am completely lost in at this point).

The first one I cut was about 8.5” x 2” and I made it in coreldraw. I wanted to put a hexapod in the middle but couldn’t find a png at the time.

Here are the lasercutter settings I used for a epilog 120w lasercutter to cut/engrave 3mm acrylic:
600 dpi, vector
cut: 25 speed 100 power
engrave (the words): 70 speed 30 power

The narwhal refused to cut as a vector so it’s not in the bracelet (I selected bracelet only).

cut it out of transparent acrylic (shown here with the paper covering not peeled off yet)
So actually the pointy tip snapped off when I was bending it. I made a too-tight radius so this actually helped allow the bracelet to be wearable because I can slip my wrist through the crack. The next time around, though, I made sure to start bending at the pointy end first. This step just requires patience, aim the heat gun, wait a minute, and then the acrylic should be super bendy, at which point I can move the gun up the acrylic and press down all the while to get a nice curve. And then having the patient to wait for it to cool while holding it in place.
I also learned to bend it on a clean surface as the hot acrylic picked up all the gunk on the mat.
I was also too hasty in putting this on to check whether it would go on or not and ended up with a small burn. So… be careful. Hopefully this doesn’t scar like the forging-iron-chopsticks one (which is actually pretty faded from two years ago).
I did a second one which was closer to 9” long.
This one retained the corner, but is also bent too tight. It is extremely hard to put on and actually took off skin.

I didn’t know what to put so here is a cheery message:

Ignore the black spraypaint, I was stenciling.

lasercut cards

I finished up my lasercut birthday gift to cathy wu after two weeks -__-;;; with a lasercut card. She likes giraffes so I borrowed an image from the internet (see image below for source link).
Lasercutter settings for construction paper: 600dpi vector, 100 speed 5 power (120w epilog).
materials used:
about that awesome spray-on adhesive, yea fail, I used too much and then placed it incorrectly so had to redo
I ended up using http://www.fontspring.com/fonts/typodermic/rafika which has a free version.
some finishing touches with a razor were required, and I used tape to pick up the stencils which you can see didn’t all come out cleanly:
I think it turned out well. @__@ I hope +Cathy Wu likes it.

red bull competition

I’m probably not entering, but they sent me free LED stuff to play with. I thought their theme was micro or nano or something so I was excited, because I thought they would send me something related to diy nano but I guess not.
Interesting box design (this came inside an actual shipping box):
looks like they contracted out to a company that makes lasercut things, and that this is meant to be wall-hang-able: