Work around “iteration over a 0-d array” when reading txt files with Python

I am using Numpy to read some txt files that could be any lines and then iterate them. I realize that I got “iteration over a 0-d array” when the file happens to contain only 1 line. Here is how I work around it — not very clever but it works.

import numpy
f = numpy.genfromtxt('test.file', dtype='str')
if f.size > 1:
   for i in f:
      print "many lines..."
   i = f.datap[:]
   print "only 1 line"

And yeah, I will try to fight with my laziness and populate this blog with bits from my research that could help others. With the help of Google, I benefit a lot from people I don’t know, and now I want to give.


Sky is full of surprises

A Camelopardalid meteor and (one of) its prediction maker. Dr. Albert, the icon of the E.F. Fox Observatory, can be seen in background.

A Camelopardalid meteor and (one of) its prediction maker. Dr. Albert, the icon of the E.F. Fox Observatory, can be seen in background.

Before going to E.F. Fox Observatory for monitoring the Camelopardalids outburst, I felt I would be very happy no matter my co-prediction is right or wrong. However, as always, sky (like life) is full of surprises and rewards and they often come in a way that is beyond our imagination.

Sebastian and I left London at 5 pm EDT. It was overcast at first but soon cleared up. We arrived the E.F. Fox Observatory shortly before 9 pm. John Hlynialuk from the Bluewater Astronomical Society was already there. E.F. Fox Observatory is located in a dark sky preserve in Bruce Peninsula, I estimate the Bortle class to be 3 based on the experience this night. Two Polish observers arrived later and started preparing their multi-station video observations. There were several local amateur astronomers as well.

We went to a nearby small town to grab something to eat and returned to the observatory at about 10:40 pm EDT or 0240Z. I saw two Camelopardalids within one minute as I walked from the parking lot to the observatory — each at 0–1 magnitude with characteristic slow speed and very noticeable train. This raised my hope for a great performance later in the night, as it was still 4 hours from the predicted peak.

In the next 2 hours I was mingling around and saw near half-dozen Camelopardalids in the process — oh, I probably should be smarter and start doing observations right away! I didn’t, because I think that since I need to drive 4 hours in the next morning, I should save my energy for the second half of the night. Sebastian was taking pictures with his DSLR and I think he at least captured 2–3 bright Camelopardalids in the process. At around 12:40 am (0440Z) I saw four Camelopardalids in a little bit more than 1 minute! But again, unfortunately I decided to take a nap right away (!) so that I would be fully prepared for the “show”. Ackkkkk……

So I started standard visual observation at 1:37 am (0537Z). I did this more or less for fun, because I know CMOR and CAMO will be watching anyway. I need a new pair of glasses (I almost cannot tell that Mizar-Alcor is a visual binary!) so my LM isn’t high, only at about 5.5.

I had 50 min. of efficient observation time in the first hour (0537Z-0634Z) and recorded 9 Camelopardalids. No fireballs, but they were all very slow and flew pass the sky very elegantly. From 2:34 am (0634Z) I decided to observe non-stop to nautical twilight (about 4 am). I saw 4 from 2:34 to 2:54 am, with a -1 magnitude bright one with yellowish train that brought us quite a bit of “wow”s (that was the best one of the night). The peak should be around 3 am, so I was anticipating something… but I was wrong. I saw two from 2:54 to 3:10 am, then in the next half an hour I saw none. A +3 Camelopardalid meteor emerged around 3:40 am concluded the whole night.

Why the heck was happening? It seems the peak must be either a few hours early, or is too faint to be seen visually. Based on very preliminary data, I personally inclined to the former. Around 12:30 am I noticed a very strong radiant on CMOR’s real-time activity map (not the one on NASA, that one just got updated once a day), but the strength of the radiant does not seem to elevate much afterwards (implying the radiant has weaken since that map is an accumulative map). The all-sky camera system run by our group (which can only detected meteors up to +0 or so) also picked up as much as four bright Camelopardalids from 0250-0450Z (before 1 am) ranging from -3 to -1 magnitude (absolute), but only one afterwards.

So here is the funny part: personally I was inclining to other researchers’ prediction in terms of peak time, i.e. 0710-0740 UT. However, at least for now, it seems Paul and I’s prediction seems to be closer to what we got. Mother Nature is good at teasing people, isn’t it?

