The only blog not featuring an ipod.

How to solve the bounding box problem with matplotlib generated eps files

The situation is the following: you generate an eps file using matplotlib and then import it into a latex document which you compile to pdf. Some viewers have no problems with it, other's refuse to open it (old versions of chrome's viewer on macosx, for example). Furthermore, some  latex compilers will crop / truncate the image when converting it to pdf as an intermediate step.


I have come across this scenario when doing a submission using manuscriptcentral that included some plots generated in matplotlib, which were quite large in size. Smaller plots seem to have no problem. The compiler on the site generated the proof pdf with the large images truncated on the left. Rotating the image in latex didn't solve the problem.

Apparently, the way compilers and viewers handle postscript bounding boxes that have corners with negative coordinates is inconsistent and has been so for over 10 years.  One way to go around it, taken from here, is the following:

suppose the offending file is called  plot.eps

  gs -o testaa.pdf -sDEVICE=pdfwrite -dEPSCrop plot.eps 
  gs -o plot.eps -sDEVICE=epswrite testaa.pdf 

gs is the command for ghostscript, a decades old compiler viewer for postscript and related files. It is available both for debian and windows, at least. 









networkx gephi and graphml: missing node attributes

You are exporting graphml files using networkx, loading them into gephi and not being able to see all the attributes your node has?
read on!

There's one dirty secret of gephi: some attribute-id's of graphml files have reserved status.
The problem is, networkx's write_graphml function produces id's that, sometimes, fall into this category.
Here's the scenario:

You create a graph with networkx and put attributes into the nodes using them as dictionaries.

let G be some networkx graph object with num_nodes nodes and let attMatrix a num_attributes x num_nodes (numpy) matrix that contains some numbers you want to put on the nodes

V=G.nodes();
for v in V:
for i in range (num_attributes):
G.node[v][str(i)] = int(attMatrix[i,v]);

networxx.write_graphml(G, "myGraph.graphml")


It turns out, if num_attributes >=4  then there's going to be one attribute you won't be able to use.. the fourth. If you peak into the graphml you will see that that attribute is assigned  id="d3" which gephi chooses to ignore.

The simplest workaround:   open your graphmlfile and replace all id= with idd= 

The slightly better workaround: open  networkx/readwrite/graphml.py  and change, in line 260  new_id = "d%i" % len(list(self.keys))     to   new_id = "dd%i" % len(list(self.keys))
then reload networkx module and re-export (you might have to re-start python altogether). This makes more sense if you are going to be exporting more graphs.

There is, for sure, a better workaround: modify the  write_graphml function so that it accepts this "d" or "dd" as a parameter. But that should be done by the networkx people, I guess.


Bias at its best


The set of numbers within [0,1] that are not normal has Lebesgue measure 0. Thus, if one picks a number in the unit interval at random, it is almost sure that it is normal. However, the set of known normal numbers (for which we know the decimal expansion, i.e. excluding those with an uncomputable one) is rather small. So, if mathematics is to be regarded as a sampling process, it is an extremely biased one.


Installing ctrax on Ubuntu 11.04 Natty OR Debian jessie / wheezy [Updated 2014.07.14]

Ctrax is a video tracking software developed specifically to track trajectories of fruit flies.

Currently (Jan 2012), there are packages available for Ubuntu 10.04. If you want to install it in 11.04 you can't use those packages, you will get an error. My solution is the following.

NOTES:
This solution also works "as is" on debian whezzy, using ctrax version 0.5.0-1_amd64.deb (July 2014).
If you are running debian jessie, you might run into a couple of problems, whose workarounds are marked in bold below.

1. First some prerequisites and one package you Can install:
sudo apt-get install equivs python-setuptools python-dev python-matplotlib python-scipy python-wxgtk2.8 libavbin0

     Note: If you are trying this in debian Jessie, libavbin0 is not available for this version of the distro. You have to1. set up the sid repositories on your apt sources and run apt-get update2  install ONLY libavbin0, (apt-get install libavbin0)3. remove the sid repositories from your apt sources4. install the rest of the packages with sudo apt-get install equivs python-setuptools python-dev python-matplotlib python-scipy python-wxgtk2.8 


2. Get the latest version of ctrax from here. I tried this on 0.3.0-1_amd64 and 0.3.2-1_amd64.deb and 0.5.0-1_amd64.deb
Place it in a certain folder, say ~/ctraxinst and

cd ~/ctraxinst

3. Now, since this package depends on some python packages which are not available (or not in the correct version) for 11.04, it is necesary to install them by hand:

sudo easy_install motmot.wxvideo
sudo easy_install motmot.wxglvideo
sudo easy_install motmot.wxvalidatedtext
sudo easy_install motmot.imops
sudo easy_install pygarrayimage
sudo easy_install pyglet

4. This installs the python packages, the problem is that since they were not installed using the packaging manager, when we try to install ctrax it will report unmet dependecies. Here comes the dirty part, we will make some dummy packages and trick the packaging system into thinking this python modules are installed, well, not tricking because they actually are, lets call it, informing it of their installation.