Meanwhile, the very preliminary IMO visual analysis (the visual peak seems to occur at about 0630Z with ZHR~15 as retrieved on May 24 at 6 pm EDT) and RMOB real-time analysis (the peak at 0630Z with ZHR~35 as retrieved on May 24 at 6 pm EDT) also shows an early peak but not as much as my impression with my visual observation and the results from CAMO.

Hmm, it may not a great event in the sense of a meteor storm, but I still find it very fascinating. It seems our predictions must have missed something. There has to be a reason and I want to find it out.

So below is my visual IMO report:

// Header section
night 2014-05-23/24
begin 2014-05-24 0537
end 2014-05-24 0800
observer "Quan-Zhi" "Ye" "YE_QU"
location 81 13 50 W, 44 44 20 N
site "E.S. Fox Observatory" "Canada"
reporter ""

// Shower section
shower CAM 122 +78
shower SPO

// Number section
// Interval RA Dec Teff F Lm CAM SPO
period 0537-0551 315 +45 0.233 1.00 5.64 C 3 - /
period 0554-0613 315 +45 0.316 1.00 5.39 C 5 - /
period 0617-0634 315 +45 0.283 1.00 5.58 C 1 - /
period 0634-0654 315 +45 0.333 1.00 5.06 C 4 - /
period 0654-0710 315 +45 0.266 1.00 5.58 C 2 - /
period 0710-0726 315 +40 0.266 1.00 5.58 C 0 - /
period 0728-0745 315 +40 0.283 1.00 5.58 C 1 - /
period 0747-0800 315 +40 0.216 1.00 5.06 C 0 - /

// Magnitude section
// Show Interval -6 -5 -4 -3 -2 -1 +0 +1 +2 +3 +4 +5 +6 +7 Tot

// Personal comments
Magnitudes and SPOs not recorded.

OK, to conclude: my ZHR prediction seems to be about right, but lots of questions are to be answered. For myself, I also got a gift which I am quite happy about: I thought about take a photo of myself and a Camelopardalid meteor, but I wanted to do observation and didn’t have time to try to wait for one, so I ended up just put the camera on the table and take a photo of myself and the observatory (the photo above). And this morning I realized there is indeed a Camelopardalid meteor on that photo! The very same meteor was also captured by our all-sky camera system allowing orbit to be calculated, so it is definitely a Camelopardalid based on the orbit. Aha 😉 there are always great things coming along in astronomy and as I love to say, go out and take a look or you never know 😉

Acknowledgement: we thank John Hlynialuk for hosting us at the observatory.

Long tail of P/LINEAR and new meteor outburst prediction

P/LINEAR imaged by Xingming Observatory 0.35-m SASP telescope on May 18.69 (UT). Imaging by Quan-Zhi Ye and Xing Gao, reduction by Man-To Hui.

P/LINEAR imaged by Xingming Observatory 0.35-m SASP telescope on May 18.69 (UT). The image is roughly 18’x6′. Imaging by Quan-Zhi Ye and Xing Gao, reduction by Man-To Hui.

Same image above but with different enhancement technique.

Same image above but with different enhancement technique.

Syndyne-synchrone modeling of the Xingming image, courtesy of Man-To Hui (UCLA)

Syndyne-synchrone modeling of the Xingming image, courtesy of Man-To Hui (UCLA)

My old friend Man-To Hui has sent me the processed version of P/LINEAR that I took using Xingming Observatory‘s 0.35-m SASP telescope on May 18 (I was too busy to process the images, and Man-To is a real expert in image processing!). The image you see above is combined from 55 frames with a total exposure time of 83 minutes. Hey, look at that!

Despite the guiding issues (which did not center the comet) we are missing some of the tail, but I can tell the tail is at least 15’ long. Not bad for a tiny comet that is said to be dying. Man-To and I think we are seeing a possible secondary tail just down to the longer, primary tail, but it may just be illusions. Synchrone simulations by Man-To do not support the idea of a secondary tail, but in a few days we are crossing the orbital plane of the comet, which gives us some advantages on detecting the “dust trail” (not tail) of the comet, i.e. the old meteoroid clouds released by the comet long ago. I will be working with the two Gemini telescopes and the Xingming facilities on that purpose. Lots of work over the weekend!

Meanwhile I am excited to see David Asher just posted his prediction of the meteor shower. There are a bit more information in the powerpoint prepared by Robert McNaught, but the website has all the “core” information. According to David, the Earth will take the direct hit by 22-rev (released in 1903) at 7:09 UT and 47-rev (released in 1778) at 7:47 UT. A lot of other trails will have a near miss (rE-rD<0.0001 AU). For the case of 1999-2002 Leonid storms, anything around or below 0.0002 AU or so are very, very interesting (c.f. McNaught & Asher 1999). Unfortunately P/LINEAR is pretty much dead comparing to the parent body of Leonids, 55P/Tempel-Tuttle, but I just realized that P/Tempel-Tuttle is not huge — only 3.6 km according to JPL data — thinking about the most recent report that P/LINEAR may be much larger in size, it gives me a remote hope that maybe P/LINEAR was by a fraction comparable to P/Tempel-Tuttle in the distant past? Although, the pessimistic scientist would have told me that P/Tempel-Tuttle has a longer orbital period than P/LINEAR and should preserve much more volatile materials. Any ejecta from P/LINEAR should have been long-buried into the zodiatic background. If P/LINEAR was ever active recently we should have seen a moderate annual Camelopardalids shower (in off-storm years, the ZHR of Leonids is actually around 15), but we aren’t even sure if the annual Camelopardalid shower exists!

If you want to be optimistic, think about Draconids. Its parent, 21P/Giacobini-Zinner, has a similar orbital period (6.6 yr) to P/LINEAR (5.1 yr); the encounter speed is also similar (20 km/s for Draconids, 16-19 km/s for Camelopardalids). Even the names have some sort of similarity (dragon vs. giraffe + camel + leopard hybrid). In 1933 and 1946 we had two gigantic Draconids storms (ZHR~10000) that even overshadowed all Leonids storms (except the one in 1966), with zero direct-hit in 1933 and only one direct-hit in 1946 (c.f. Maslov)! Draconids are also very quiet in other years, almost non-detectable. Of course, P/Giacobini-Zinner is a bit more active (OK, in fact it is by a magnitude of 3 in terms of Afrho). But since we have so many encounters all at once, even P/LINEAR was only one magnitude more active in the past, we should still have quite a show.

I will be driving to the Fox Observatory in a dark preserve area in the Bruce Peninsula tomorrow for the meteor shower. Well, no research stuff this time. I will just bring myself and see what’s going on. This should be my first time joining local amateurs since arriving Canada. I haven’t been doing amateur stuff for quite a while, but as somebody put it: “in any case, firstly I am a star-gazer, then I am a professional astronomer.”

UPDATE May 22: according to Peter Jenniskens, the Goldstone radar has detected the nucleus of P/LINEAR. I think I read somewhere that the lower detection limit is 1 km, so this indicates that the nucleus is larger than 1 km, which converged with the earlier reports by Carl Hergenrother. More calculations here. The window for Arecibo is May 23-27, so we should have more news coming in in a few days. The comet will be closest to the Earth on May 29, provides a very good opportunity for both radars.

Update on 209P/LINEAR and Camelopardalids

209P/LINEAR on Apr 9.25 (UT) by Gemini North + GMOS, the image is approximately 50"x30". (Quan-Zhi Ye/Gemini Observatory)

209P/LINEAR on Apr 9.25 (UT) by Gemini North + GMOS, the image is approximately 50″x30″. North is up (Quan-Zhi Ye/Gemini Observatory)

Syndyne-synchrone modeling of the Gemini image, courtesy of Man-To Hui

Syndyne-synchrone modeling of the Gemini image, courtesy of Man-To Hui (UCLA)

A bit more news on 209P/LINEAR and the forthcoming Camelopardalid meteor shower:

  • Carl Hergenrother (U Arizona) reported his broad-band photometry of P/LINEAR in CBET 3870. His analysis indicated a slow rotator (best fit ~21.86 hr) and a larger-than-expected nucleus (at least 2 km). He also suggested that the comet is only active within 1.4 AU from the Sun.
  • There have been a few reports on meteorobs mailing list and noted by the American Meteor Society about some fireballs that looks like Camelopardalid member (northern radiant + slow). I remain skeptical until I see the orbit.
  • Peter Jenniskens (SETI) is hosting a great website here and keeping collecting information about P/LINEAR and Camelopardalids. On the post of May 20 he noted the higher chance of seeing lunar meteoroid impacts as calculated by Peter Zimnikoval. The predicted peak time for the moon is about 4h UT on May 24.
  • On the same date, Jenniskens also wrote that he and his colleagues detected an annual meteor shower called sigma Ursae Majorids in the CAMS network that appears in mid June. Note that this is actually reported in a submitted paper and he did not note the registered Camelopardalid meteor shower (code 451; this may or may not be the same Camelopardalid meteor shower we used to refer the forthcoming outburst) he mentioned in his earlier study (Rudawska & Jennsikens 2014). It is not clear to me why is this — for example, if these two meteor showers are in fact the same one.
  • Jenniskens also reported the measurement by David Schleicher (Lowell) which showed an extremely low activity of P/LINEAR (CBET pending).