mkdir fakes
cd fakes
equivs-control python-motmot-wxvideo
equivs-control python-motmot-wxvalidatedtext
equivs-control python-motmot-wxglvideo
equivs-control python-motmot-imops
equivs-control python-pygarrayimage
equivs-control python-pyglet

This will create six files named as the packages, in side each of them is the information on the respective fake package, we just need to edit one line in each of them. For example

nano python-motmot-imops

and make sure the 8th line says:

Package: python-motmot-imops

(this means you have to replace the defaults with line

Now you can actually build the packages



equivs-build python-motmot-wxvideo

equivs-build python-motmot-wxvalidatedtext
equivs-build python-motmot-wxglvideo
equivs-build python-motmot-imops
equivs-build python-pygarrayimage
equivs-build python-pyglet


this makes six .deb files which can be installed

sudo dpkg -i python-motmot-wxvideo_1.0_all.deb
sudo dpkg -i python-motmot-wxglvideo_1.0_all.deb
sudo dpkg -i python-motmot-wxvalidatedtext_1.0_all.deb
sudo dpkg -i python-motmot-imops_1.0_all.deb
sudo dpkg -i python-pygarrayimage_1.0_all.deb
sudo dpkg -i python-pyglet_1.0_all.deb


5. And now you can install the ctrax file you downloaded

sudo dpkg -i ../python-ctrax_0.5.0-1_amd64.deb


That should do the trick :)

NOTE:  In Debian jessie you might get an error, when running Ctrax, about matplotlib not finding one of its libraries. 
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/tkagg.py", line 2, in
    from matplotlib.backends import _tkagg
ImportError: cannot import name _tkagg

I don't fully understand what the backends of matplotlib are, but one workaround for this is to use another backend. This can be done by editing matplotlib's config 
  sudo nano /etc/matplotlibrc
and changing the line backend      : TkAgg so that it reads:
   backend      : QT4Agg


This should do the trick.

50 años.

De vivir en el futuro.

Xeon 5620 lm-sensors, problems with coretemp

I post this here because of lack of a better place to get it visible to search engines.

If you are trying to get lm-sensors to work on Debian with a E5620 Xeon or two, you will probably get an error about no sensors found (even after going trough sensors-detect). If you try to manually load the modules required, you will see that an error pops up when trying to load the coretemp module. Something about "devide not found".