For me, I have been trying to learn IRAF to reduce my spectra taken with Gemini in early April at the breaks of my thesis project. Well, I managed to do it at last (mind you, that was an EUREKA moment!), but I am yet to refine it (combining more frames, etc). Initial measurement of cometary emission species of CN, C_2 and C_3 (upper limit is <~10**25 mol/s) agree with David’s suggestion and the conclusion of our earlier study that P/LINEAR seems to be very depleted in dust production. Meanwhile, I also check the daily log of CAMO and I do not see any activity pops up in either optical system or the radar.

Today Apostolos Christou from Armagh Observatory visited our group and brought us a surprise — a fresh-new prediction by David Asher and Robert McNaught (I first learnt the two’s names when I was in grade 6 in primary school when preparing for the Leonids 1999 return). Their prediction kinds of aligned with me and Paul’s prediction, although their timing is more inclined to other predictions (peaks around 7h UT) and their predicted FWHM is shorter (~40 min). They also thought that materials older than 52-rev (~1800) is likely heavily perturbed and is difficult to predict. I talk to Apostolos and Paul about the idea of resonance enhancements (i.e. certain kinds of orbit setups that can reduce the effect of perturbation and preserve strong enhancements within the trail, see the strong and unexpected outburst in 1998 Leonids). They thought that perhaps nobody has taken a closer look into this (Paul said he didn’t), so we probably won’t know until we see it. Keep in mind that surprise can happen!

After all, my thought: we will know in 48 hours. I still think that the activity due to the calculated trails (1800-1900s) will likely be weak (ZHR~10-ish, maybe) and faint (rich in +5 magnitude, maybe) unless we are really lucky (e.g. P/LINEAR is the remnant of a recent catastrophic event or similar things like that). Materials older than 52-rev may have a shoot there, too. My advisor, Peter Brown, also noted that any meteorite-dropper will have to be at least kg-sized, and I don’t see how can an extincting comet do that. But surely we never know…

Some thoughts on the forthcoming Camelopardalid meteor shower

The tiny comet 209P/LINEAR and its associated Camelopardalid meteor shower (which may produce an outburst on May 24, less than two weeks from now) are getting attentions, and it seems that people start talking about my earlier work with Prof. Paul Wiegert that made prediction of this new meteor shower — hmm, not bad for a first year PhD, I guess!

However, I saw people quoting the number of ZHR=200 appeared somewhere in the paper (for example, Sky & Telescope and EarthSky), perhaps our wording in the paper was too cautious and I find the need to clarify. Indeed, we stated “a predicted ZHR of about 200 for our nominal scenario” (p. 3286 just under Fig. 3), but to my understanding of how Paul construct his model, this “nominal scenario” actually means that “209P/LINEAR is a kind-of nominal comet”, like those parent bodies of well-known and predicted meteor showers, such as 21P/Giacobini-Zinner (which is really what my Master’s thesis is about, by the way) or 55P/Tempel-Tuttle. Since our analyse seem to show that the dust/gas activity of 209P/LINEAR seems to be 1-2 magnitude lower than a “nominal comet” at its size, the “true” ZHR of the meteor shower may also be 1-2 magnitude lower, so I incline to expect a ZHR around 10-ish.

In the paper, we also showed that the cometary tail as imaged in 2009 was dominated by large, millimeter-sized particles, and numerical simulation suggested that particles at this size are likely to dominate the May 24 outburst, which may suggest that the outburst event “may be dominated by bright meteors”. Well, darn, I should have used terms like “above-average brightness” — as the Camelopardalid meteoroids are exceptionally slow when arrive the Earth (about 16 km/s). Assuming a density of 1000 kg/m^3, a millimeter-sized particle is about 0.01 g. If we use the figure below for a conversion, we see that a millimeter-sized Camelopardalid meteoroid corresponds to a +6 magnitude meteor! (meteor’s absolute magnitude: the magnitude of the meteor as seen by the observer when the meteor is placed at a height of 100 km at zenith direction from the observer)

The relation between meteor's brightness and its arrival speed (M. Campbell-Brown and P. Brown)

The relation between meteor’s brightness and its arrival speed (M. Campbell-Brown and P. Brown)

Hmm, sounds not very encouraging. But I will be more than happy to find out if I am wrong. In fact, the uncertainty is so large that we literally won’t know what we will see until we see it. For example, as the event is caused by the material released by 209P/LINEAR about two century ago, the comet could well have been more active at that time — or it could be the remnant of a recent catastrophic event which would mean that a large amount of meteoroids have been deposit in the orbit. This is why we need meteor observation, it is like a time machine and can tell us some information about the parent body in its past.

An interesting point I noticed is that at least two groups (Rudawska & Jenniskens 2013, Meteoroids, and Segon et al. 2014, JIMO 42) reported that they found a weak annual meteor shower in May while examining their own video data that may be linked to 209P/LINEAR. However, both groups reported a slightly earlier date (Rudawska & Jenniskens reported April 22 to May 6, Segon et al. reported April 24 to June 4 and peaked on May 12). If this linkage is real, then it implied that 209P/LINEAR was releasing more material possibly several centuries ago, as it takes time for the material to distribute around the orbit and shift from the parent body. From the perspective of dynamics, it is very difficult to chase the comet back to before ~1800s, as the comet makes frequent close approach to Jupiter that alters its orbit.

In any case, I will keep my eyes on this event. After the excitement of the last Leonids return in 1998-2002 (which produced three meteor storms and officially marked my involvement to meteor science!), it seems we need to wait quite a bit (maybe a few decades) for the next meteor storm, so I feel lucky to be able to involve in a meteor outburst prediction… and I am eager to find out the result. I have placed quite a bit of side projects around it as I also got time on Gemini for cometary spectra and is working with my friends for some very deep exposures of the comet, I may write a bit about those later — just let me figure out how to work with IRAF…

Installing Debian 7 + Xfce 4.8 on ThinkPad X60


In this tutorial we will go through the installation of Debian 7 (Wheezy) + Xfce 4.8 environment on a ThinkPad X60 1709APC laptop. ThinkPad X60 was released in January 2006 and it is among the last ThinkPad series that beared the “IBM ThinkPad” mark on its lower right corner. I have used the original Windows XP Home (which came with my ThinkPad X60), Ubuntu 12.04 LTS + Unity, 12.10 + Unity, Debian 6 + GNOME 2, Debian 7 + GNOME 3 (Default and Classic) and Xfce, and eventually decide to settle down at the (much) faster, newer and more stable Debian + Xfce. If you are interested in a comparison of each desktop environment, you may find here as a good start.

The CPU of 1709APC (Intel Core Duo T2300) does not support x64 system so we must use the x86 version. The firmware of 1709APC also does not support physical memory over 3GB (even with PAE enabled).

The creation of this document is inspired by “Debian Wheezy on Lenovo ThinkPad L420”. I got hints and helps from numerious websites and posts over years and I hope this document can be among one of them that are of some help to others.

Revision History

  • 2014 April 20: update the solution to Fn+F7.
  • 2014 April 17: creation.

Installing Debian 7 + Xfce Environment

The installation of the Debian 7 + Xfce 4.8 system is simple. You can download the most recent i386 intallation image from here. For me, the ~630MB debian-7.x.x-i386-xfce-CD-1.iso is sufficient to use. You can burn it into your USB disk (make sure it is unmounted) with the following command. Note: make sure to change /dev/sdc to the actual address of your USB device!

$ cp debian-7.x.x-i386-xfce-CD-1.iso /dev/sdc

After this, you can directly boot from the USB disk and start the installation.

For me, these items work out of the box:

  • Keyboard and trackpoint
  • Display and VGA out (manual switch)
  • Fn Keys: F3, F5, F7
  • Volume control (but see fix)
  • Fn+Home/End for brightness control (but see “remaining issues”)
  • USB ports
  • SD card reader
  • Ethernet

Most of the Fn keys do not work naturally even with tpb package installed, but this can be fixed by tweaks. There is an excellent page on on how to get Fn keys to work, but it looks to be outdated for Debian 7 (thinkpad_acpi comes with the installation anyway) and I have no luck with it, although it does offer some hints on diagnosing the issues.

Fixing Issues