The solution is simple, you must install kernel 2.6.37-2-amd64. This cannot be done if you are running either stable or testing. You must use the unstable repositories (http://jaqque.sbih.org/kplug/apt-pinning.html for a how-to) and from there install with apt-get install -t unstable linux-image-2.6-37-2-amd64

This new kernel has a new version of the coretemp module which is capable of dealing with these (not-so-)new intel models.

This might also be necessary for the newer high-end i7 as well as other 5600 series Xeon cpus.

Regards.

Life, it seems, is not with out a sense or irony.

Las indentaciones son importantes

La noche de ayer fue una buena noche:
__Soñe que entraba a una celda acompañado de dos personas, que se veian amables.
__Despues de un rato me daba cuenta de que se trataba de Mahmoud Ahmadinejad y Rosa Otunbajewa.
__Me ponia a contarles la siguiente historia, que pacientemente escuchaban mientras comiamos los tres galletas de avena.
____Soñe que entraba a una celda acompañado de dos personas, que se veian amables.
____Despues de un rato me daba cuenta de que se trataba de Mahmoud Ahmadinejad y Rosa Otunbajewa.
____Me ponia a contarles la siguiente historia, que pacientemente escuchaban
________Jocabed y Laura, dos amigas, eran presidenta y vicepresidenta de México, respectivamente.
________Había un atentado en su contra y a mi me acusaban de conspirador

Me llamaba la atención que Ahmadinejad fuera tan buena persona y tratara tan respetuosamente a Otunbajewa. En general, se veia un buen tipo, con su chaqueta sport y su barba, comiendo una gran galleta de avena.

Nuclear Dream

En la facultad de ciencias de la UNAM hay esta escultura de Prometeo que, supuestamente, los estudiantes movieron de la vieja localización a la actual a mano. De cualquier fora, está en un lugar donde la gente se reune y seguro ha visto muchas cosas. Recuerdo por ejemplo haber visto a una chica quitarse el bra por abajo de la blusa, una competencia por ver quien factorizaba más rápido en primos unos números (auxiliados de unas calculadoras de bolsillo), simultaneas de ajedrez, obras de teatro, discuros políticos y lecturas del origen de las especies, desde un banquito, en una combinación entre misa y discurso de caja de jabón, todo a los ojos de Prometeo. Algunas de estas cosas estaba recordando feliz hace unos días.

También hace unos días estaba leyendo la descripción que hace Feynman de la primera explosión nuclear hecha por el hombre, que observó a veinte millas de distancia. Gracias a un muy buen amigo, tengo un pedazo de arena cristalizada por esa misma explosión, el cual, hace unos días también, le mostré a una visita.

Soñe anoche que había gran alboroto alrededor de la fuente del Prometeo, la gente salia de los edificios y se paraba ahí, al atardecer, pero volteando más bien al sureste.

La luz de la explosión llenaba de blanco todo el campo visual por unos segundos, como si le hubieran puesto a uno una hoja blanca frente a los ojos, y despues una nube cambiando rápidamente de forma, morada sobre ese cielo azul obscuro, y poco despues un golpe de aire que levantaba el polvo y hacia que algunos nos arrojaramos al suelo.

El fuego de los dioses... en manos de los hombres.

Fashion Revolutionaries

Este país se está yendo a la chingada, es un hecho reconocido casi por todos.

En este contexto, soñé que unos estudiantes se estaban organizando para poner fin a ello. Habían convocado a una gran reunión en un auditorio, y yo decidía darme una vuelta. En el estacionamiento de dicho auditorio, estaban algunos estudiantes preparando explosivos pequeños, y enseñando a usarlos.

El auditorio estaba lleno de estudiantes fresitas, con sus ropas adidas y sus tenis pumas, y al frente estaba un profesor de mi facultad, muy querido entre esa gente. Estaban hablando de la revolución, de como había que cambiar las cosas, en su característico tono fresa y con sus característicos argumentos ingenuos.

Yo decía para mi "esto es una farsa, están jugando a ser los revolucionarios". Para comprobarme a mi mismo mi teoría, me paraba sobre mi silla, levantaba el brazo y gritaba:

First we take Manhattan

Y una buena parte del auditorio respondía

Then we take Berlin.

Con lo que, según yo, probaba mi punto.

If you tought masturbation was sad compared to sex

I think strip conway's game of life would be a new interesting sexual practice, mostly because it is considered a zero player game.

WW

Some days ago this friend told me "I found out that my way of loving is making sacrifice for the other person, but that I don't really mean to be altruistic"

My first answer was

"What would Dawkins say?"

Today I discovered (Yes, it's not a good idea to browse DSM-V just to pass time) that I have separation anxiery disorder.

Mi first reaction was:

"What would Freud say?"

And I quickly found the answer:

"Bullshit"

overeagerness

Overeagerness...

I can't think of more stupid a concept as that one.

Qué, a nivel subatómico, da lugar a la fuerza normal?

El principio de exclusión.

WTF!

Insensatez

En un extraño juego de la evolución
social
hemos adquirido, como el armadillo, una coraza
y como el pavorreal, bellos colores.

Y cómo muestra irónica de la coevolución
de dos distintos genes
solo los que saben apreciar esos colores vivos
sobre esa placa hostil
logran coger.

Esa coraza hermosa,
armadura reactiva,
tiene grietas, hondas y delgadas
por las que se nos cuelan los amores

Nosotros las parchamos, prestos
porque no vaya ser que alguien nos vea
no nos quiera coger, y se enamore.

Definición

Cuando se está triste nada sale bien, no se disfruta ni el porno.

Talvez esa sea la definición de estar triste.

art out of art




Live Forever: Elizabeth Peyton / New Museum, New York
(Gracias a Aide por pasármelo)

Fuck! Can this be bloody possible?

In the beginning, God created the heavens and earth. No plant or shrub had yet sprung up, for Yahweh God had not sent rain upon the earth, and there was no one to till the soil. Moisture would well up from the earth and water the surface of the ground
Yahweh God formed man from the soil of the ground
And breathed into his nostrils the breath of life.



En el espiritú de las preguntas talmúdicas, e inspirado por una analogía de Toño hace poco más de un año, me permito poner lo siguiente a consideración, otra vez:

Supongan que tienen a su disposición el número que ustedes deseen de piezas de LEGO (a.k.a. tentes) con la propiedad especial de poder unirse a otras piezas por cualquiera de sus caras (no como en los LEGOs tradicionales, que solo lo pueden hacer por dos de ellas).

Supongan que además tienen la propiedad de que la unión entre dos piezas se deshace instantáneamente después de un cierto tiempo de estar unidas, dónde este tiempo es proporcional al número de puntos (muescas, protuberancias, como quieran llamarle a los puntitos de los LEGOs) por los que están unidas. Una vez deshecha una unión las piezas se rigen por la fuerza de gravedad.

Elijan un organismo vivo cualquiera.

Sin restricciones de tiempo ni espacio (pero siempre finitos) ¿Es posible reproducirlo a cabalidad, en estructura y procesos, usando las piezas de LEGO con esta propiedad de que las uniones se deshacen en en tiempo?

*Nota, pueden suponer que las piezas son tan pequeñas como quieran, sin que esto merme su capacidad de armar las configuraciones que deseen. Ingnoremos las fuerzas nucleares debiles y fuertes, aunque no creo que las piezas tuvieran que ser tan pequeñas como para que éstas fueran importantes.

*Una persona ha venido con el siguiente comentario:
Una cuestion interesante es la posibilidad de crear gradientes de concentración y la subsecuente fuerza de difusión, que juegan un papel importante en la vida. ¿Cómo podría lograrse esto?

...to wake to the sound of drums




Alguien me habló todos los días de mi vida al oido, despacio, lentamente. Me dijo: ¡vive, vive, vive! Era la muerte. (JS)