Beeps in Moving Cursor

The laptop beeps when the cursor is moving out of range (e.g. backspace at the beginning of a text), and this cannot be turned off at the setup of the mixer. Solution: create /etc/modprobe.d/blacklist.conf, insert the following lines and reboot:

blacklist pcspkr
blacklist snd_pcsp
Fn+F2 Lock Screen

The Fn+F2 does not work out of the box, but there is a fast and painless workaround with xflock4 command which is included in xscreensaver package. Navigate to Application Menu > Settings > Keyboard > Application Shortcuts, and associate xflock4 to Fn+F2 and we are done.

I personally would not recommend modifying the ACPI as it seems more complicated than the shortcut method, there could well be a clever way to do this.

Fn+F4/F12 Suspend/Hibernation Not Working

I am amazed that Fn+F4/F12 does not work out of the box, it seems not many people have this issue. The keys were working without any additional work for my last intallation (Debian 7.0 beta + GNOME 3.6). The reason is in fact simple but not obvious to me at the first place: in xfce4-power-manager you can control the behavior after sleep/suspend and hibernation keys have been pressed, and by default they are set to “do nothing”!

If you have tried this trick without luck and you think your issue may be hardware-related, you can try acpi_listen and xev to see whether your keys are really responsive, if nothing shows on your screen when you press the keys with these commands, then you may have a bigger trouble! Otherwise you can check if pm-utils is properly installed by, for example, manually executing sudo pm-suspend to see if the laptop can enter suspend mode properly.

As an ending note, to avoid reloading issues after hibernation, be sure to create the file /etc/pm/config.d/thinkpad_acpi and add a single line to it:

SUSPEND_MODULES="thinkpad_acpi iwlwifi psmouse"
Fn+F4/F12 Suspend/Hibernation Not Locking the Screen

After getting Fn+F4/F12 working, I realize that the screen is not locked with these two keys, while if you enter the suspend/hibernation mode using the Applications Menu, screen is locked properly. This seems directly opposite than what Theiling reported. Theiling’s tweak is working, but I have one occasion that when you want to enter suspend/hibernation mode via Fn+F4/F12 you have to lock and unlock your screen first. This issue magically goes away when I tweak other things so I am not sure what makes it disappeared. I also tried the method of 00screensaver-lock posted on archlinux but it does not seems to be working.

Theiling’s tweak is simply create /etc/pm/sleep.d/40_xfce4-lock-screen with the following content and make it executable:

#! /bin/sh -x
# Hack for xfce4-session v4.8 to support screen lock on sleeping.
case "$1" in
. /usr/share/acpi-support/power-funcs
for x in $d/X*; do
if test "x$XAUTHORITY" != x
export DISPLAY=":$displaynum"
if xprop -root _DT_SAVE_MODE | grep -q xfce4
CMD="xfconf-query -c xfce4-power-manager -p $KEY || echo true"
DOLOCK=`(su "$XUSER" -c "$CMD") 2&gt;/dev/null`
if test "x$DOLOCK" = "xtrue"

Theiling also reports that the issue is fixed in Xfce 4.9.

Fn+F7 Switch between Display/VGA

The Fn+F7 key will invoke xfce4-display-settings, but this can be nasty when one disconnect an external monitor from the laptop: the display goes no where and you will have to manually restart lightdm to get the display back (I think there must be a cleverer way to deal with this). After some search and experiment, I found an easy way to work around this, although not fully what I am hoping for: navigate to Application Menu > Settings > Keyboard > Application Shortcuts, and associate xrandr –auto to Fn+F7. There is an excellent workaround as suggested here: just create the following sh file, place it somewhere (e.g. /etc/acpi/ and make it as executable (with chmod +x):

# Based on the script from
# <span class="skimlinks-unlinked"></span>

# Will do a cycling output from state 0 to 2 and use a sound as feedback
# State VGA LVDS Beeps
#   0    0   1      1
#   1    1   0      2
#   2    1   1      3
#   (back to state 0)  

#For identifying our monitors use xrandr tool and view output
LVDS=LVDS1      # could be another one like: LVDS, LVDS-1, etc
VGA=VGA1        # could be another one like: VGA, VGA-1, etc
EXTRA="--right-of $LVDS" # addtional info while dual display

# Lets check both LVDS and VGA state from the string "$display connected ("
xrandr | grep -q "$LVDS connected (" && LVDS_IS_ON=0 || LVDS_IS_ON=1
xrandr | grep -q "$VGA connected (" && VGA_IS_ON=0 || VGA_IS_ON=1

# Output switch cycle
if [ $LVDS_IS_ON -eq 1 ] && [ $VGA_IS_ON -eq 1 ]; then
    #Go to state 0 -&gt; just LVDS
    xrandr --output $LVDS --auto
    xrandr --output $VGA --off
elif [ $LVDS_IS_ON -eq 1 ]; then
    #Go to state 1 -&gt; just VGA
    xrandr --output $LVDS --off
    xrandr --output $VGA --auto
    beep && beep
elif [ $VGA_IS_ON -eq 1 ]; then
    #Go to state 2 -&gt; both outputs
    xrandr --output $LVDS --auto
    xrandr --output $VGA --auto $EXTRA
    beep && beep && beep
    #This should never be reached but just in case..
    xrandr --output $LVDS --auto
    beep && beep && beep && beep

You can associate the script to Fn+F7, so it will automatically loop around the setup (laptop only > dual monitor same display > dual monitor extended display > external only) when you press Fn+F7. You can also automate the things when you plug/unplug the cable. Create /etc/screen-autoswitch.hotplug with the following content:

#! /bin/sh
# This is run from an udev rule. It needs to find out which user is the X user and run switch-auto as
# that user in order to connect to the X server.

. /usr/share/acpi-support/power-funcs

for x in $d/X*; do
if test "x$XAUTHORITY" != x
sleep 2 # wait for monitor to settle
for screen in 0 1
export DISPLAY=":$displaynum.$screen"

Make this file executable. Note that if you place elsewhere you need to change to location accordingly. Lastly, create /etc/udev/rules.d/40-display.rules (does not need to be executable) with:

ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/etc/screen-autoswitch.hotplug"

And here we done!

Maximizing Window with Double Clicks on the Title Bar

Initially, maximazing the window with double clicks on the title bar seems buggy to me, as the window may or may not be maximazed. This is because the default interval threshold (250 ms) is too short for me. Navigate thru Applications Menu > Settings > Mouse > Behavior, and increase the “Double Click Time” should do the trick. For me 400 ms is enough.

ThinkPad Utilities

Be sure to install thinkfan and hdapsd for automate fan control and IBM Hard Drive Active Protection System.

Wireless Firmware

The wireless firmware is in the non-free repository, so it does not come with the installation disk. First, we modify /etc/apt/sources.list and add the following lines:

deb wheezy main non-free contrib
deb-src wheezy main non-free contrib
deb wheezy/updates main non-free contrib
deb-src wheezy/updates main non-free contrib

Then we execute the following commands from the console:

$ su
$ aptitude update &amp;&amp; aptitude install firmware-iwlwifi wireless-tools
$ modprobe -r iwlwifi
$ modprobe iwlwifi
$ iwconfig
Workrave Applet Corruption

The Workrave applet in the notification area is corrupted with the original Workrave 1.9.909 in Xfce 4.8. I remove the original one and compile the most recent version from git (1.10.2 at the time of writing) and it works like a charm.

Remaining Issues

  • The drag-n-drop feature seems buggy with Iceweasel 24.4.0.
  • Xfce/Thunar mounting SD card: after clicking the “eject” icon in the sidebar, the icon is still there despite the device has been ejected.
  • Fn+Home/End moves in multiple steps.
  • The volume control keys can only control the Alsa mixer called ThinkPad Console Audio Control, this leads to confliction if you use an external keyboard that can control volume and another mixer (like PulseAudio). Things are working, but just inconvenient.


  • Fn keys player control.
  • Fn+Space (screen zoom).
  • Some old-fashion features like the modem, infrared port and 1394 port.

Here is another research blog!

My name is Quan-Zhi Ye, you can just call me “Yeh”. I have been a die-hard lover of astronomy since a kid, and I am proud to find myself keep following the dream over years. I am currently doing my PhD in astronomy with Prof. Peter Brown at the University of Western Ontario on meteor science, but I am also very interested in other topics in astrophysics, atmospheric and planetary sciences and have been involved in some side projects in these areas. I am also eager to do outreach, but it is mostly within China (my home country). Although English is not my first language, I guess it won’t stop me from start writing a research blog. Perhaps things will get improved over time. I plan to put together bits from my research or something I find useful/related to my research, and I hope they can be of use to someone at some time, who knows — let’s see how this play out.